<commit_before>from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
import json
import logging
import objectpath
from indra.statements import Influence, Agent, Evidence


logger = logging.getLogger('eidos')


class EidosJsonLdProcessor(object):
    """This processor extracts INDRA Statements from Eidos JSON-LD output.

    Parameters
    ----------
    json_dict : dict
        A JSON dictionary containing the Eidos extractions in JSON-LD format.

    Attributes
    ----------
    tree : objectpath.Tree
        The objectpath Tree object representing the extractions.
    statements : list[indra.statements.Statement]
        A list of INDRA Statements that were extracted by the processor.
    """
    def __init__(self, json_dict):
        self.tree = objectpath.Tree(json_dict)
        self.statements = []

    def get_events_json_ld(self):
        events = \
            self.tree.execute("$.extractions[(@.@type is 'DirectedRelation')]")
        entities = \
            self.tree.execute("$.extractions[(@.@type is 'Entity')]")
        entity_ids = \
            self.tree.execute("$.extractions[(@.@type is 'Entity')].@id")
        entity_dict = {id:entity for id, entity in zip(entity_ids, entities)}

        for event in list(events):<commit_msg>Standardize extraction function in processor<commit_after>from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
import json
import logging
import objectpath
from indra.statements import Influence, Agent, Evidence


logger = logging.getLogger('eidos')


class EidosJsonLdProcessor(object):
    """This processor extracts INDRA Statements from Eidos JSON-LD output.

    Parameters
    ----------
    json_dict : dict
        A JSON dictionary containing the Eidos extractions in JSON-LD format.

    Attributes
    ----------
    tree : objectpath.Tree
        The objectpath Tree object representing the extractions.
    statements : list[indra.statements.Statement]
        A list of INDRA Statements that were extracted by the processor.
    """
    def __init__(self, json_dict):
        self.tree = objectpath.Tree(json_dict)
        self.statements = []

    def get_events(self):
        events = \
            self.tree.execute("$.extractions[(@.@type is 'DirectedRelation')]")
        entities = \
            self.tree.execute("$.extractions[(@.@type is 'Entity')]")
        entity_ids = \
            self.tree.execute("$.extractions[(@.@type is 'Entity')].@id")
        entity_dict = {id:entity for id, entity in zip(entity_ids, entities)}

        for event in list(events):
{'fraction_non_alphanumeric': 0.1087202718006795, 'fraction_numerical': 0.0, 'mean_word_length': 2.891336270190896, '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': '2208925', 'n_tokens_mistral': 741, 'n_tokens_neox': 713, 'n_words': 211}