Skip to content

Commit

Permalink
Perform some refactoring in detector
Browse files Browse the repository at this point in the history
  • Loading branch information
pemistahl committed Jan 10, 2025
1 parent 00dedf3 commit b0a2403
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 269 deletions.
8 changes: 4 additions & 4 deletions lingua/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def object_hook(self, obj: Any) -> Any:
if isinstance(obj, dict) and "language" in obj and "ngrams" in obj:
language = Language[obj["language"]]
ngrams = self.object_hook(obj["ngrams"])
return _NgramModel(language, frozenset(ngrams))
return _NgramCountModel(language, frozenset(ngrams))
return obj


Expand All @@ -92,7 +92,7 @@ class _NgramProbabilityModel:


@dataclass
class _NgramModel:
class _NgramCountModel:
language: Language
ngrams: frozenset[str]

Expand All @@ -117,9 +117,9 @@ def _load_ngram_probability_model(
return None


def _load_ngram_model(
def _load_ngram_count_model(
language: Language, ngram_length: int, model_type: _NgramModelType
) -> Optional[_NgramModel]:
) -> Optional[_NgramCountModel]:
ngram_name = _get_ngram_name_by_length(ngram_length)
iso_code = language.iso_code_639_1.name.lower()
relative_file_path = (
Expand Down
Loading

0 comments on commit b0a2403

Please sign in to comment.