search spell checking
This commit is contained in:
@@ -5,6 +5,7 @@ from datetime import date # used for daily verse
|
||||
import sqlite3
|
||||
import string # for literals
|
||||
import json # for dictionary
|
||||
import hunspell # for spell checking
|
||||
DEBUG = 0
|
||||
|
||||
"""
|
||||
@@ -164,8 +165,9 @@ def define():
|
||||
dictionary = json.load(data)
|
||||
ref = ref.lower()
|
||||
if not ref in dictionary.keys():
|
||||
return "{} not found".format(ref)
|
||||
|
||||
h = hunspell.HunSpell("kjv.dic","kjv.aff")
|
||||
suggestions = h.suggest(ref)
|
||||
return "{} not found, try one of the following: {}".format(ref, ', '.join(suggestions))
|
||||
arg_view = request.args.get("view", None)
|
||||
if arg_view == "plain":
|
||||
response = return_dict_plain(ref, dictionary[ref])
|
||||
@@ -363,8 +365,13 @@ def search():
|
||||
return send_file("html/search.html")
|
||||
|
||||
results = lookup_fts(cleaned_keywords)
|
||||
if not results:
|
||||
h = hunspell.HunSpell("kjv.dic","kjv.aff")
|
||||
suggestions = h.suggest(cleaned_keywords)
|
||||
return "{} not found, try one of the following: {}".format(cleaned_keywords, ', '.join(suggestions))
|
||||
response_list = response_multi(results)
|
||||
|
||||
|
||||
arg_view = request.args.get("view", None)
|
||||
if arg_view == "plain" or arg_view == "rich":
|
||||
response = "<br>".join(response_list)
|
||||
|
||||
Reference in New Issue
Block a user