-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_grc_features.py
59 lines (48 loc) · 2.44 KB
/
test_grc_features.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# pylint: disable = missing-function-docstring, missing-class-docstring
'''Tests'''
import unittest
from functools import reduce
from greek_features import * # pylint: disable = wildcard-import, unused-wildcard-import
class TestGreekFeatures(unittest.TestCase):
def setUp(self):
pass
def test_freq_indefinite_pronoun_in_non_interrogative_sentence1(self):
file = 'test test. test test test? test test test; test test. test.'
result = freq_indefinite_pronoun_in_non_interrogative_sentence(text=file)
expected = 0
self.assertEqual(expected, result)
def test_freq_indefinite_pronoun_in_non_interrogative_sentence2(self):
file = 'τις τινός τινός, αβγ δεζ. ηθικλ τις μνξοπρσ; τινός. τω τι τυφχψω.'
result = freq_indefinite_pronoun_in_non_interrogative_sentence(text=file)
expected = 5 / 39
self.assertEqual(expected, result)
def test_freq_sentences_with_vocative_omega(self):
file = 'ὦ α βγδ ὦ εζθικλ. μνξ ὦ οπ, ρσὦ τυ; φχψω. ὦ.'
result = freq_sentences_with_vocative_omega(text=file)
expected = 3 / 4
self.assertEqual(expected, result)
def test_freq_sentence_with_relative_clause(self):
file = 'ὅς αφνιοςε ςοεφπκ. ὃ ςενςεο; ΝΕΣΟΝΦΕΙΝΟΣΙ ὧν. ὧν. νψςειοιοςνφψλε.'
result = freq_sentence_with_relative_clause(text=file)
expected = 4 / 5
self.assertEqual(expected, result)
def test_mean_sentence_length1(self):
file = 'ὅς αφνιοςε ςοεφπκ. ὃ ςενςεο; ΝΕΣΟΝΦΕΙΝΟΣΙ ὧν. ὧν. νψςειοιοςνφψλε.'
result = mean_sentence_length(text=file)
expected = (16 + 8 + 15 + 3 + 15) / 5
self.assertEqual(expected, result)
def test_variance_of_sentence_length1(self):
file = 'ὅς αφνιοςε ςοεφπκ. ὃ ςενςεο; ΝΕΣΟΝΦΕΙΝΟΣΙ ὧν. ὧν. νψςειοιοςνφψλε.'
result = variance_of_sentence_length(text=file)
vals = (16, 8, 15, 3, 15)
mean = sum(vals) / len(vals)
expected = reduce(lambda cur_sum, val: cur_sum + (val - mean) ** 2, vals, 0) / len(vals)
self.assertEqual(expected, result)
def test_freq_interrogatives1(self):
#Includes GREEK QUESTION MARK after ofiihwio;
file = 'a b ccccccc. aaafew aaedwp bbdinwe; bnoirenfiob; ads ofiihwio; freino. daieof; frinoe.'
result = freq_interrogatives(text=file)
expected = 4 / 7
self.assertEqual(expected, result)
if __name__ == '__main__':
unittest.main()