From 623b068cef73e94d7b936420bc641e95773261a6 Mon Sep 17 00:00:00 2001 From: Book-reader Date: Sat, 10 May 2025 01:55:53 +1200 Subject: [PATCH] add instructions --- asklyphe-frontend/src/spellcheck.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/asklyphe-frontend/src/spellcheck.rs b/asklyphe-frontend/src/spellcheck.rs index d4ea9bc..aa5b58d 100644 --- a/asklyphe-frontend/src/spellcheck.rs +++ b/asklyphe-frontend/src/spellcheck.rs @@ -3,9 +3,24 @@ use tracing::{debug, error}; use std::{cmp, mem}; use std::collections::BTreeMap; use std::sync::Mutex; -// TODO: cache distances of strings/substrings -// TODO: use binary search to find direct matches, and if that fails, calculate and cache the result in BTreeMap +// how to generate words.txt: +// clone https://github.com/en-wl/wordlist && cd wordlist +// ./scowl wl --deaccent > words0.txt +// filtered with this python script: +// ----------------------------------- +// with open("words0.txt", "r") as f: +// out = [] +// for line in f: +// line = line.lower() +// if not line in out: +// out.append(line) +// out.sort() +// with open("words.txt", "w") as out_file: +// for line in out: +// out_file.write(f'{line}') +// ------------------------------------ +// then use regex or similar to enclose every line in quotes and add comma, then add 'static KNOWN_WORDS: &[&str] = &[' to the start and '];' to the end include!("./words.txt"); // a cache of misspelled words and the closest match in the database