Ontology Module (indra_world.ontology)

Module containing the implementation of an IndraOntology for the World Modelers use case.

World Ontology (indra_world.ontology.ontology)

class indra_world.ontology.ontology.WorldOntology(url, yml=None)[source]

Represents the ontology used for World Modelers applications.

Parameters:

url (str) – The URL or file path pointing to a World Modelers ontology YAML.

url

The URL or file path pointing to a World Modelers ontology YAML.

Type:

str

yml

The ontology YAML as loaded by the yaml package from the URL.

Type:

list

add_entry(entry, examples=None, neg_examples=None)[source]

Add a new ontology entry with examples.

This works by adding the entry to the yml attribute first and then reloading the entire yaml to build a new graph.

Parameters:
  • entry (str) – The new entry.

  • examples (Optional[list of str]) – Examples for the new entry.

  • neg_examples (Optional[list of str]) – Negative examples for the new entry.

build_relations(node, tree, prefix)[source]

Build relations for the classic ontology format <= v3.0

build_relations_new_format(node, prefix)[source]

Build relations for the new ontology format > v3.0

dump_yml_str()[source]

Return a string-serialized form of the loaded YAML

Returns:

The YAML string of the ontology.

Return type:

str

initialize()[source]

Load the World Modelers ontology from the web and build the graph.

indra_world.ontology.ontology.load_world_ontology(url=None, default_type='compositional')[source]

Load the world ontology from a given URL or file path.

indra_world.ontology.ontology.load_yaml_from_path(path)[source]

Return a YAML object loaded from a YAML file URL.