<jupyter_start><jupyter_text>Arestas que sofrerão eventos de fechamento![Mapa com Arestas Utilizado](../img/events_edges_map.png)![Mapa com Arestas Utilizado](../img/events_edges_map_2.png)<jupyter_code>def chunk_nodes(nodes):
    """
    Usage:
    > chunk_nodes([1,2,3,4,5])
    [(1, 2), (2, 3), (3, 4), (4, 5)]
    """
    list1 = list(nodes)[:-1]
    list2 = list(nodes)[1:]
    
    return list(zip(list1, list2))
events_ways_tag = events_xml.getElementsByTagName('way')
map_ways_tag = map_xml.getElementsByTagName('way')

events_nodes_tags = events_xml.getElementsByTagName('node')
map_nodes_tags = events_xml.getElementsByTagName('node')

events_nodes = {}
events_edges = []
map_nodes = {}
map_edges = {}
for n in map_nodes_tags:
    map_nodes[int(n.getAttribute('id'))] = (float(n.getAttribute('lat')), float(n.getAttribute('lon')))
    
for n in events_nodes_tags:
    events_nodes[int(n.getAttribute('id'))] = (float(n.getAttribute('lat')), float(n.getAttribute('lon')))
for w in events_ways_tag:
    events_edges.append(int(w.getAttribute('id')))
events_edges_related = []
highest = 0
counter = 1
for w in map_ways_tag:
    tags = w.getElementsByTagName('tag')
    width = 2
    maxspeed = 0
    oneway = 1
    
    for t in tags:
        key = t.getAttribute('k')
        value = t.getAttribute('v')
        
        if (key == 'width'):
            width = float(value)
        elif (key == 'maxspeed'):
            maxspeed = int(value)/3.6
        elif (key == 'oneway'):
            oneway = 1 if (value == 'yes') else 0
    
    chunks = chunk_nodes(w.getElementsByTagName('nd'))
    for chunk in chunks:
        n1 = chunk[0].getAttribute('ref')
        n2 = chunk[1].getAttribute('ref')
        if (int(w.getAttribute('id')) in events_edges):
            events_edges_related.append([w.getAttribute('id'), n1, n2, counter])
        counter += 1
df = pd.DataFrame(columns=["type", "from", "to", "start_tick", "duration", "slowdown"])
counter = 0

for e in events_edges_related:
    df.loc[counter] = ["close_street", e[1], e[2], 100, 1700, 0]
    counter += 1
df.describe()
df.to_csv("../scenario_2_sao_paulo/inputs/events.csv", header=False, sep=";", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16681735985533455, 'fraction_numerical': 0.022151898734177215, 'mean_word_length': 3.678646934460888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '586794', 'license': 'MIT', 'n_tokens_mistral': 813, 'n_tokens_neox': 795, 'n_words': 153, 'path': 'utils/events_generator.ipynb', 'repo_name': 'LSS-USP/pmv_experiment', 'size': '2212'}