Skip to content

Commit

Permalink
Test BOM removal in custom stopwords
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdapretnar committed Jul 10, 2024
1 parent d9b12b6 commit 52cb0e4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions orangecontrib/text/tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,24 @@ def test_lang_to_iso(self):
self.assertEqual("en", StopwordsFilter.lang_to_iso("English"))
self.assertEqual("sl", StopwordsFilter.lang_to_iso("Slovene"))

def test_custom_list(self):
f = tempfile.NamedTemporaryFile("w", delete=False,
encoding='utf-8-sig')
# test if BOM removed
f.write('human\n')
f.write('user\n')
f.flush()
f.close()
stopwords = preprocess.StopwordsFilter(None, f.name)
self.assertIn('human', stopwords._lexicon)
self.assertIn('user', stopwords._lexicon)
with self.corpus.unlocked():
self.corpus.metas[0, 0] = 'human user baz'
processed = stopwords(self.corpus)
self.assertEqual(["baz"], processed.tokens[0])
f.close()
os.unlink(f.name)

def test_lexicon(self):
f = tempfile.NamedTemporaryFile(delete=False)
f.write(b'filter\n')
Expand Down

0 comments on commit 52cb0e4

Please sign in to comment.