search spell checking

This commit is contained in:
2023-01-14 01:09:47 -08:00
parent 1bb03004b6
commit 8c8cc7b6b5
4 changed files with 12827 additions and 3 deletions
+2 -1
View File
@@ -4,7 +4,8 @@ Tested with Dependancy:Version
python3:3.10.6-1~22.04 python3:3.10.6-1~22.04
python3-flask:2.0.1-2ubuntu1 python3-flask:2.0.1-2ubuntu1
sqlite3:3.37.2-2ubuntu0.1 sqlite3:3.37.2-2ubuntu0.1
bible-kjv:4.37 libhunspell-dev:1.7.0-4build1
python3-hunspell:0.5.5-2build6
uwsgi-core:2.0.20-4 uwsgi-core:2.0.20-4
uwsgi-plugin-python3:2.0.20-4 uwsgi-plugin-python3:2.0.20-4
apache2:2.4.52-1ubuntu4.2 apache2:2.4.52-1ubuntu4.2
+9 -2
View File
@@ -5,6 +5,7 @@ from datetime import date # used for daily verse
import sqlite3 import sqlite3
import string # for literals import string # for literals
import json # for dictionary import json # for dictionary
import hunspell # for spell checking
DEBUG = 0 DEBUG = 0
""" """
@@ -164,8 +165,9 @@ def define():
dictionary = json.load(data) dictionary = json.load(data)
ref = ref.lower() ref = ref.lower()
if not ref in dictionary.keys(): 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) arg_view = request.args.get("view", None)
if arg_view == "plain": if arg_view == "plain":
response = return_dict_plain(ref, dictionary[ref]) response = return_dict_plain(ref, dictionary[ref])
@@ -363,8 +365,13 @@ def search():
return send_file("html/search.html") return send_file("html/search.html")
results = lookup_fts(cleaned_keywords) 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) response_list = response_multi(results)
arg_view = request.args.get("view", None) arg_view = request.args.get("view", None)
if arg_view == "plain" or arg_view == "rich": if arg_view == "plain" or arg_view == "rich":
response = "<br>".join(response_list) response = "<br>".join(response_list)
+109
View File
@@ -0,0 +1,109 @@
SET UTF-8
TRY esiaénrtolcdugmfphbyvkw-'.zqjxSNRTLCGDMFPHBEAUYOIVKWóöâôZQJXÅçèîêàïüäñ
ICONV 1
ICONV '
NOSUGGEST !
# ordinal numbers
COMPOUNDMIN 1
# only in compounds: 1th, 2th, 3th
ONLYINCOMPOUND c
# compound rules:
# 1. [0-9]*1[0-9]th (10th, 11th, 12th, 56714th, etc.)
# 2. [0-9]*[02-9](1st|2nd|3rd|[4-9]th) (21st, 22nd, 123rd, 1234th, etc.)
COMPOUNDRULE 2
COMPOUNDRULE n*1t
COMPOUNDRULE n*mp
WORDCHARS 0123456789
REP 90
REP a ei
REP ei a
REP a ey
REP ey a
REP ai ie
REP ie ai
REP alot a_lot
REP are air
REP are ear
REP are eir
REP air are
REP air ere
REP ere air
REP ere ear
REP ere eir
REP ear are
REP ear air
REP ear ere
REP eir are
REP eir ere
REP ch te
REP te ch
REP ch ti
REP ti ch
REP ch tu
REP tu ch
REP ch s
REP s ch
REP ch k
REP k ch
REP f ph
REP ph f
REP gh f
REP f gh
REP i igh
REP igh i
REP i uy
REP uy i
REP i ee
REP ee i
REP j di
REP di j
REP j gg
REP gg j
REP j ge
REP ge j
REP s ti
REP ti s
REP s ci
REP ci s
REP k cc
REP cc k
REP k qu
REP qu k
REP kw qu
REP o eau
REP eau o
REP o ew
REP ew o
REP oo ew
REP ew oo
REP ew ui
REP ui ew
REP oo ui
REP ui oo
REP ew u
REP u ew
REP oo u
REP u oo
REP u oe
REP oe u
REP u ieu
REP ieu u
REP ue ew
REP ew ue
REP uff ough
REP oo ieu
REP ieu oo
REP ier ear
REP ear ier
REP ear air
REP air ear
REP w qu
REP qu w
REP z ss
REP ss z
REP shun tion
REP shun sion
REP shun cion
REP size cise
+12707
View File
File diff suppressed because it is too large Load Diff