Praison AI
Bot
Use Cases
University
Docs
Get Started
Say when it is not there
Run
from praisonai import KeywordIndex lines = [ "Apples grow on trees in the orchard.", "The secret colour of the boat is blue.", "Tickets for the ferry cost four pounds.", ] index = KeywordIndex() index.add_documents(lines) question = "Who wrote the handbook?" words = [word.strip("?.!,").lower() for word in question.split() if len(word) > 3] hit = index.query(question, top_k=1)[0] if any(word in hit["text"].lower() for word in words): print(hit["text"]) else: print("Not in the note.")
Press Run. The result appears here.