<commit_before>from ast import AST
import yaml


class ASTTranslator:

    def __init__(self, tree):
        self.tree = tree

    def translate(self):
        return yaml.dump({'type': 'program', 'code': []})<commit_msg>Add a basic ast translator<commit_after>import ast
import yaml


class ASTTranslator:

    def __init__(self, tree):
        self.tree = tree

    def translate(self):
        return yaml.dump(self._translate_node(self.tree))

    def _translate_node(self, node):
        if isinstance(node, ast.AST):
            return getattr('_translate_%s' % type(node).__name__)(**node.__dict__)
        elif isinstance(node, list):
            return [self._translate_node(n) for n in node]
        elif isinstance(node, dict):
            return {k: self._translate_node(v) for k, v in node.items()}
        else:
            return node

    def _translate_module(self, body):
        return {'type': 'program', 'code': self._translate_node(body)}

    def _translate_int(self, n):
        return {'type': 'int', 'value': n}
{'fraction_non_alphanumeric': 0.12439729990356799, 'fraction_numerical': 0.0, 'mean_word_length': 2.858736059479554, 'pattern_counts': {'":': 0, '<': 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': '2728122', 'n_tokens_mistral': 322, 'n_tokens_neox': 305, 'n_words': 86}