Python code to build search logic from scratch with Text and Query Operators

Viewed 24

I am working on a search engine using Python from scratch which checks if an expression is present or not in the given dataset. The input contains words, brackets and Operators like &(AND), !(NOT) and |(OR)

Examples: Valid -

  1. Quick & brown (fox | (tall & ox)) --> should search for "quick brown fox" or "quick brown tall ox"
  2. hot & (air | balloon) --> should search for "hot air" or "hot balloon"
  3. quick & brown & !fox & ox --> should search for "quick brown ox" and fox should not me part of the result string.

Not Valid -

  1. Very & Quick | brown & fox --> "|" is ambiguous and hence invalid.
0 Answers
Related