-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
# List of dictionaries to use | ||
dictionaries = ["en_US", "tech_terms"] | ||
|
||
# Custom allowed words | ||
words = ["codebook", "allowlist", "aff", "dic", "blopker", "spellbook"] | ||
|
||
# Words to always flag | ||
flag_words = ["todo", "fixme"] | ||
|
||
# Paths to ignore (glob patterns) | ||
ignore_paths = ["target/**/*", "**/*.json", ".git/**/*"] | ||
dictionaries = [ | ||
"en_us", | ||
"tech_terms", | ||
] | ||
words = [ | ||
"aff", | ||
"allowlist", | ||
"blopker", | ||
"codebook", | ||
"declarator", | ||
"dic", | ||
"spellbook", | ||
] | ||
flag_words = [ | ||
"todo", | ||
"fixme", | ||
] | ||
ignore_paths = [ | ||
"target/**/*", | ||
"**/*.json", | ||
".git/**/*", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use std::sync::LazyLock; | ||
|
||
static CODEBOOK_DICTIONARY: &str = include_str!("../../word_lists/combined.gen.txt"); | ||
|
||
#[derive(Clone, Debug)] | ||
struct HunspellDictionaryLocation { | ||
pub aff_url: String, | ||
pub dict_url: String, | ||
pub name: String, | ||
} | ||
|
||
impl HunspellDictionaryLocation { | ||
pub fn new(name: &str, aff_url: &str, dict_url: &str) -> Self { | ||
Self { | ||
aff_url: aff_url.to_string(), | ||
dict_url: dict_url.to_string(), | ||
name: name.to_string(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
struct TextDictionaryLocation { | ||
pub url: String, | ||
pub name: String, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
enum DictionaryLocation { | ||
Hunspell(HunspellDictionaryLocation), | ||
Text(TextDictionaryLocation), | ||
} | ||
|
||
static NATRUAL_DICTIONARIES: LazyLock<Vec<DictionaryLocation>> = LazyLock::new(|| { | ||
vec![DictionaryLocation::Hunspell( | ||
HunspellDictionaryLocation::new( | ||
"en_us", | ||
"https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/refs/heads/main/dictionaries/en_US/src/hunspell/en_US-large.aff", | ||
"https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/refs/heads/main/dictionaries/en_US/src/hunspell/en_US-large.dic", | ||
)), | ||
DictionaryLocation::Hunspell( | ||
HunspellDictionaryLocation::new( | ||
"en_gb", | ||
"https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/refs/heads/main/dictionaries/en_GB/src/hunspell/en_GB-large.aff", | ||
"https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/refs/heads/main/dictionaries/en_GB/src/hunspell/en_GB-large.dic", | ||
)), | ||
] | ||
}); | ||
|
||
pub fn get_codebook_dictionary() -> impl Iterator<Item = &'static str> { | ||
CODEBOOK_DICTIONARY.lines().filter(|l| !l.contains('#')) | ||
} | ||
|
||
pub fn get_natural_dictionary(name: &str) -> Option<DictionaryLocation> { | ||
let res = NATRUAL_DICTIONARIES.iter().find(|d| match d { | ||
DictionaryLocation::Hunspell(h) => h.name == name, | ||
_ => false, | ||
}); | ||
|
||
match res { | ||
Some(d) => Some(d.clone()), | ||
None => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod dictionary; | ||
mod dictionary_repo; | ||
pub mod downloader; | ||
mod log; | ||
mod queries; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters