omop.preprocess

source

preprocess_search_term

def preprocess_search_term(
	term: str
)

Preprocess a search term for use in a full-text search query.

This function performs the following operations:

  1. Converts the input term to lowercase.
  2. Splits the term into individual words.
  3. Removes common stop words.
  4. Joins the remaining words with ’ | ’ for use in PostgreSQL’s to_tsquery function.

Parameters

term: str The original search term.

Returns

str A preprocessed string ready for use in a full-text search query.