Autocomplete APIΒΆ

async autocomplete_api.autocomplete(question: str, language: str = None, tag: str = None, k: int = 15, db: Session = fastapi.Depends)ΒΆ

If the user input ends with a β€œ?” character, return a set of questions that may be relevant to the user. If there are at lest 5 results from fuzzy matching, they are returned. Otherwise, results of semantic similarity matching are returned alongside the fuzzy matching results.

Parameters:
  • question (str) – User input to match database entries

  • language (str, optional) – Question and results language

  • tag (str, optional) – Tag of the documents to search

  • k (int, optional) – Number of results to return

  • db (Session) – Database session

Return type:

list of dict

autocomplete_api.exact_match(question: str, language: str = None, tag: str = None, k: int = 10, db: Session = fastapi.Depends)ΒΆ

Return results from Exact matching

Parameters:
  • question (str) – User input to match database entries

  • language (str, optional) – Question and results language

  • tag (str, optional) – Tag of the documents to search

  • k (int, optional) – Number of results to return

  • db (Session) – Database session

Return type:

list of dict

autocomplete_api.fuzzy_match(question: str, language: str = None, tag: str = None, k: int = 10, threshold=50, db: Session = fastapi.Depends)ΒΆ

Return results from Fuzzy matching, using Levenshtein distance

Parameters:
  • question (str) – User input to match database entries

  • language (str, optional) – Question and results language

  • tag (str, optional) – Tag of the documents to search

  • k (int, optional) – Number of results to return

  • threshold (int, optional) – Levenshtein threshold

  • db (Session) – Database session

Return type:

list of dict

autocomplete_api.trigram_match(question: str, language: str = None, tag: str = None, k: int = 10, threshold: float = 0.4, db: Session = fastapi.Depends)ΒΆ

Return results from Trigram matching

Parameters:
  • question (str) – User input to match database entries

  • language (str, optional) – Question and results language

  • tag (str, optional) – Tag of the documents to search

  • k (int, optional) – Number of results to return

  • threshold (float, optional) – Trigram threshold, between 0 and 1

  • db (Session) – Database session

Return type:

list of dict

autocomplete_api.semantic_similarity_match(question: str, language: str = None, tag: str = None, k: int = 10, db: Session = fastapi.Depends)ΒΆ

Return results from Semantic Similarity matching

Parameters:
  • question (str) – User input to match database entries

  • language (str, optional) – Question and results language

  • tag (str, optional) – Tag of the documents to search

  • k (int, optional) – Number of results to return

  • db (Session) – Database session

Return type:

list of dict