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)[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
Returns: tp – A TripsProcessor containing the extracted INDRA Statements in tp.statements.
Return type:
-
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.
-
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, query_args=None)[source]¶ Send a query to the TRIPS web service.
Parameters: - text (str) – The text to be processed.
- 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