Create test.py

Add search term testing
This commit is contained in:
Daniel 2022-05-30 16:03:05 -07:00
parent d647f655fa
commit 9ec2423210
No known key found for this signature in database
GPG Key ID: 771601B78F6934C8

27
test.py Normal file
View File

@ -0,0 +1,27 @@
# Import Required
import json
from typing import List
# Load FAQs
faqFile = open("faq.json")
FAQs = json.load(faqFile)
# Check results
def autocomplete_faqs(searchTerm: str) -> List[str]:
searchTermElements = searchTerm.split()
results = []
for s in searchTermElements:
for q in FAQs:
if s.lower() in q.lower():
if q not in results:
results.append(q)
return results[:10]
# Term to search for
searchTerm = "mean"
# Search
searchResults = autocomplete_faqs(searchTerm)
# Print Results
print("Search Term: {}".format(searchTerm))
print("Results: {}".format(searchResults))