Skip to content

Commit

Permalink
Avoid using detect Language as much as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ManyTheFish committed Sep 19, 2024
1 parent 3214bcf commit c75c335
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion charabia/src/detection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ impl<'o, 'al> StrDetection<'o, 'al> {
let inner = self.inner;
self.language = match self.language.take() {
Some(lang) => Some(lang),
None => Self::detect_lang(inner, self.allow_list),
None => match self.allow_list {
Some([unique_language]) => Some(*unique_language),
None if Self::detect_script(inner) == Script::Latin => None,
_otherwise => Self::detect_lang(inner, self.allow_list),
},
};

self.language
Expand Down

0 comments on commit c75c335

Please sign in to comment.