-
Notifications
You must be signed in to change notification settings - Fork 10
/
stemmer_test.go
198 lines (192 loc) · 8.11 KB
/
stemmer_test.go
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package sastrawi
import "testing"
type testItem struct {
value string
expected string
}
func TestStemmer(t *testing.T) {
testItems := []testItem{
{value: "mei", expected: "mei"},
{value: "bui", expected: "bui"},
{value: "nilai", expected: "nilai"},
{value: "hancurlah", expected: "hancur"},
{value: "benarkah", expected: "benar"},
{value: "apatah", expected: "apa"},
{value: "siapapun", expected: "siapa"},
{value: "jubahku", expected: "jubah"},
{value: "bajumu", expected: "baju"},
{value: "celananya", expected: "celana"},
{value: "hantui", expected: "hantu"},
{value: "belikan", expected: "beli"},
{value: "jualan", expected: "jual"},
{value: "bukumukah", expected: "buku"},
{value: "miliknyalah", expected: "milik"},
{value: "kulitkupun", expected: "kulit"},
{value: "berikanku", expected: "beri"},
{value: "sakitimu", expected: "sakit"},
{value: "beriannya", expected: "beri"},
{value: "kasihilah", expected: "kasih"},
{value: "dibuang", expected: "buang"},
{value: "kesakitan", expected: "sakit"},
{value: "sesuap", expected: "suap"},
{value: "beradu", expected: "adu"},
{value: "berambut", expected: "rambut"},
{value: "bersuara", expected: "suara"},
{value: "berdaerah", expected: "daerah"},
{value: "belajar", expected: "ajar"},
{value: "bekerja", expected: "kerja"},
{value: "beternak", expected: "ternak"},
{value: "terasing", expected: "asing"},
{value: "teraup", expected: "raup"},
{value: "tergerak", expected: "gerak"},
{value: "terpuruk", expected: "puruk"},
{value: "teterbang", expected: "terbang"},
{value: "melipat", expected: "lipat"},
{value: "meringkas", expected: "ringkas"},
{value: "mewarnai", expected: "warna"},
{value: "meyakinkan", expected: "yakin"},
{value: "membangun", expected: "bangun"},
{value: "memfitnah", expected: "fitnah"},
{value: "memvonis", expected: "vonis"},
{value: "memperbaru", expected: "baru"},
{value: "mempelajar", expected: "ajar"},
{value: "meminum", expected: "minum"},
{value: "memukul", expected: "pukul"},
{value: "mencinta", expected: "cinta"},
{value: "mendua", expected: "dua"},
{value: "menjauh", expected: "jauh"},
{value: "menziarah", expected: "ziarah"},
{value: "menuklir", expected: "nuklir"},
{value: "menangkap", expected: "tangkap"},
{value: "menggila", expected: "gila"},
{value: "menghajar", expected: "hajar"},
{value: "mengqasar", expected: "qasar"},
{value: "mengudara", expected: "udara"},
{value: "mengupas", expected: "kupas"},
{value: "menyuarakan", expected: "suara"},
{value: "mempopulerkan", expected: "populer"},
{value: "pewarna", expected: "warna"},
{value: "peyoga", expected: "yoga"},
{value: "peradilan", expected: "adil"},
{value: "perumahan", expected: "rumah"},
{value: "permuka", expected: "muka"},
{value: "perdaerah", expected: "daerah"},
{value: "pembangun", expected: "bangun"},
{value: "pemfitnah", expected: "fitnah"},
{value: "pemvonis", expected: "vonis"},
{value: "peminum", expected: "minum"},
{value: "pemukul", expected: "pukul"},
{value: "pencinta", expected: "cinta"},
{value: "pendua", expected: "dua"},
{value: "penjauh", expected: "jauh"},
{value: "penziarah", expected: "ziarah"},
{value: "penuklir", expected: "nuklir"},
{value: "penangkap", expected: "tangkap"},
{value: "penggila", expected: "gila"},
{value: "penghajar", expected: "hajar"},
{value: "pengqasar", expected: "qasar"},
{value: "pengudara", expected: "udara"},
{value: "pengupas", expected: "kupas"},
{value: "penyuara", expected: "suara"},
{value: "pelajar", expected: "ajar"},
{value: "pelabuh", expected: "labuh"},
{value: "petarung", expected: "tarung"},
{value: "terpercaya", expected: "percaya"},
{value: "pekerja", expected: "kerja"},
{value: "peserta", expected: "serta"},
{value: "mempengaruhi", expected: "pengaruh"},
{value: "mengkritik", expected: "kritik"},
{value: "bersekolah", expected: "sekolah"},
{value: "bertahan", expected: "tahan"},
{value: "mencapai", expected: "capai"},
{value: "dimulai", expected: "mulai"},
{value: "petani", expected: "tani"},
{value: "terabai", expected: "abai"},
{value: "mensyaratkan", expected: "syarat"},
{value: "mensyukuri", expected: "syukur"},
{value: "mengebom", expected: "bom"},
{value: "mempromosikan", expected: "promosi"},
{value: "memproteksi", expected: "proteksi"},
{value: "memprediksi", expected: "prediksi"},
{value: "pengkajian", expected: "kaji"},
{value: "pengebom", expected: "bom"},
{value: "bersembunyi", expected: "sembunyi"},
{value: "bersembunyilah", expected: "sembunyi"},
{value: "pelanggan", expected: "langgan"},
{value: "pelaku", expected: "laku"},
{value: "pelangganmukah", expected: "langgan"},
{value: "pelakunyalah", expected: "laku"},
{value: "perbaikan", expected: "baik"},
{value: "kebaikannya", expected: "baik"},
{value: "bisikan", expected: "bisik"},
{value: "menerangi", expected: "terang"},
{value: "berimanlah", expected: "iman"},
{value: "memuaskan", expected: "puas"},
{value: "berpelanggan", expected: "langgan"},
{value: "bermakanan", expected: "makan"},
{value: "menyala", expected: "nyala"},
{value: "menyanyikan", expected: "nyanyi"},
{value: "menyatakannya", expected: "nyata"},
{value: "penyanyi", expected: "nyanyi"},
{value: "penyawaan", expected: "nyawa"},
{value: "rerata", expected: "rata"},
{value: "lelembut", expected: "lembut"},
{value: "lemigas", expected: "ligas"},
{value: "kinerja", expected: "kerja"},
{value: "bertebaran", expected: "tebar"},
{value: "terasingkan", expected: "asing"},
{value: "membangunkan", expected: "bangun"},
{value: "mencintai", expected: "cinta"},
{value: "menduakan", expected: "dua"},
{value: "menjauhi", expected: "jauh"},
{value: "menggilai", expected: "gila"},
{value: "pembangunan", expected: "bangun"},
{value: "marwan", expected: "marwan"},
{value: "subarkah", expected: "subarkah"},
{value: "memberdayakan", expected: "daya"},
{value: "persemakmuran", expected: "makmur"},
{value: "keberuntunganmu", expected: "untung"},
{value: "kesepersepuluhnya", expected: "sepuluh"},
{value: "Perekonomian", expected: "ekonomi"},
{value: "menahan", expected: "tahan"},
{value: "peranan", expected: "peran"},
{value: "memberikan", expected: "beri"},
{value: "medannya", expected: "medan"},
{value: "idealis", expected: "ideal"},
{value: "idealisme", expected: "ideal"},
{value: "finalisasi", expected: "final"},
{value: "mentaati", expected: "taat"},
{value: "melewati", expected: "lewat"},
{value: "menganga", expected: "nganga"},
{value: "kupukul", expected: "pukul"},
{value: "kauhajar", expected: "hajar"},
{value: "kuasa-Mu", expected: "kuasa"},
{value: "nikmat-Ku", expected: "nikmat"},
{value: "allah-lah", expected: "allah"},
}
dictionary := NewDictionary("hancur", "benar", "apa", "siapa", "jubah",
"baju", "beli", "celana", "hantu", "jual", "buku", "milik", "kulit",
"sakit", "kasih", "buang", "suap", "nilai", "beri", "rambut", "adu",
"suara", "daerah", "ajar", "kerja", "ternak", "asing", "raup", "gerak",
"puruk", "terbang", "lipat", "ringkas", "warna", "yakin", "bangun",
"fitnah", "vonis", "baru", "ajar", "tangkap", "kupas", "minum", "pukul",
"cinta", "dua", "jauh", "ziarah", "nuklir", "gila", "hajar", "qasar",
"udara", "populer", "warna", "yoga", "adil", "rumah", "muka", "labuh",
"tarung", "tebar", "indah", "daya", "untung", "sepuluh", "ekonomi",
"makmur", "telah", "serta", "percaya", "pengaruh", "kritik", "seko",
"sekolah", "tahan", "capa", "capai", "mula", "mulai", "petan", "tani",
"aba", "abai", "balas", "balik", "peran", "medan", "syukur", "syarat",
"bom", "promosi", "proteksi", "prediksi", "kaji", "sembunyi", "langgan",
"laku", "baik", "terang", "iman", "bisik", "taat", "puas", "makan",
"nyala", "nyanyi", "nyata", "nyawa", "rata", "lembut", "ligas",
"budaya", "karya", "ideal", "final", "taat", "tiru", "sepak", "kuasa",
"malaikat", "nikmat", "lewat", "nganga", "allah",
)
stemmer := NewStemmer(dictionary)
for _, item := range testItems {
result := stemmer.Stem(item.value)
if result != item.expected {
t.Errorf("%s, expected: %s, result: %s", item.value, item.expected, result)
}
}
}