CWMS (indra.sources.cwms)

CWMS is a variant of the TRIPS system. It is a general purpose natural language understanding system with applications in world modeling. For more information, see: http://trips.ihmc.us/parser/cgi/cwmsreader

CWMS API (indra.sources.cwms.api)

indra.sources.cwms.api.process_ekb(ekb_str)[source]

Processes an EKB string produced by CWMS.

Parameters:ekb_str (str) – EKB string to process
Returns:cp – A CWMSProcessor, which contains a list of INDRA statements in its statements attribute.
Return type:indra.sources.cwms.CWMSProcessor
indra.sources.cwms.api.process_ekb_file(fname)[source]

Processes an EKB file produced by CWMS.

Parameters:fname (str) – Path to the EKB file to process.
Returns:cp – A CWMSProcessor, which contains a list of INDRA statements in its statements attribute.
Return type:indra.sources.cwms.CWMSProcessor
indra.sources.cwms.api.process_rdf_file(text, rdf_filename)[source]

Process CWMS’s RDF output for the given statement and returns a processor populated with INDRA statements.

Parameters:
  • text (str) – Sentence to process
  • rdf_filename (str) – The RDF filename to process
Returns:

cp – A CWMSProcessor instance, which contains a list of INDRA Statements as its statements attribute.

Return type:

indra.sources.cwms.CWMSRDFProcessor

indra.sources.cwms.api.process_text(text, save_xml='cwms_output.xml')[source]

Processes text using the CWMS web service.

Parameters:text (str) – Text to process
Returns:cp – A CWMSProcessor, which contains a list of INDRA statements in its statements attribute.
Return type:indra.sources.cwms.CWMSProcessor

CWMS EKB Processor (indra.sources.cwms.processor)

exception indra.sources.cwms.processor.CWMSError[source]
class indra.sources.cwms.processor.CWMSProcessor(xml_string)[source]

The CWMSProcessor currently extracts causal relationships between terms (nouns) in EKB. In the future, this processor can be extended to extract other types of relations, or to extract relations involving events.

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

An ElementTree object representation of the TRIPS EKB XML.

Type:xml.etree.ElementTree.Element
doc_id

Document ID

Type:str
statements

A list of INDRA Statements that were extracted from the EKB.

Type:list[indra.statements.Statement]
sentences

The list of all sentences in the EKB with their IDs

Type:dict[str: str]
paragraphs

The list of all paragraphs in the EKB with their IDs

Type:dict[str: str]
par_to_sec

A map from paragraph IDs to their associated section types

Type:dict[str: str]
event_from_event(event_term)[source]

Return an Event from an EVENT element in the EKB.

extract_causal_relations()[source]

Extract Influence Statements from the EKB.

extract_events()[source]

Extract standalone Events from the EKB.

influence_from_event(event)[source]

Return an Influence from an EVENT element in the EKB.

influence_from_relation(relation)[source]

Return an Influence from a CC element in the EKB.

CWMS RDF Processor (indra.sources.cwms.rdf_processor)

class indra.sources.cwms.rdf_processor.CWMSRDFProcessor(text, rdf_filename)[source]

This processor extracts INDRA statements from CWMS RDF output.

Parameters:
  • text (str) – The source sentence as text
  • rdf_filename (str) – A string containing the RDF output returned by CWMS for that sentence
statements

A list of INDRA statements that were extracted by the processor.

Type:list[indra.statements.Statement]
extract_statement_from_query_result(res)[source]

Adds a statement based on one element of a rdflib SPARQL query.

Parameters:res (rdflib.query.ResultRow) – Element of rdflib SPARQL query result
extract_statements()[source]

Extracts INDRA statements from the RDF graph via SPARQL queries.