middleware.vocabulary.search_index ================================== .. py:module:: middleware.vocabulary.search_index .. autoapi-nested-parse:: Build and query a lexical index over indexed RDF vocabulary terms. Attributes ---------- .. autoapisummary:: middleware.vocabulary.search_index.LabelLookup Classes ------- .. autoapisummary:: middleware.vocabulary.search_index.IndexedTerm middleware.vocabulary.search_index.VocabularySearchIndex Functions --------- .. autoapisummary:: middleware.vocabulary.search_index.strip_accents middleware.vocabulary.search_index.split_identifier middleware.vocabulary.search_index.normalize_text middleware.vocabulary.search_index.tokenize middleware.vocabulary.search_index.uri_local_name Module Contents --------------- .. py:class:: IndexedTerm Normalized searchable fields for one vocabulary term. .. py:attribute:: uri :type: str .. py:attribute:: label :type: str .. py:attribute:: definition :type: str .. py:attribute:: term_type :type: rdflib_reasoning.middleware.namespaces.common.VocabularyTermType .. py:attribute:: vocabulary :type: str .. py:attribute:: super_terms :type: tuple[str, Ellipsis] :value: () .. py:attribute:: domain :type: tuple[str, Ellipsis] :value: () .. py:attribute:: range_ :type: tuple[str, Ellipsis] :value: () .. py:attribute:: label_norm :type: str :value: '' .. py:attribute:: label_tokens :type: tuple[str, Ellipsis] :value: () .. py:attribute:: uri_local_name :type: str :value: '' .. py:attribute:: uri_local_name_norm :type: str :value: '' .. py:attribute:: uri_local_tokens :type: tuple[str, Ellipsis] :value: () .. py:attribute:: definition_norm :type: str :value: '' .. py:attribute:: definition_tokens :type: tuple[str, Ellipsis] :value: () .. py:attribute:: super_term_labels :type: tuple[str, Ellipsis] :value: () .. py:attribute:: super_term_tokens :type: tuple[str, Ellipsis] :value: () .. py:attribute:: domain_labels :type: tuple[str, Ellipsis] :value: () .. py:attribute:: domain_tokens :type: tuple[str, Ellipsis] :value: () .. py:attribute:: range_labels :type: tuple[str, Ellipsis] :value: () .. py:attribute:: range_tokens :type: tuple[str, Ellipsis] :value: () .. py:attribute:: searchable_text :type: str :value: '' .. py:type:: LabelLookup :canonical: Mapping[str, str] .. py:function:: strip_accents(text: str) -> str Remove combining marks after NFKD normalization. .. py:function:: split_identifier(text: str) -> str Split camelCase and separator-heavy identifiers into spaced words. .. py:function:: normalize_text(text: str) -> str Lowercase, accent-stripped text suitable for lexical matching. .. py:function:: tokenize(text: str) -> tuple[str, Ellipsis] Return alphanumeric tokens extracted from normalized ``text``. .. py:function:: uri_local_name(uri: str) -> str Return the fragment or final path segment of ``uri``. .. py:class:: VocabularySearchIndex Lexical index over indexed vocabulary terms for ranked search. .. py:attribute:: terms :type: tuple[IndexedTerm, Ellipsis] .. py:attribute:: terms_by_uri :type: collections.abc.Mapping[str, IndexedTerm] .. py:method:: build(context: rdflib_reasoning.middleware.vocabulary_configuration.VocabularyContext) -> Self :classmethod: Index every term from ``context`` indexed vocabularies. .. py:method:: search(query: str, *, vocabularies: tuple[str, Ellipsis] = (), term_types: tuple[rdflib_reasoning.middleware.namespaces.common.VocabularyTermType, Ellipsis] = (), limit: int = 8) -> middleware.vocabulary.search_model.TermSearchResponse Rank indexed terms against ``query`` and return the top ``limit`` hits.