Skip to content

Commit

Permalink
Add tests for wrong stem results
Browse files Browse the repository at this point in the history
as inspired from issue thread har07/PySastrawi#4

Failing tests are commented.
  • Loading branch information
lahdjirayhan committed Aug 28, 2022
1 parent d63e78a commit 04f672d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/stemmer/test_stemmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@ def test_stem_word(self):
self.assertEqual(self.stemmer.stem_word('dilipatgandakan'), 'lipat ganda')
self.assertEqual(self.stemmer.stem_word('pertanggungjawaban'), 'tanggung jawab')

# Failing tests are commented out for now
self.assertEqual(self.stemmer.stem_word('dikuranginya'), 'kurang')
self.assertEqual(self.stemmer.stem_word('menyinari'), 'sinar')
# self.assertEqual(self.stemmer.stem_word('dibelinya'), 'beli')
# self.assertEqual(self.stemmer.stem_word('gerakan'), 'gerak')
# self.assertEqual(self.stemmer.stem_word('menangis'), 'tangis')
# self.assertEqual(self.stemmer.stem_word('perangi'), 'perang')
# self.assertEqual(self.stemmer.stem_word('aktivis'), 'aktif')


def test_stem_sentences(self):
self.assertEqual(
self.stemmer.stem('maka dokumen tersebut ditandatangani olehnya'),
self.stemmer.stem('maka dokumen tersebut ditandatangani olehnya'),
'maka dokumen sebut tanda tangan oleh'
)
self.assertEqual(
self.stemmer.stem('tiba-tiba disebarluaskanlah rahasia itu'),
'tiba sebar luas rahasia itu'
)

def test_add_words(self):
# Make sure word kasaha not exists in dictionary
self.assertNotIn('kasaha', self.stemmer.dictionary)

# Add one word
self.stemmer.add_words('kasaha')
self.assertIn('kasaha', self.stemmer.dictionary)
Expand All @@ -41,7 +51,7 @@ def test_add_words(self):
self.stemmer.add_words('kunaon', 'kumaha')
self.assertIn('kunaon', self.stemmer.dictionary)
self.assertIn('kumaha', self.stemmer.dictionary)

def test_remove_words(self):
# Make sure word kasaha not exists in dictionary
self.assertIn('ikan', self.stemmer.dictionary)
Expand Down

0 comments on commit 04f672d

Please sign in to comment.