mirror of
https://github.com/Team-Neptune/TeamNeptuneFAQBot.git
synced 2024-11-23 04:39:41 +00:00
Create test.py
Add search term testing
This commit is contained in:
parent
d647f655fa
commit
9ec2423210
27
test.py
Normal file
27
test.py
Normal 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))
|
Loading…
Reference in New Issue
Block a user