Skip to content

Commit

Permalink
Tests for Slovenian language support
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdapretnar committed Aug 2, 2018
1 parent 365cad8 commit 7d60f3b
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion orangecontrib/text/tests/test_sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class LiuHuTest(unittest.TestCase):
def setUp(self):
self.corpus = Corpus.from_file('deerwester')
self.method = Liu_Hu_Sentiment()
self.method = Liu_Hu_Sentiment('English')
self.new_cols = 1

def test_transform(self):
Expand Down Expand Up @@ -49,6 +49,39 @@ def test_empty_corpus(self):
len(self.corpus.domain) + self.new_cols)
self.assertEqual(len(sentiment), 0)

class Liu_Hu_Slovenian(unittest.TestCase):
def setUp(self):
self.corpus = Corpus.from_file('slo-opinion-corpus')
self.method = Liu_Hu_Sentiment('Slovenian')
self.new_cols = 1

def test_transform(self):
sentiment = self.method.transform(self.corpus)
self.assertIsInstance(sentiment, Corpus)
self.assertEqual(len(sentiment.domain),
len(self.corpus.domain) + self.new_cols)

def test_copy(self):
sentiment_t = self.method.transform(self.corpus, copy=True)
self.assertIsNot(self.corpus, sentiment_t)

sentiment_f = self.method.transform(self.corpus, copy=False)
self.assertIs(self.corpus, sentiment_f)

def test_compute_values(self):
sentiment = self.method.transform(self.corpus)
computed = Corpus.from_table(sentiment.domain, self.corpus)

self.assertEqual(sentiment.domain, computed.domain)
self.assertTrue((sentiment.X == computed.X).all())

def test_empty_corpus(self):
corpus = self.corpus[:0]
sentiment = self.method.transform(corpus)
self.assertEqual(len(sentiment.domain),
len(self.corpus.domain) + self.new_cols)
self.assertEqual(len(sentiment), 0)


class VaderTest(LiuHuTest):
def setUp(self):
Expand Down

0 comments on commit 7d60f3b

Please sign in to comment.