コード例 #1
0
ファイル: trips_api.py プロジェクト: jmuhlich/indra
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)
コード例 #2
0
ファイル: trips_api.py プロジェクト: lijielife/indra
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)
コード例 #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')
コード例 #4
0
ファイル: mra_test.py プロジェクト: sorgerlab/bioagents
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')