tribler.core.database.augmenter =============================== .. py:module:: tribler.core.database.augmenter Attributes ---------- .. autoapisummary:: tribler.core.database.augmenter.logger tribler.core.database.augmenter.LOG_LEVELS Classes ------- .. autoapisummary:: tribler.core.database.augmenter.AugmentedSearch Module Contents --------------- .. py:data:: logger .. py:data:: LOG_LEVELS logging {50: CRITICAL/FATAL, 40: ERROR, 30: WARNING/WARN, 20: INFO, 10: DEBUG, 0: NOTSET} SentencePieceTrainer { 3: FATAL, 2: ERROR, 1: WARNING, 0: INFO } .. py:class:: AugmentedSearch(config: tribler.tribler_config.TriblerConfigManager, notifier: tribler.core.notifier.Notifier, task_manager: ipv8.taskmanager.TaskManager) This class is responsible for "slow" search. It creates its own language, based on torrent titles, to augment user queries. .. py:attribute:: config .. py:attribute:: max_title_length :value: 4192 .. py:attribute:: title_window :type: list[str] :value: [] .. py:attribute:: initialized :value: False .. py:attribute:: write_completed :type: asyncio.Future[None] .. py:attribute:: task_manager .. py:attribute:: model_file .. py:attribute:: title_cache_file .. py:attribute:: processor :type: sentencepiece.SentencePieceProcessor .. py:method:: on_shutdown() -> None Quickly dump our cache onto the disk. .. py:method:: consume_torrent_metadata(metadata: dict) -> None We found a new torrent title. Put it in the cache and start learning when we have sufficient data. .. py:method:: write(trained_model: bytes) -> None SentencePiece really wants to write to disk and then load it again. We need to be sure that new input was actually written to disk before reading it, or we lose data. .. py:method:: study() -> None :async: Study our most recent torrent titles and add them to the top tokens that we have already found in the past. .. py:method:: needs_kickstart() -> bool Check if we could use a good seeding. .. py:method:: to_phrases(pieces: list[str]) -> list[list[str]] What we get from SentencePiece is pieces. What we want is the pieces that make up a word, i.e., a phrase. Note that each word is separated by "▁" and may span several list elements. .. py:method:: augment(search: str, limit: int = 1000, offset: int = 1) -> tuple[str, list[str]] Augment the original user search string and create an SQL-injection-safe SQL query and its parameters.