Eidos (indra_world.sources.eidos)

API (indra_world.sources.eidos.api)

indra_world.sources.eidos.api.process_json(json_dict, grounding_ns=None, extract_filter=None, grounding_mode=None)[source]

Return an EidosProcessor by processing a Eidos JSON-LD dict.

Parameters:
  • json_dict (dict) – The JSON-LD dict to be processed.

  • grounding_ns (Optional[list]) – A list of name spaces for which INDRA should represent groundings, when given. If not specified or None, all grounding name spaces are propagated. If an empty list, no groundings are propagated. Example: [‘UN’, ‘WM’], Default: None

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’. If not given, all relation types are extracted. This argument can be used if, for instance, only Influence statements are of interest. Default: None

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

Returns:

ep – A EidosProcessor containing the extracted INDRA Statements in its statements attribute.

Return type:

EidosProcessor

indra_world.sources.eidos.api.process_json_file(file_name, grounding_ns=None, extract_filter=None, grounding_mode='compositional')[source]

Return an EidosProcessor by processing the given Eidos JSON-LD file.

This function is useful if the output from Eidos is saved as a file and needs to be processed.

Parameters:
  • file_name (str) – The name of the JSON-LD file to be processed.

  • grounding_ns (Optional[list]) – A list of name spaces for which INDRA should represent groundings, when given. If not specified or None, all grounding name spaces are propagated. If an empty list, no groundings are propagated. Example: [‘UN’, ‘WM’], Default: None

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’. If not given, all relation types are extracted. This argument can be used if, for instance, only Influence statements are of interest. Default: None

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

Returns:

ep – A EidosProcessor containing the extracted INDRA Statements in its statements attribute.

Return type:

EidosProcessor

indra_world.sources.eidos.api.process_json_str(json_str, grounding_ns=None, extract_filter=None, grounding_mode='compositional')[source]

Return an EidosProcessor by processing the Eidos JSON-LD string.

Parameters:
  • json_str (str) – The JSON-LD string to be processed.

  • grounding_ns (Optional[list]) – A list of name spaces for which INDRA should represent groundings, when given. If not specified or None, all grounding name spaces are propagated. If an empty list, no groundings are propagated. Example: [‘UN’, ‘WM’], Default: None

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’. If not given, all relation types are extracted. This argument can be used if, for instance, only Influence statements are of interest. Default: None

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

Returns:

ep – A EidosProcessor containing the extracted INDRA Statements in its statements attribute.

Return type:

EidosProcessor

indra_world.sources.eidos.api.process_text(text, save_json='eidos_output.json', webservice=None, grounding_ns=None, extract_filter=None, grounding_mode='compositional')[source]

Return an EidosProcessor by processing the given text.

This constructs a reader object via Java and extracts mentions from the text. It then serializes the mentions into JSON and processes the result with process_json.

Parameters:
  • text (str) – The text to be processed.

  • save_json (Optional[str]) – The name of a file in which to dump the JSON output of Eidos.

  • webservice (Optional[str]) – An Eidos reader web service URL to send the request to. If None, the reading is assumed to be done with the Eidos JAR rather than via a web service. Default: None

  • grounding_ns (Optional[list]) – A list of name spaces for which INDRA should represent groundings, when given. If not specified or None, all grounding name spaces are propagated. If an empty list, no groundings are propagated. Example: [‘UN’, ‘WM’], Default: None

  • extract_filter (Optional[list]) – A list of relation types to extract. Valid values in the list are ‘influence’, ‘association’, ‘event’. If not given, all relation types are extracted. This argument can be used if, for instance, only Influence statements are of interest. Default: None

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

Returns:

ep – An EidosProcessor containing the extracted INDRA Statements in its statements attribute.

Return type:

EidosProcessor

indra_world.sources.eidos.api.reground_texts(texts, ont_yml, webservice=None, topk=10, filter=True, is_canonicalized=True)[source]

Return grounding for concept texts given an ontology.

Parameters:
  • texts (list[str]) – A list of concept texts to ground.

  • ont_yml (str) – A serialized YAML string representing the ontology.

  • webservice (Optional[str]) – The address where the Eidos web service is running, e.g., http://localhost:9000. If None, a local Eidos JAR is invoked via pyjnius. Default: None

  • topk (Optional[int]) – The number of top scoring groundings to return. Default: 10

  • is_canonicalized (Optional[bool]) – If True, the texts are assumed to be canonicalized. If False, Eidos will canonicalize the texts which yields much better groundings but is slower. Default: False

  • filter (Optional[bool]) – If True, Eidos filters the ontology to remove determiners from examples and other similar operations. Should typically be set to True. Default: True

Returns:

A list of the top k scored groundings for each text in the list.

Return type:

list[list]

Client (indra_world.sources.eidos.client)

indra_world.sources.eidos.client.grounding_dict_to_list(groundings)[source]

Transform the webservice response into a flat list.

indra_world.sources.eidos.client.reground_texts(texts, ont_yml, webservice, topk=10, is_canonicalized=False, filter=True, cache_path=None)[source]

Ground concept texts given an ontology with an Eidos web service.

Parameters:
  • texts (list[str]) – A list of concept texts to ground.

  • ont_yml (str) – A serialized YAML string representing the ontology.

  • webservice (str) – The address where the Eidos web service is running, e.g., http://localhost:9000.

  • topk (Optional[int]) – The number of top scoring groundings to return. Default: 10

  • is_canonicalized (Optional[bool]) – If True, the texts are assumed to be canonicalized. If False, Eidos will canonicalize the texts which yields much better groundings but is slower. Default: False

  • filter (Optional[bool]) – If True, Eidos filters the ontology to remove determiners from examples and other similar operations. Should typically be set to True. Default: True

Returns:

A JSON dict of the results from the Eidos webservice.

Return type:

dict

Migration Table Processor (indra_world.sources.eidos.migration_table_processor)

Processor (indra_world.sources.eidos.processor)

class indra_world.sources.eidos.processor.EidosProcessorCompositional(json_dict, grounding_ns)[source]

Bases: EidosWorldProcessor

get_groundings(entity)[source]

Return groundings as db_refs for an entity.

class indra_world.sources.eidos.processor.EidosWorldProcessor(json_dict, grounding_ns)[source]

Bases: EidosProcessor

geo_context_from_ref(ref)[source]

Return a ref context object given a location reference entry.

get_groundings(entity)[source]

Return groundings as db_refs for an entity.

time_context_from_ref(timex)[source]

Return a time context object given a timex reference entry.

indra_world.sources.eidos.processor.ref_context_from_geoloc(geoloc)[source]

Return a RefContext object given a geoloc entry.

indra_world.sources.eidos.processor.time_context_from_timex(timex)[source]

Return a TimeContext object given a timex entry.