forked from Pastafarians/linguine-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremove_caps_test.py
36 lines (28 loc) · 1.61 KB
/
remove_caps_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
from linguine.corpus import Corpus
from linguine.ops.remove_caps import RemoveCapsGreedy, RemoveCapsPreserveNNP
class RemoveCapsTest(unittest.TestCase):
def setUp(self):
self.op = RemoveCapsGreedy()
def test_run_greedy(self):
self.op = RemoveCapsGreedy()
test_data = [Corpus("0", "",
"Removes all non-proper-noun capitals from a given text. Removes capital letters from text, even for Bill Clinton. Accepts as input a non-tokenized string.")]
desired_results = {
"0": "removes all non-proper-noun capitals from a given text. removes capital letters from text, even for bill clinton. accepts as input a non-tokenized string."}
results = self.op.run(test_data)
self.assertIsNotNone(results)
for corpus in results:
self.assertEqual(corpus.contents, desired_results[corpus.id])
def test_run_preserve_nnp(self):
self.op = RemoveCapsPreserveNNP()
test_data = [Corpus("0", "",
"Removes all non-proper-noun capitals from a given text. Removes capital letters from text, even for Bill Clinton. Accepts as input a non-tokenized string.")]
desired_results = {
"0": "removes all non-proper-noun capitals from a given text. removes capital letters from text, even for Bill Clinton. accepts as input a non-tokenized string."}
results = self.op.run(test_data)
self.assertIsNotNone(results)
for corpus in results:
self.assertEqual(corpus.contents, desired_results[corpus.id])
if __name__ == '__main__':
unittest.main()