Coverage for src/pysumo/indexabstractor : 94%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" This module abstracts all operations on the Ontology index. It is used for every read operation on the Ontology. It eases access to the Ontology and protects the data structures from direct user access.
This module contains:
- IndexAbstractor: The interface to the Ontology index. - AbstractGraph: An object containing selected graph nodes and relations. - AbstractGraphNode: A node in a AbstractGraph - DotGraph: A Graphical representation of an AbstractGraph with DOT
"""
""" The IndexAbstractor provides a high-level index of the AbstractSyntaxTree. Each Ontology is represented by a hashmap, the list of these hashmaps is the index. Average access time is in O(n) where n is the number of loaded Ontologies.
Variables:
- root: The root AbstractSyntaxTree node. - ontologies: The list of currently active Ontologies. - index: The index of all terms in the currently active Ontologies. - wordnet: A reference to the Object containing the SUMO-WordNet mapping.
Methods:
- init_wordnet: Initializes the WordNet mapping. - update_index: Updates the index. - search: Searches for a term in the Ontology. - get_ontology_file: Return an in-memory file object for an Ontology. - get_completions: Return a list of possible completions for the current index. - get_graph: Creates an abstract graph containing a view of the Ontology. - wordnet_locate: Returns information about a term from WordNet.
"""
""" Initializes the IndexAbstractor object. """
""" Initializes the SUMO mapping to WordNet. """
""" Updates the index with all new AST nodes in ast. """
""" Builds an index from self.root. """
""" Returns an in-memory file object for the Kif representation of ontology. """
""" Returns a list of possible completions for the currently loaded ontologies. """
""" Search for term in the in-memory Ontology. Returns all objects that match the search.
Returns:
- {Ontology : (String, int)[]}
"""
""" Returns the denormalized version of term. """
""" Returns a hierarchical view of the Ontology.
Arguments:
- variant: The list of terms against which the resulting AbstractGraph matches. - major: The position of the parent element. - minor: The position of the child element. - root: The root node to which all other nodes are related. - depth: The recursion depth.
Returns:
- AbstractGraph
Raises:
- KeyError
""" else:
""" Use the mapping from SUMO to WordNet to retrieve information about a term.
Arguments:
- term: the term to locate
Returns:
- String[]
Raises:
- KeyError
"""
except AttributeError: self.init_wordnet() return self._synonym_locate(term)
""" An abstract representation of a subset of an Ontology as a collection of nodes and relations.
Variables:
- nodes: The list of graph nodes. - relations: An adjacency matrix of all the paths in the graph.
"""
""" Initializes the AbstractGraph and instantiates variables. """ else: x: y for x, y in self.relations.items() if x in self.nodes}
""" Produces an AbstractGraph of all the currently active ontologies. """
""" Checks if node matches the variant. """ except IndexError: return False
""" Produces an AbstractGraph containing all relations of type variant. """
""" Filters the AbstractGraph so only children of root are kept up to a maximum depth. """ except KeyError: rel.add(minor)
""" A node in an AbstractGraph. Contains information necessary to recreate an AbstractSyntaxTree from an AbstractGraph.
Varibles:
- name: The name of the AbstractGraphNode.
"""
""" Initializes an AbstractGraphNode and instantiates variables. """
return not self.__eq__(other)
return str(self.name)
""" Normalizes term to aid in searching. """ |