i'm looking for an existing module(s) which enabled me to write basic boolean queries for matching and searching texts, WITHOUT writing my own parser etc.
for example,
president AND (ronald OR (george NOT bush))
would match TRUE against "the president ronald ragen" "the president ronald ragen and bush" "max bush was not a president"
but False on "george bush was a president" "i don't know how to spell ronald ragen"
(So far i found Booleano, which seems a bit overkill, but could do the task. However their group is inactive, and i couldn't figure out from the documentation what to do.)
thanks
Edit: the exact style or grammer is not critical. my aim is to provide non-tech users with the ability to search certain texts a bit beyond keyword search.
DISCLAIMER: I am the creator of the package presented below.
For the people who might come to this page: I built a package to do just that (still in beta).
pip install eldar
Your query would be translated in the following code:
from eldar import Query
eldar = Query('"president" AND ("ronald" OR ("george" AND NOT "bush"))')
print(eldar("President Bush"))
# >>> False
print(eldar("President George"))
# >>> True
You can use it on some pandas dataframe as well, check the git page for more info: https://github.com/kerighan/eldar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With