search.utils ============ .. py:module:: search.utils Attributes ---------- .. autoapisummary:: search.utils.HASHTAG search.utils.LANGUAGE_MAP Classes ------- .. autoapisummary:: search.utils.classproperty search.utils.LanguageDetector Functions --------- .. autoapisummary:: search.utils.language_from_locale search.utils.searchable_sqlalchemy_models search.utils.get_polymorphic_base search.utils.apply_searchable_polymorphic_filter search.utils.extract_hashtags Module Contents --------------- .. py:data:: HASHTAG .. py:data:: LANGUAGE_MAP .. py:function:: language_from_locale(locale: str | None) -> str .. py:function:: searchable_sqlalchemy_models[T](base: type[T]) -> collections.abc.Iterator[type[onegov.search.Searchable]] Searches through the given SQLAlchemy base and returns the classes of all SQLAlchemy models found which inherit from the :class:`onegov.search.mixins.Searchable` interface. .. py:function:: get_polymorphic_base(model: type[sqlalchemy.orm.DeclarativeBase | onegov.search.mixins.Searchable]) -> type[sqlalchemy.orm.DeclarativeBase | onegov.search.mixins.Searchable] Filter out models that are polymorphic subclasses of other models in order to save on queries. .. py:function:: apply_searchable_polymorphic_filter[T](query: sqlalchemy.orm.Query[T], model: Any, order_by_polymorphic_identity: bool = False) -> sqlalchemy.orm.Query[T] Given a query and the corresponding model add a filter that excludes any polymorphic variants, that are not searchable. .. py:function:: extract_hashtags(text: str) -> list[str] .. py:class:: classproperty[T_co](f: collections.abc.Callable[[type[Any]], T_co]) .. py:attribute:: f .. py:method:: __get__(obj: object | None, owner: type[object]) -> T_co .. py:class:: LanguageDetector(supported_languages: collections.abc.Sequence[str]) Detects languages with the help of lingua-language-detector. .. py:attribute:: supported_languages .. py:attribute:: detector .. py:method:: detect(text: str) -> str .. py:method:: probabilities(text: str) -> list[lingua.ConfidenceValue]