<commit_before>"""
Utils for dealing with Nodes/Plugins.
"""

import json
import node
import types



class NodeEncoder(json.JSONEncoder):
    """
    Encoder for JSONifying nodes.
    """
    def default(self, n):
        """
        Flatten node for JSON encoding.
        """
        if issubclass(n, node.Node):
            return dict(
                name=n.name,
                description=n.description,
                arity=n.arity,
                stage=n.stage,
                passthrough=n.passthrough,
                parameters=n.parameters(),
            )
        return super(NodeEncoder, self).default(n)            



<commit_msg>Serialise input and output types<commit_after>"""
Utils for dealing with Nodes/Plugins.
"""

import json
import node
import types



class NodeEncoder(json.JSONEncoder):
    """
    Encoder for JSONifying nodes.
    """
    def default(self, n):
        """
        Flatten node for JSON encoding.
        """
        if issubclass(n, node.Node):
            return dict(
                name=n.name,
                description=n.description,
                arity=n.arity,
                stage=n.stage,
                passthrough=n.passthrough,
                parameters=n.parameters(),
                intypes=[t.__name__ for t in n.intypes],
                outtype=n.outtype.__name__
            )
        return super(NodeEncoder, self).default(n)            




{'fraction_non_alphanumeric': 0.09894736842105263, 'fraction_numerical': 0.0, 'mean_word_length': 1.5693693693693693, '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': '6588433', 'n_tokens_mistral': 407, 'n_tokens_neox': 379, 'n_words': 90}