Skip to content

Commit

Permalink
refactor: moving all language related files in languages folder
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTheFactory committed Jan 23, 2024
1 parent 7a08fc2 commit 9a48739
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ repos:
.*/stopwords.*\.txt|
tests/data/.*|
newspaper/languages.py|
newspaper/languages/.*|
newspaper/resources/.*
)$
additional_dependencies:
Expand Down
Empty file removed newspaper/language/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions newspaper/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def __init__(self, language="en"):
with open(stopwordsFile, "r", encoding="utf-8") as f:
self._cached_stop_words[language] = set(f.read().splitlines())

lang_module = Path(__file__).parent / "language" / f"{language}.py"
lang_module = Path(__file__).parent / "languages" / f"{language}.py"
if lang_module.exists():
import importlib

module = importlib.import_module(f"newspaper.language.{language}")
module = importlib.import_module(f"newspaper.languages.{language}")
if not hasattr(module, "tokenizer"):
raise ValueError(
f"Language module {lang_module} has no tokenizer function!"
Expand Down

0 comments on commit 9a48739

Please sign in to comment.