1
whooshライブラリを使用してスペルチェックを実行する方法。ドキュメントにあるコードをいくつか追加しました。それは言葉を訂正するものではありません。私のコードを見つけてください。whoosh pythonライブラリを使用してスペルチェックを行う方法
def main():
print " Hi"
schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT)
ix = create_in("/home/praveen/Downloads/who", schema)
writer = ix.writer()
writer.add_document(title=u"First document", path=u"/a", content=u"This is the first document we've added!")
writer.add_document(title=u"Second document", path=u"/b",content=u"The second one is even more interesting!")
writer.commit()
qstring = "frm indea wroking for campany"
qp = qparser.QueryParser("content", ix.schema)
q = qp.parse(qstring)
# Try correcting the query
with ix.searcher() as s:
corrected = s.correct_query(q,qstring)
print(corrected)
print(corrected.query)
if corrected.query != q:
print("Did you mean:", corrected.string)
if __name__ == "__main__":
main();
と私の出力は次のようになります。
Hi
Correction(And([Term('content', u'frm'), Term('content', u'indea'), Term('content', u'wroking'), Term('content', u'campany')]), 'frm indea wroking for campany')
(content:frm AND content:indea AND content:wroking AND content:campany)
私は "もしかして:" になっていないです修正文字列で。
私は事前に
感謝を教えてください、
明らかに 'corrected.query == q'です。 –
私のプログラムで何が変更される必要がありますか?私は文書からコードを取り出した。入力はqstringで、スペルチェックを受けなければなりません –