diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-05-10 19:52:47 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-05-11 11:44:14 +1000 |
| commit | 6c61612564b9a30f747207c43729c3e7e8cbf0d3 (patch) | |
| tree | 3f0f3b4cc35162e73542942ef30da3f1a0bf6276 /backend/data/genSpellfixNameData.py | |
| parent | 3d895370a608d4f51726b74e2560dcf5f4ec43a8 (diff) | |
Use prefix-search with ranking-by-length
Diffstat (limited to 'backend/data/genSpellfixNameData.py')
| -rwxr-xr-x | backend/data/genSpellfixNameData.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/backend/data/genSpellfixNameData.py b/backend/data/genSpellfixNameData.py deleted file mode 100755 index 9a3a7a1..0000000 --- a/backend/data/genSpellfixNameData.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python3 - -import sys -import sqlite3 - -usageInfo = f"usage: {sys.argv[0]}\n" -usageInfo += "Reads alt-names from a 'names' table in a database, and adds a spellfix \n" -usageInfo += "table 'spellfix_alt_names' usable for fuzzy-searching those names.\n" -if len(sys.argv) > 1: - print(usageInfo, file=sys.stderr) - sys.exit(1) - -dbFile = "data.db" - -# Connect to db, and load spellfix extension -dbCon = sqlite3.connect(dbFile) -dbCon.enable_load_extension(True) -dbCon.load_extension('./spellfix') -# Create spellfix table, and insert alt-names -spellfixCur = dbCon.cursor() -spellfixCur.execute("CREATE VIRTUAL TABLE spellfix_alt_names USING spellfix1") -namesCur = dbCon.cursor() -iterationNum = 0 -for row in namesCur.execute("SELECT DISTINCT alt_name FROM names"): - iterationNum += 1 - if iterationNum % 10000 == 0: - print("Loop {}: {}".format(iterationNum, row[0])) - # Insert alt-name - spellfixCur.execute("INSERT INTO spellfix_alt_names(word) VALUES (?)", (row[0],)) -# Close db -dbCon.commit() -dbCon.close() |
