kerighan / eldar

Boolean text search in Python
MIT License
44 stars 9 forks source link

Support for wildcards in queries #8

Closed misotrnka closed 3 years ago

misotrnka commented 3 years ago

I've added support for wildcard characters in queries. Essentially, you can use * in a query entry to match any number (including zero) of any alpha-numeric characters (and underscore, as this is implemented as \w regex group).

This is how it works:

from eldar import Query

# sample document and query with multiple wildcards:
document = "Gandalf is a fictional character in Tolkien's The Lord of the Rings"
eldar = Query('"g*dal*" AND "*kien"')

# call to see if the text matches the query:
print(eldar(document))
# >>> True

Also, I've refactored the package by splitting the code into smaller files, which I believe increases readability and maintainability.

This is a feature that we need at Gerulata Technologies. I'm not sure if you would like to include this in your project, but feel free to let me know :)

kerighan commented 3 years ago

Very nice addition to the library. I've run a few tests, everything seems to be working just fine. I'll include it in eldar==0.0.7. Thank you very much for your work.

misotrnka commented 3 years ago

Happy to hear that. Thank you for making this handy little package :)