Skip to content

Commit ce666a0

Browse files
committed
Added input validation (string)
1 parent 1df70db commit ce666a0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

eld/languageDetector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, subset_file=''):
1515
super().__init__()
1616
languageData.load_ngrams(subset_file)
1717
self.__do_clean_text = False
18-
self.VERSION = '1.0.7' # Has to match pyproject.toml version
18+
self.VERSION = '1.0.8' # Has to match pyproject.toml version
1919

2020
def detect(self, text):
2121
"""
@@ -28,6 +28,8 @@ def detect(self, text):
2828
Returns:
2929
object LanguageResult: language (str or None), scores() (dict or None), is_reliable() (bool)
3030
"""
31+
if not isinstance(text, str):
32+
raise TypeError("Input 'text' must be a string.")
3133
if self.__do_clean_text:
3234
# Removes Urls, emails, alphanumerical & numbers
3335
text = get_clean_txt(text)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "eld"
7-
version = "1.0.7"
7+
version = "1.0.8"
88
# Update VERSION at languageDetector.py too
99
authors = ["Nito T.M."]
1010
description = "Fast and accurate natural language detection. Detector written in Python. Nito-ELD, ELD."

0 commit comments

Comments
 (0)