Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Preprocess: Retain corpus ids #553

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions orangecontrib/text/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def __call__(self, corpus: Corpus) -> Corpus:
:return: Corpus
Preprocessed corpus.
"""
ids = corpus.ids
corpus = corpus.copy()
corpus.ids = ids
corpus.used_preprocessor = self
return corpus

Expand Down
6 changes: 6 additions & 0 deletions orangecontrib/text/tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def test_inplace(self):
corpus = p(self.corpus)
self.assertIsNot(corpus, self.corpus)

def test_retain_ids(self):
corpus = self.corpus
for pp in self.pp_list:
corpus = pp(corpus)
self.assertTrue((corpus.ids == self.corpus.ids).all())


class TransformationTests(unittest.TestCase):
def setUp(self):
Expand Down