File tree Expand file tree Collapse file tree 6 files changed +196
-12
lines changed
data/Stemmers/GreekStemmerTest Expand file tree Collapse file tree 6 files changed +196
-12
lines changed Original file line number Diff line number Diff line change 8
8
* http://people.dsv.su.se/~hercules/papers/Ntais_greek_stemmer_thesis_final.pdf
9
9
*
10
10
* It was first ported to php by P. Kyriakakis.
11
+ * This stemmer expects lower case characters and not upper case.
11
12
*/
12
13
class GreekStemmer extends Stemmer
13
14
{
Original file line number Diff line number Diff line change 2
2
3
3
namespace NlpTools \Stemmers ;
4
4
5
- class GreekStemmerTest extends \PHPUnit_Framework_TestCase
5
+ class GreekStemmerTest extends StemmerTestBase
6
6
{
7
7
/**
8
8
* Test the words found in Appendix A from Mr. Ntais's thesis.
9
+ *
10
+ * The words are not tested against the stem reported in the appendix
11
+ * but against the results of Mr. Ntais's canonical implementation in js
12
+ * found here http://people.dsv.su.se/~hercules/greek_stemmer.gr.html
9
13
*/
10
14
public function testFromAppendixA ()
11
15
{
12
- $ this ->fail ("This test is not yet implemented " );
16
+ $ words = new \SplFileObject (TEST_DATA_DIR .'/Stemmers/GreekStemmerTest/appendix-a-words ' );
17
+ $ stems = new \SplFileObject (TEST_DATA_DIR .'/Stemmers/GreekStemmerTest/appendix-a-stems ' );
18
+ $ words ->setFlags (\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY );
19
+ $ stems ->setFlags (\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY );
20
+ $ stems ->rewind ();
21
+
22
+ $ stemmer = new GreekStemmer ();
23
+ $ this ->checkStemmer ($ stemmer , $ words , $ stems );
13
24
}
14
25
}
Original file line number Diff line number Diff line change 8
8
* words.txt and stems.txt are taken from
9
9
* http://tartarus.org/~martin/PorterStemmer/
10
10
*/
11
- class PorterStemmerTest extends \PHPUnit_Framework_TestCase
11
+ class PorterStemmerTest extends StemmerTestBase
12
12
{
13
13
/**
14
14
* Load a set of words and their stems and check if the stemmer
@@ -25,14 +25,6 @@ public function testStemmer()
25
25
$ stems ->rewind ();
26
26
27
27
$ stemmer = new PorterStemmer ();
28
- foreach ($ words as $ word ) {
29
- $ stem = $ stems ->current ();
30
- $ this ->assertEquals (
31
- $ stemmer ->stem ($ word ),
32
- $ stem ,
33
- "The stem for ' $ word' should be ' $ stem' not ' {$ stemmer ->stem ($ word )}' "
34
- );
35
- $ stems ->next ();
36
- }
28
+ $ this ->checkStemmer ($ stemmer , $ words , $ stems );
37
29
}
38
30
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace NlpTools \Stemmers ;
4
+
5
+ /**
6
+ * This class simply provides a bit of functioanlity to test
7
+ * a stemmer agains two lists of words and stems just to keep
8
+ * the test code a bit DRY
9
+ */
10
+ class StemmerTestBase extends \PHPUnit_Framework_TestCase
11
+ {
12
+ protected function checkStemmer (Stemmer $ stemmer , \Iterator $ words , \Iterator $ stems )
13
+ {
14
+ foreach ($ words as $ word ) {
15
+ $ stem = $ stems ->current ();
16
+ $ this ->assertEquals (
17
+ $ stemmer ->stem ($ word ),
18
+ $ stem ,
19
+ "The stem for ' $ word' should be ' $ stem' not ' {$ stemmer ->stem ($ word )}' "
20
+ );
21
+ $ stems ->next ();
22
+ }
23
+ }
24
+ }
Original file line number Diff line number Diff line change
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
+ μελλοντ
60
+ βορειοασιατικ
61
+ μελλοντ
62
+ βορειοασιατ
63
+ μελλ
64
+ βορειοασιατικ
65
+ μελλοντ
66
+ βορειοασιατ
67
+ μελλοντ
68
+ βορειοασιατικ
69
+ αρει
70
+ βορειοασιατ
71
+ αρει
72
+ υπομελ
73
+ αρει
74
+ υπομελ
75
+ αρει
76
+ υπομελ
77
+ αρει
78
+ υπομελ
Original file line number Diff line number Diff line change
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
+ μελλοντα
60
+ βορειοασιατικοι
61
+ μελλοντ
62
+ βορειοασιατικου
63
+ μελλοντασ
64
+ βορειοασιατικουσ
65
+ μελλοντεσ
66
+ βορειοασιατικο
67
+ μελλοντοσ
68
+ βορειοασιατικοσ
69
+ αρειε
70
+ βορειοασιατικων
71
+ αρειο
72
+ υπομελη
73
+ αρειοι
74
+ υπομελοσ
75
+ αρειοσ
76
+ υπομελουσ
77
+ αρειου
78
+ υπομελων
You can’t perform that action at this time.
0 commit comments