for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
"""Type declarations for vocabulary functionality"""
import abc
from annif.corpus import Subject
class SubjectIndex(metaclass=abc.ABCMeta):
"""Base class for an index that remembers the associations between
integer subject IDs and their URIs and labels."""
@abc.abstractmethod
def __len__(self) -> int:
pass # pragma: no cover
@property
def languages(self) -> list[str] | None:
def __getitem__(self, subject_id: int) -> Subject:
def contains_uri(self, uri: str) -> bool:
def by_uri(self, uri: str, warnings: bool = True) -> int | None:
"""return the subject ID of a subject by its URI, or None if not found.
If warnings=True, log a warning message if the URI cannot be found."""
def by_label(self, label: str | None, language: str) -> int | None:
"""return the subject ID of a subject by its label in a given
language"""
def active(self) -> list[tuple[int, Subject]]:
"""return a list of (subject_id, Subject) tuples of all subjects that
are available for use"""