CWMS (indra_world.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

API (indra_world.sources.cwms.api)

indra_world.sources.cwms.api.process_ekb(ekb_str, extract_filter=None, grounding_mode='flat')[source]

Processes an EKB string produced by CWMS.

Parameters
  • ekb_str (str) – EKB string to process

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’ and ‘migration’. If not given, only Influences are extracted since processing other relation types can be time consuming. This argument can be used if the extraction of other relation types such as Events are also of interest.

  • grounding_mode (Optional[str]) – Selects whether ‘flat’ or ‘compositional’ groundings should be extracted. Default: ‘flat’.

Returns

cp – A CWMSProcessor, which contains a list of INDRA statements in its statements attribute.

Return type

indra.sources.cwms.CWMSProcessor

indra_world.sources.cwms.api.process_ekb_file(fname, extract_filter=None, grounding_mode='flat')[source]

Processes an EKB file produced by CWMS.

Parameters
  • fname (str) – Path to the EKB file to process.

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’ and ‘migration’. If not given, only Influences are extracted since processing other relation types can be time consuming. This argument can be used if the extraction of other relation types such as Events are also of interest.

  • grounding_mode (Optional[str]) – Selects whether ‘flat’ or ‘compositional’ groundings should be extracted. Default: ‘flat’.

Returns

cp – A CWMSProcessor, which contains a list of INDRA statements in its statements attribute.

Return type

indra.sources.cwms.CWMSProcessor

indra_world.sources.cwms.api.process_text(text, save_xml='cwms_output.xml', extract_filter=None, grounding_mode='flat')[source]

Processes text using the CWMS web service.

Parameters
  • text (str) – Text to process

  • save_xml (Optional[str]) – A file name in which to dump the output from CWMS. Default: cwms_output.xml

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’ and ‘migration’. If not given, only Influences are extracted since processing other relation types can be time consuming. This argument can be used if the extraction of other relation types such as Events are also of interest.

  • grounding_mode (Optional[str]) – Selects whether ‘flat’ or ‘compositional’ groundings should be extracted. Default: ‘flat’.

Returns

cp – A CWMSProcessor, which contains a list of INDRA statements in its statements attribute.

Return type

indra.sources.cwms.CWMSProcessor

Processor (indra_world.sources.cwms.processor)

exception indra_world.sources.cwms.processor.CWMSError[source]

Bases: Exception

class indra_world.sources.cwms.processor.CWMSProcessor(xml_string)[source]

Bases: object

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.

migration_from_event(event_term)[source]

Return a Migration event from an EVENT element in the EKB.

class indra_world.sources.cwms.processor.CWMSProcessorCompositional(xml_string)[source]

Bases: indra_world.sources.cwms.processor.CWMSProcessor