Skip to content
Snippets Groups Projects
Commit 5dff74fd authored by Benjamin Murauer's avatar Benjamin Murauer
Browse files

fixed mypy issues

parent b55aa19a
No related branches found
No related tags found
No related merge requests found
...@@ -63,14 +63,16 @@ class SubFrequencyVectorizer(BaseEstimator, TransformerMixin): ...@@ -63,14 +63,16 @@ class SubFrequencyVectorizer(BaseEstimator, TransformerMixin):
def transform(self, X: Iterable[str], _y: Any = None) -> np.ndarray: def transform(self, X: Iterable[str], _y: Any = None) -> np.ndarray:
"""Transform data due to previously learned frequencies.""" """Transform data due to previously learned frequencies."""
result: List[int] = [] result: List[np.ndarray] = []
for k in X: for k in X:
document_sum = 0 document_sum: np.ndarray = np.array([])
doc_words = k.split() doc_words = k.split()
for j in doc_words: for j in doc_words:
if j not in self.t: if j not in self.t:
continue continue
if document_sum.shape[0] == 0:
document_sum = np.zeros(self.t[j].shape)
tf = doc_words.count(j) tf = doc_words.count(j)
document_sum += int(self.t[j] * tf / len(doc_words)) document_sum += self.t[j] * tf / len(doc_words)
result.append(document_sum) result.append(document_sum)
return np.array(result) return np.array(result)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment