<commit_before>#!/usr/bin/env python
"""A more advanced Reducer, using Python iterators and generators."""

from itertools import groupby
from operator import itemgetter
import sys


def read_mapper_output(file, separator='\t'):
    for line in file:
        yield line.rstrip().split(separator, 1)


def main(separator='\t'):
    data = read_mapper_output(sys.stdin, separator=separator)
    for key, value in groupby(data, itemgetter(0)):
        nodes = eval(key)
        neighbours_list = eval(value)

        print("{}\t{}".format(nodes, neighbours_list))

if __name__ == "__main__":
    main()<commit_msg>Fix eval problem<commit_after>#!/usr/bin/env python
"""A more advanced Reducer, using Python iterators and generators."""

from itertools import groupby
from operator import itemgetter
import sys


def read_mapper_output(file, separator='\t'):
    for line in file:
        yield line.rstrip().split(separator, 1)


def main(separator='\t'):
    data = read_mapper_output(sys.stdin, separator=separator)
    for key, value in groupby(data, itemgetter(0)):
        nodes = eval(key)
        neighbours_list = [eval(i[1]) for i in value]

        print("{}\t{}".format(nodes, neighbours_list))

if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.128928283642224, 'fraction_numerical': 0.0040290088638195, 'mean_word_length': 3.9879518072289155, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6054678', 'n_tokens_mistral': 409, 'n_tokens_neox': 386, 'n_words': 109}