Skip to main content

OntologyElement Objects

@dataclass
class OntologyElement(ABC)

children

@property
def children() -> Sequence[OntologyElement]
Returns an empty sequence of children nodes for this ontology element. This method is meant to be overridden by subclasses that have actual child nodes.

title

@property
@abstractmethod
def title() -> str
Abstract property that should return the title of the ontology element. Must be implemented by subclasses.

get_child_by_hash

def get_child_by_hash(
    feature_node_hash: str,
    type_: Optional[Type[OntologyNestedElementT]] = None
) -> OntologyNestedElementT
Retrieves the first child node of this ontology element with the matching feature node hash. If multiple children have the same hash, the ontology is in an invalid state. Throws an exception if no matching child is found or if the type does not match. Arguments:
  • feature_node_hash - The feature node hash of the child node to find.
  • type_ - Optional type to check the type of the child node.
Returns: The child node with the specified feature node hash and type.

get_children_by_title

def get_children_by_title(
    title: str,
    type_: Optional[Type[OntologyNestedElementT]] = None
) -> List[OntologyNestedElementT]
Retrieves all child nodes of this ontology element that match the specified title and type. Arguments:
  • title - The exact title of the child nodes to find.
  • type_ - Optional type to filter the child nodes.
Returns: A list of child nodes with the specified title and type.

get_child_by_title

def get_child_by_title(
    title: str,
    type_: Optional[Type[OntologyNestedElementT]] = None
) -> OntologyNestedElementT
Retrieves a single child node of this ontology element that matches the specified title and type. Throws an exception if more than one or no child with the specified title and type is found. Arguments:
  • title - The exact title of the child node to find.
  • type_ - Optional type to check the type of the child node.
Returns: The child node with the specified title and type. Raises:
  • OntologyError - If more than one or no matching child is found.