brel.characteristics.brel_aspect
This module contains the Aspect class. Aspects are the building blocks of the Context of a fact. They are split into two categories: core aspects and custom aspects.
Core aspects are the 5 base aspects: concept, period, entity and unit.
Custom aspects are all other aspects that are not core aspects.
====================
- author: Robin Schmidiger
- version: 0.2
- date: 08 January 2024
====================
Aspect Objects
class Aspect()
Base class for all aspects. An an aspect is a wrapper around a string-id. This string-id is called the name of the aspect. An aspect can also have human readable labels for its name. The four core aspects are instances of this class and are accessible as class attributes.
These four core aspects are available as the following class attributes:
Aspect.CONCEPT
Aspect.PERIOD
Aspect.ENTITY
Aspect.UNIT
A lot of reports omit the language aspect, but it can be emulated by using a custom aspect. All but the concept aspect are optional for a context.
get_name
def get_name() -> str
Get the name of the aspect.
is_core
def is_core() -> bool
Check if the aspect is a core aspect.
get_labels
def get_labels() -> list[BrelLabel]
Get the labels of the aspect.
from_QName
@classmethod
def from_QName(cls,
qname: QName,
labels: list[BrelLabel] | None = None) -> "Aspect"
Creates a new aspect from a QName.
The method get_name()
of the newly created aspect will return the string generated by qname.get()
.
Arguments:
qname
: the QName to create the aspect fromlabels
: A list of labels for the aspect. If None, an empty list is used.
from_str
@classmethod
def from_str(cls,
name: str,
labels: list[BrelLabel] | None = None) -> "Aspect"
Creates a new aspect from a string.
To access the core aspects, use the class attributes
Aspect.CONCEPT
, Aspect.PERIOD
, Aspect.ENTITY
and Aspect.UNIT
instead.
Arguments:
name
: The name of the aspectlabels
: A list of labels for the aspect. If None, an empty list is used.