mopac-library / src /search_engine /search_engine_functions.py
denovoref
Add binary files from src/search_engine/index
efeacc7
raw
history blame contribute delete
592 Bytes
from whoosh import index
from whoosh.qparser import MultifieldParser
from whoosh import qparser
acronym_regex = r"([A-Z][\w,β€™β€˜']+(?:(?:\s|&|and|or|the|of|to|in|on|at|for|an|-)+[A-Z][\w,β€™β€˜']+){1,})\s\(([A-Za-z\s]+)\)"
def search(query,index_dir):
ix = index.open_dir(index_dir)
mparser = MultifieldParser(["title", "content","date","acronyms"], schema=ix.schema,group=qparser.OrGroup)
q = mparser.parse(query)
s = ix.searcher()
print(q)
results = s.search(q, limit=10)
for r in results:
print(r['title'],r['file_name'])
return(list(results))