Updated wordlist and made related changes in code

This commit is contained in:
Sayantan Santra 2022-06-07 17:30:29 -05:00
parent 6192c22c19
commit ade3107107
4 changed files with 740218 additions and 4 deletions

View file

@ -3,3 +3,7 @@
I'm learning Rust, so this is just a rewrite of an simple old project in Rust.
[Link to old project.](https://github.com/SinTan1729/Unscrambler)
### Note
The main wordlist was pulled from [words_alpha.txt by dwyl](https://github.com/dwyl/english-words/) and processed using Rust. Processing code was really simple, so didn't put it up here.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -4,6 +4,8 @@ fn main() {
// read the dictionary files
let wordlist = include_str!("data/wordlist.txt");
let wordlist_sorted = include_str!("data/wordlist_sorted.txt");
let wordlist = &[" ", &wordlist.replace("\n", " ")[..]].join("")[..];
let wordlist_sorted = &[" ", &wordlist_sorted.replace("\n", " ")[..]].join("")[..];
// get into a loop so that we can run it multiple times
loop {
@ -41,7 +43,7 @@ fn main() {
for index in indices {
println!(
"{}",
sentence_case(&wordlist[index + 1..index + input.len() - 1])
sentence_case(&wordlist[index + 1..index - 1 + input.len()])
);
}
}
@ -62,6 +64,6 @@ fn sentence_case(s: &str) -> String {
let mut c = s.chars();
match c.next() {
None => String::new(),
Some(f) => f.to_uppercase().collect::<String>() + &c.as_str()[..].to_lowercase(),
Some(f) => f.to_uppercase().collect::<String>() + c.as_str(),
}
}