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] [workspace]
members = [ members = [
".", # ".",
"./words", "./words",
"./this_algorithm", "./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("\t\tgrape\n\t orange apple 1000 \t ");
t("\n1000 APPlE oRAnGE GrAPe\n"); 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); assert!(false);
} }
fn ll(lat: f64, lon: f64) { fn ll(lat: f64, lon: f64) {

View File

@ -75,7 +75,8 @@ fn write_number_to_words(mut file: impl Write, words: &[Word]) {
writeln!( writeln!(
&mut file, &mut file,
// "pub static NUMBER_TO_WORDS: &[&[usize]] = &[" // "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(); .unwrap();
@ -89,7 +90,7 @@ fn write_number_to_words(mut file: impl Write, words: &[Word]) {
// write!(&mut file, "{idx},").unwrap(); // write!(&mut file, "{idx},").unwrap();
write!(&mut file, "&WORDS[{idx}],").unwrap(); write!(&mut file, "&WORDS[{idx}],").unwrap();
} }
writeln!(&mut file, "],").unwrap(); writeln!(&mut file, "], /* {} */", entry[0].0).unwrap();
} }
writeln!(&mut file, "];\n").unwrap(); writeln!(&mut file, "];\n").unwrap();
} }

View File

@ -58,6 +58,15 @@ where
mod tests { mod tests {
use super::*; 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] #[test]
fn test_equivalence() { fn test_equivalence() {
// Test equivalence // Test equivalence
@ -78,6 +87,8 @@ mod tests {
// Homonyms // Homonyms
te!(blue, blew); te!(blue, blew);
te!(yellow, hello); te!(yellow, hello);
te!(days, daze);
te!(day, days);
// Plurals // Plurals
te!(sent, sense); te!(sent, sense);