Skip to content

Commit

Permalink
Adapt widgets and test to corpus refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Jan 12, 2022
1 parent 9207553 commit d60fbcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions orangecontrib/text/widgets/owscoredocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ def _preprocess_words(
# cases like this think about implementation of preprocessors for a list
# of strings
words_feature = StringVariable("words")
words_c = Corpus(
words_c = Corpus.from_numpy(
Domain([], metas=[words_feature]),
np.empty((len(words), 0)),
metas=np.array([[w] for w in words]),
text_features=[words_feature],
)
Expand Down Expand Up @@ -570,7 +571,7 @@ def _send_output(self) -> None:
metas=d.metas + tuple(ContinuousVariable(get_unique_names(d, l))
for l in labels),
)
out_corpus = Corpus(
out_corpus = Corpus.from_numpy(
domain,
self.corpus.X,
self.corpus.Y,
Expand Down
5 changes: 3 additions & 2 deletions orangecontrib/text/widgets/tests/test_owscoredocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def embedding_mock(_, corpus, __):
return np.ones((len(corpus), 10))
else: # corpus is Corpus
return (
Corpus(
Corpus.from_numpy(
domain=Domain([ContinuousVariable(str(i)) for i in range(10)]),
X=np.ones((len(corpus), 10)),
),
Expand Down Expand Up @@ -168,8 +168,9 @@ def create_corpus(texts: List[str]) -> Corpus:
"""Create sample corpus with texts passed"""
text_var = StringVariable("Text")
domain = Domain([], metas=[text_var])
c = Corpus(
c = Corpus.from_numpy(
domain,
X=np.empty((len(texts), 0)),
metas=np.array(texts).reshape(-1, 1),
text_features=[text_var],
)
Expand Down

0 comments on commit d60fbcb

Please sign in to comment.