Skip to content

Commit f394700

Browse files
new: only print the fasttext warning if verbose is set
1 parent 04372df commit f394700

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

WDoc/utils/misc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def language_detector(text: str) -> float:
4343
return ftlangdetect.detect(text.lower())["score"]
4444
assert isinstance(language_detector("This is a test"), float)
4545
except Exception as err:
46-
red(f"Couldn't import optional package 'ftlangdetect', trying to import langdetect (but it's much slower): '{err}'")
46+
if is_verbose:
47+
red(f"Couldn't import optional package 'ftlangdetect', trying to import langdetect (but it's much slower): '{err}'")
4748
if "ftlangdetect" in sys.modules:
4849
del sys.modules["ftlangdetect"]
4950

@@ -55,7 +56,8 @@ def language_detector(text: str) -> float:
5556
return langdetect.detect_langs(text.lower())[0].prob
5657
assert isinstance(language_detector("This is a test"), float)
5758
except Exception as err:
58-
red(f"Couldn't import optional package 'langdetect': '{err}'")
59+
if is_verbose:
60+
red(f"Couldn't import optional package 'langdetect' either: '{err}'")
5961
@optional_typecheck
6062
def language_detector(text: str) -> None:
6163
return None

0 commit comments

Comments
 (0)