TRIPS (indra.sources.trips)

TRIPS API (indra.sources.trips.trips_api)

indra.sources.trips.trips_api.process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True, offline=False, service_endpoint='drum')[source]

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
  • oflline (Optional[bool]) – If True, offline reading is used with a local instance of DRUM, if availble. Default: False
  • service_endpoint (Optional[str]) – Selects the TRIPS/DRUM web service endpoint to use. Is a choice between “drum” (default) and “drum-dev”, a nightly build.
Returns:

tp – A TripsProcessor containing the extracted INDRA Statements in tp.statements.

Return type:

TripsProcessor

indra.sources.trips.trips_api.process_xml(xml_string)[source]

Return a TripsProcessor by processing a TRIPS EKB XML string.

Parameters:xml_string (str) – A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html
Returns:tp – A TripsProcessor containing the extracted INDRA Statements in tp.statements.
Return type:TripsProcessor

TRIPS Processor (indra.sources.trips.processor)

class indra.sources.trips.processor.TripsProcessor(xml_string)[source]

The TripsProcessor extracts INDRA Statements from a TRIPS XML.

For more details on the TRIPS EKB XML format, see http://trips.ihmc.us/parser/cgi/drum

Parameters:xml_string (str) – A TRIPS extraction knowledge base (EKB) in XML format as a string.
tree

xml.etree.ElementTree.Element – An ElementTree object representation of the TRIPS EKB XML.

statements

list[indra.statements.Statement] – A list of INDRA Statements that were extracted from the EKB.

doc_id

str – The PubMed ID of the paper that the extractions are from.

sentences

dict[str: str] – The list of all sentences in the EKB with their IDs

paragraphs

dict[str: str] – The list of all paragraphs in the EKB with their IDs

par_to_sec

dict[str: str] – A map from paragraph IDs to their associated section types

extracted_events

list[xml.etree.ElementTree.Element] – A list of Event elements that have been extracted as INDRA Statements.

get_activations()[source]

Extract direct Activation INDRA Statements.

get_activations_causal()[source]

Extract causal Activation INDRA Statements.

get_activations_stimulate()[source]

Extract Activation INDRA Statements via stimulation.

get_active_forms()[source]

Extract ActiveForm INDRA Statements.

get_active_forms_state()[source]

Extract ActiveForm INDRA Statements.

get_agents()[source]

Return list of INDRA Agents corresponding to TERMs in the EKB.

This is meant to be used when entities e.g. “phosphorylated ERK”, rather than events need to be extracted from processed natural language. These entities with their respective states are represented as INDRA Agents.

Returns:agents – List of INDRA Agents extracted from EKB.
Return type:list[indra.statements.Agent]
get_all_events()[source]

Make a list of all events in the TRIPS EKB.

The events are stored in self.all_events.

get_complexes()[source]

Extract Complex INDRA Statements.

get_degradations()[source]

Extract Degradation INDRA Statements.

get_modifications()[source]

Extract all types of Modification INDRA Statements.

get_modifications_indirect()[source]

Extract indirect Modification INDRA Statements.

get_regulate_amounts()[source]

Extract Increase/DecreaseAmount Statements.

get_syntheses()[source]

Extract IncreaseAmount INDRA Statements.

TRIPS Client (indra.sources.trips.trips_client)

indra.sources.trips.trips_client.get_xml(html)[source]

Extract the EKB XML from the HTML output of the TRIPS web service.

Parameters:html (str) – The HTML output from the TRIPS web service.
Returns:
  • The extraction knowledge base (EKB) XML that contains the event and term
  • extractions.
indra.sources.trips.trips_client.save_xml(xml_str, file_name, pretty=True)[source]

Save the TRIPS EKB XML in a file.

Parameters:
  • xml_str (str) – The TRIPS EKB XML string to be saved.
  • file_name (str) – The name of the file to save the result in.
  • pretty (Optional[bool]) – If True, the XML is pretty printed.
indra.sources.trips.trips_client.send_query(text, service_endpoint='drum', query_args=None)[source]

Send a query to the TRIPS web service.

Parameters:
  • text (str) – The text to be processed.
  • service_endpoint (Optional[str]) – Selects the TRIPS/DRUM web service endpoint to use. Is a choice between “drum” (default) and “drum-dev”, a nightly build.
  • query_args (Optional[dict]) – A dictionary of arguments to be passed with the query.
Returns:

html – The HTML result returned by the web service.

Return type:

str