<commit_before>import os
import json
from collections import OrderedDict
import xml.etree.ElementTree as ET
from kqml import KQMLString, KQMLPerformative
from indra.sources import trips
from indra.statements import stmts_to_json, Agent
from bioagents import Bioagent


def ekb_from_text(text):
    """Return an EKB XML from the cache or by TRIPS reading from text."""
    ekb_xml = read_or_load(text)
    return ekb_xml


def ekb_kstring_from_text(text):
    """Return a KQML string representation of an EKB from text."""
    ekb_xml = ekb_from_text(text)
    ks = KQMLString(ekb_xml)
    return ks


def agent_from_text(text):
    """Return a single INDRA Agent from text."""
    ekb_xml = ekb_from_text(text)
    tp = trips.process_xml(ekb_xml)
    agents = tp.get_agents()
    return agents[0]


def agent_clj_from_text(text):
    """Return an INDRA Agent CL-JSON from text."""
    agent = agent_from_text(text)
    clj = Bioagent.make_cljson(agent)
    return clj


def stmts_from_text(text):<commit_msg>Handle complexes in TRA tests<commit_after>import os
import json
from collections import OrderedDict
import xml.etree.ElementTree as ET
from kqml import KQMLString, KQMLPerformative
from indra.sources import trips
from indra.statements import stmts_to_json, Agent
from bioagents import Bioagent


def ekb_from_text(text):
    """Return an EKB XML from the cache or by TRIPS reading from text."""
    ekb_xml = read_or_load(text)
    return ekb_xml


def ekb_kstring_from_text(text):
    """Return a KQML string representation of an EKB from text."""
    ekb_xml = ekb_from_text(text)
    ks = KQMLString(ekb_xml)
    return ks


def agent_from_text(text):
    """Return a single INDRA Agent from text."""
    ekb_xml = ekb_from_text(text)
    tp = trips.process_xml(ekb_xml)
    agents = tp.get_agents()
    for agent in agents:
        if agent.bound_conditions:
            return agent
    return agents[0]


def agent_clj_from_text(text):
    """Return an INDRA Agent CL-JSON from text."""
    agent = agent_from_text(text)
    clj = Bioagent.make_cljson(agent)
    return clj


def stmts_from_text(text):
{'fraction_non_alphanumeric': 0.07888521492678319, 'fraction_numerical': 0.000944733112895607, 'mean_word_length': 3.971830985915493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '885307', 'n_tokens_mistral': 739, 'n_tokens_neox': 716, 'n_words': 213}