<commit_before>import os
import json
from collections import OrderedDict
from kqml import KQMLString, KQMLPerformative
from indra.statements import stmts_to_json
from indra.sources import trips


def ekb_from_text(text):
    ekb_xml = read_or_load(text)
    return ekb_xml
<commit_msg>A way to get an Agent from a name using Trips<commit_after>import os
import json
from collections import OrderedDict
import xml.etree.ElementTree as ET
from kqml import KQMLString, KQMLPerformative
from indra.statements import stmts_to_json, Agent
from indra.sources import trips


def agent_from_name(name):
    ekb_xml = ET.fromstring(ekb_from_text(name))
    term = ekb_xml.find('TERM')
    drum_term = term.find('drum-terms/drum-term')
    dbid = drum_term.attrib['dbid']
    dbids = dbid.split('|')
    db_refs = {k: v for k, v in [d.split(':') for d in dbids]}
    agent = Agent(name, db_refs=db_refs)
    return agent

def ekb_from_text(text):
    ekb_xml = read_or_load(text)
    return ekb_xml

{'fraction_non_alphanumeric': 0.08299595141700405, 'fraction_numerical': 0.0, 'mean_word_length': 4.619318181818182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, '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': '5250438', 'n_tokens_mistral': 362, 'n_tokens_neox': 354, 'n_words': 98}