middleware.vocabulary.search_index

Build and query a lexical index over indexed RDF vocabulary terms.

Attributes

LabelLookup

Classes

IndexedTerm

Normalized searchable fields for one vocabulary term.

VocabularySearchIndex

Lexical index over indexed vocabulary terms for ranked search.

Functions

strip_accents(→ str)

Remove combining marks after NFKD normalization.

split_identifier(→ str)

Split camelCase and separator-heavy identifiers into spaced words.

normalize_text(→ str)

Lowercase, accent-stripped text suitable for lexical matching.

tokenize(→ tuple[str, Ellipsis])

Return alphanumeric tokens extracted from normalized text.

uri_local_name(→ str)

Return the fragment or final path segment of uri.

Module Contents

class middleware.vocabulary.search_index.IndexedTerm

Normalized searchable fields for one vocabulary term.

uri: str
label: str
definition: str
term_type: middleware.namespaces.common.VocabularyTermType
vocabulary: str
super_terms: tuple[str, Ellipsis] = ()
domain: tuple[str, Ellipsis] = ()
range_: tuple[str, Ellipsis] = ()
label_norm: str = ''
label_tokens: tuple[str, Ellipsis] = ()
uri_local_name: str = ''
uri_local_name_norm: str = ''
uri_local_tokens: tuple[str, Ellipsis] = ()
definition_norm: str = ''
definition_tokens: tuple[str, Ellipsis] = ()
super_term_labels: tuple[str, Ellipsis] = ()
super_term_tokens: tuple[str, Ellipsis] = ()
domain_labels: tuple[str, Ellipsis] = ()
domain_tokens: tuple[str, Ellipsis] = ()
range_labels: tuple[str, Ellipsis] = ()
range_tokens: tuple[str, Ellipsis] = ()
searchable_text: str = ''
type middleware.vocabulary.search_index.LabelLookup = Mapping[str, str]
middleware.vocabulary.search_index.strip_accents(text: str) → str

Remove combining marks after NFKD normalization.

middleware.vocabulary.search_index.split_identifier(text: str) → str

Split camelCase and separator-heavy identifiers into spaced words.

middleware.vocabulary.search_index.normalize_text(text: str) → str

Lowercase, accent-stripped text suitable for lexical matching.

middleware.vocabulary.search_index.tokenize(text: str) → tuple[str, Ellipsis]

Return alphanumeric tokens extracted from normalized text.

middleware.vocabulary.search_index.uri_local_name(uri: str) → str

Return the fragment or final path segment of uri.

class middleware.vocabulary.search_index.VocabularySearchIndex

Lexical index over indexed vocabulary terms for ranked search.

terms: tuple[IndexedTerm, Ellipsis]
terms_by_uri: collections.abc.Mapping[str, IndexedTerm]
classmethod build(context: middleware.vocabulary_configuration.VocabularyContext) → Self

Index every term from context indexed vocabularies.

search(query: str, *, vocabularies: tuple[str, Ellipsis] = (), term_types: tuple[middleware.namespaces.common.VocabularyTermType, Ellipsis] = (), limit: int = 8) → middleware.vocabulary.search_model.TermSearchResponse

Rank indexed terms against query and return the top limit hits.