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

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

doc_id

str – Document ID

statements

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

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

extract_noun_relations(key)[source]

Extract relationships where a term/noun affects another term/noun

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

list[indra.statements.Statement] – A list of INDRA statements that were extracted by the processor.

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.