File tree 3 files changed +38
-2
lines changed
3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,28 @@ namespace kiwi
166
166
167
167
/* * 분할된 형태소의 경우 원형 형태소를 반환한다. 그 외에는 자기 자신을 반환한다. */
168
168
const Morpheme* getCombined () const { return this + combined; }
169
+
170
+ bool hasComplex () const
171
+ {
172
+ if (getCombined ()->complex ) return true ;
173
+
174
+ for (auto c : chunks)
175
+ {
176
+ if (c->complex ) return true ;
177
+ }
178
+ return false ;
179
+ }
180
+
181
+ template <class Container >
182
+ bool hasMorpheme (Container&& m) const
183
+ {
184
+ if (m.count (getCombined ())) return true ;
185
+ for (auto c : chunks)
186
+ {
187
+ if (m.count (c)) return true ;
188
+ }
189
+ return false ;
190
+ }
169
191
};
170
192
171
193
/* *
Original file line number Diff line number Diff line change @@ -871,8 +871,8 @@ namespace kiwi
871
871
{
872
872
for (auto & curMorph : cands)
873
873
{
874
- if (splitComplex && curMorph->getCombined ()-> complex ) continue ;
875
- if (blocklist && blocklist-> count ( curMorph->getCombined () )) continue ;
874
+ if (splitComplex && curMorph->hasComplex () ) continue ;
875
+ if (blocklist && curMorph->hasMorpheme (*blocklist )) continue ;
876
876
877
877
// 덧붙은 받침(zCoda)을 위한 지름길
878
878
if (curMorph->tag == POSTag::z_coda)
Original file line number Diff line number Diff line change @@ -187,6 +187,20 @@ TEST(KiwiCpp, SplitComplex)
187
187
EXPECT_EQ (res2.first [0 ].str , u" 감사" );
188
188
}
189
189
}
190
+
191
+ {
192
+ auto testCases = {
193
+ u" 집에 갔어요" ,
194
+ u" 집에 가요" ,
195
+ };
196
+ for (auto s : testCases)
197
+ {
198
+ auto res1 = kiwi.analyze (s, Match::allWithNormalizing);
199
+ auto res2 = kiwi.analyze (s, Match::allWithNormalizing | Match::splitComplex);
200
+ EXPECT_EQ (res1.first [res1.first .size () - 1 ].str , u" 어요" );
201
+ EXPECT_EQ (res2.first [res2.first .size () - 1 ].str , u" 요" );
202
+ }
203
+ }
190
204
}
191
205
192
206
TEST (KiwiCpp, OldHangul)
You can’t perform that action at this time.
0 commit comments