in src/smjsindustry/finance/nlp_score_type.py [0:0]
def __init__(self, score_name: str, word_list: List[str]):
"""Initializes an ``NLPScoreType`` instance."""
score_name = score_name.lower()
self._score_name = score_name
if score_name in NLPSCORE_NO_WORD_LIST:
if word_list is not None:
raise TypeError(
"NLPScoreType with score_name {} requires its word_list "
"argument to be None.".format(score_name)
)
else:
if not isinstance(word_list, list):
raise TypeError(
"NLPScoreType with score_name {} requires its word_list "
"argument to be a list.".format(score_name)
)
if score_name in NLPScoreType.DEFAULT_SCORE_TYPES:
if word_list and any(not isinstance(word, str) for word in word_list):
raise TypeError("word_list argument must contain only strings.")
else:
if not word_list:
raise ValueError(
"NLPScoreType with custom score_name {} requires its word_list "
"argument to be a non-empty list.".format(score_name)
)
if any(not isinstance(word, str) for word in word_list):
raise TypeError("word_list argument must contain only strings.")
self._word_list = word_list