Create new wordlist logic and speed up builds

This commit is contained in:
Austen Adler 2023-02-17 01:06:19 +00:00
parent f70d8524bb
commit 97f2cc5d05
8 changed files with 15944 additions and 11230 deletions

View File

@ -5,7 +5,7 @@ edition = "2021"
[workspace]
members = [
".",
# ".",
"./words",
"./this_algorithm",
]

File diff suppressed because it is too large Load Diff

Binary file not shown.

2642
docs/wordlist-new.ipynb Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,9 @@ fn test_v0() {
t("\t\tgrape\n\t orange apple 1000 \t ");
t("\n1000 APPlE oRAnGE GrAPe\n");
ll(37.55512, -76.89212);
for i in 0..100 {
ll(37.55512 + f64::from(i) * 0.00001, -76.89212);
}
assert!(false);
}
fn ll(lat: f64, lon: f64) {

View File

@ -59,7 +59,7 @@ fn write_word_map(mut file: impl Write, words: &[Word]) {
writeln!(
&mut file,
r#"/// Mapping from all caps `&str` to `&'static Word`
pub static WORD_MAP: phf::Map<&'static str, &'static Word> = {};"#,
pub static WORD_MAP: phf::Map<&'static str, &'static Word> = {};"#,
word_map.build()
)
.unwrap();
@ -75,7 +75,8 @@ fn write_number_to_words(mut file: impl Write, words: &[Word]) {
writeln!(
&mut file,
// "pub static NUMBER_TO_WORDS: &[&[usize]] = &["
"pub static NUMBER_TO_WORDS: &[&[&'static Word]] = &["
r#"/// Mapping from each number to its associated word
pub static NUMBER_TO_WORDS: &[&[&'static Word]] = &["#
)
.unwrap();
@ -89,7 +90,7 @@ fn write_number_to_words(mut file: impl Write, words: &[Word]) {
// write!(&mut file, "{idx},").unwrap();
write!(&mut file, "&WORDS[{idx}],").unwrap();
}
writeln!(&mut file, "],").unwrap();
writeln!(&mut file, "], /* {} */", entry[0].0).unwrap();
}
writeln!(&mut file, "];\n").unwrap();
}

View File

@ -58,6 +58,15 @@ where
mod tests {
use super::*;
#[test]
fn test_length() {
assert!(WORDS.len() > 8195);
for i in 0..8195_u16 {
assert_eq!(NUMBER_TO_WORDS[i as usize][0].number, i);
}
}
#[test]
fn test_equivalence() {
// Test equivalence
@ -78,6 +87,8 @@ mod tests {
// Homonyms
te!(blue, blew);
te!(yellow, hello);
te!(days, daze);
te!(day, days);
// Plurals
te!(sent, sense);