I have some example:
Example : Query = "we present"
Result:
0 By encoding the rich knowledge that is present in text, these representations are able to capture many aspects of word meaning.
1 In this paper, we present a dependency graph-tostring grammar based on a graph grammar, which we call edge replacement grammar.
2 We present a sentence rewriting method that generates more monotonic translations to improve the speedaccuracy tradeoff.
I want display 2th sentence - "we present .....tradeoff" is first. And I'd ask : Why I search phrase "we present" but the result showed two sentence not consist of phrase "we present". This is my code :
def search_Document(fileIndex, Query):
# phrase_query = '"'+Query.lower()+'"'
phrase_query = Query
ix = index.open_dir(fileIndex)
with ix.searcher(weighting=scoring.Frequency()) as searcher:
# qp = QueryParser("sentence_analyse", schema=ix.schema)
pharse_qp = MultifieldParser(["sentence", "title"], schema=ix.schema)
phrase_q = pharse_qp.parse(phrase_query)
q = pharse_qp.parse(Query)
results = searcher.search(phrase_q,sortedby='rank',limit=30)
for i,result in enumerate(results):
print(i,result['sentence'])
if __name__ == '__main__':
search_Document('IndexDirectory','"we present"')