Example #1
0
def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True):
    """Return a TripsProcessor by processing text.

    Parameters
    ----------
    text : str
        The text to be processed.
    save_xml_name : Optional[str]
        The name of the file to save the returned TRIPS extraction knowledge
        base XML. Default: trips_output.xml
    save_xml_pretty : Optional[bool]
        If True, the saved XML is pretty-printed. Some third-party tools
        require non-pretty-printed XMLs which can be obtained by setting this
        to False. Default: True

    Returns
    -------
    tp : TripsProcessor
        A TripsProcessor containing the extracted INDRA Statements
        in tp.statements.
    """
    html = trips_client.send_query(text)
    xml = trips_client.get_xml(html)
    if save_xml_name:
        trips_client.save_xml(xml, save_xml_name, save_xml_pretty)
    return process_xml(xml)
Example #2
0
def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True):
    """Return a TripsProcessor by processing text.

    Parameters
    ----------
    text : str
        The text to be processed.
    save_xml_name : Optional[str]
        The name of the file to save the returned TRIPS extraction knowledge
        base XML. Default: trips_output.xml
    save_xml_pretty : Optional[bool]
        If True, the saved XML is pretty-printed. Some third-party tools
        require non-pretty-printed XMLs which can be obtained by setting this
        to False. Default: True

    Returns
    -------
    tp : TripsProcessor
        A TripsProcessor containing the extracted INDRA Statements
        in tp.statements.
    """
    html = trips_client.send_query(text)
    xml = trips_client.get_xml(html)
    if save_xml_name:
        trips_client.save_xml(xml, save_xml_name, save_xml_pretty)
    return process_xml(xml)
Example #3
0
def test_build_model_from_ekb():
    m = MRA()
    html = trips_client.send_query('MEK1 phosphorylates ERK2.')
    ekb_xml = trips_client.get_xml(html)
    model = m.build_model_from_ekb(ekb_xml)
    assert (model is not None)
    assert (len(m.statements[0]) == 1)
    assert (isinstance(m.statements[0][0], indra.statements.Phosphorylation))
    assert (m.statements[0][0].enz.name == 'MAP2K1')
    assert (m.statements[0][0].sub.name == 'MAPK1')
Example #4
0
def test_build_model_from_ekb():
    m = MRA()
    html = trips_client.send_query('MEK1 phosphorylates ERK2.')
    ekb_xml = trips_client.get_xml(html)
    model = m.build_model_from_ekb(ekb_xml)
    assert(model is not None)
    assert(len(m.statements[0]) == 1)
    assert(isinstance(m.statements[0][0], indra.statements.Phosphorylation))
    assert(m.statements[0][0].enz.name == 'MAP2K1')
    assert(m.statements[0][0].sub.name == 'MAPK1')