@@ -142,7 +142,7 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
142
142
auto fields = split (wstr, u' \t ' );
143
143
if (fields.size () < 3 )
144
144
{
145
- throw Exception { " wrong line: " + line };
145
+ throw FormatException { " wrong line: " + line };
146
146
}
147
147
148
148
auto form = normalizeHangul (fields[0 ]);
@@ -180,7 +180,7 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
180
180
}
181
181
else if (f == u" non_vowel" )
182
182
{
183
- if (cvowel != CondVowel::none) throw Exception { " wrong line: " + line };
183
+ if (cvowel != CondVowel::none) throw FormatException { " wrong line: " + line };
184
184
cvowel = CondVowel::non_vowel;
185
185
if (i + 1 < fields.size ())
186
186
{
@@ -189,7 +189,7 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
189
189
}
190
190
else if (f == u" vocalic" )
191
191
{
192
- if (cvowel != CondVowel::none) throw Exception { " wrong line: " + line };
192
+ if (cvowel != CondVowel::none) throw FormatException { " wrong line: " + line };
193
193
cvowel = CondVowel::vocalic;
194
194
if (i + 1 < fields.size ())
195
195
{
@@ -198,18 +198,18 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
198
198
}
199
199
else if (f == u" non_adj" )
200
200
{
201
- if (cpolar != CondPolarity::none) throw Exception { " wrong line: " + line };
201
+ if (cpolar != CondPolarity::none) throw FormatException { " wrong line: " + line };
202
202
cpolar = CondPolarity::non_adj;
203
203
}
204
204
else if (f.starts_with (u" complex " ))
205
205
{
206
- if (complex) throw Exception { " wrong line: " + line };
206
+ if (complex) throw FormatException { " wrong line: " + line };
207
207
complex = true ;
208
208
complexChunks.emplace (make_pair (form, tag), f.substr (8 ).to_string ());
209
209
}
210
210
else if (f[0 ] == u' =' )
211
211
{
212
- if (!origMorphemeOfAlias.empty ()) throw Exception { " wrong line: " + line };
212
+ if (!origMorphemeOfAlias.empty ()) throw FormatException { " wrong line: " + line };
213
213
if (f[1 ] == u' =' )
214
214
{
215
215
origMorphemeOfAlias = normalizeHangul (f.substr (2 ));
@@ -233,7 +233,7 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
233
233
}
234
234
else if (f[0 ] == u' ~' )
235
235
{
236
- if (!origMorphemeOfAlias.empty ()) throw Exception { " wrong line: " + line };
236
+ if (!origMorphemeOfAlias.empty ()) throw FormatException { " wrong line: " + line };
237
237
if (f.find (' /' ) == f.npos )
238
238
{
239
239
origMorphemeOfAlias = normalizeHangul (f.substr (1 ));
@@ -248,7 +248,7 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
248
248
}
249
249
else if (f[0 ] == u' -' )
250
250
{
251
- if (altWeight < 0 ) throw Exception { " wrong line: " + line };
251
+ if (altWeight < 0 ) throw FormatException { " wrong line: " + line };
252
252
altWeight = stof (f.begin (), f.end ());
253
253
}
254
254
else if (f[0 ] == ' >' )
@@ -270,7 +270,7 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
270
270
}
271
271
else
272
272
{
273
- throw Exception { " wrong line: " + line };
273
+ throw FormatException { " wrong line: " + line };
274
274
}
275
275
}
276
276
}
@@ -306,12 +306,12 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
306
306
307
307
if (it != morphMap.end () && it2 != morphMap.end ())
308
308
{
309
- throw Exception { " ambiguous base morpheme: " + utf16To8 (p.origForm ) + " /" + tagToString (clearIrregular (p.origTag )) };
309
+ throw FormatException { " ambiguous base morpheme: " + utf16To8 (p.origForm ) + " /" + tagToString (clearIrregular (p.origTag )) };
310
310
}
311
311
it = (it == morphMap.end ()) ? it2 : it;
312
312
if (it == morphMap.end ())
313
313
{
314
- throw Exception { " cannot find base morpheme: " + utf16To8 (p.origForm ) + " /" + tagToString (p.origTag ) };
314
+ throw FormatException { " cannot find base morpheme: " + utf16To8 (p.origForm ) + " /" + tagToString (p.origTag ) };
315
315
}
316
316
p.origMorphId = it->second .first ;
317
317
if (!p.addAlias ) continue ;
@@ -385,27 +385,27 @@ auto KiwiBuilder::loadMorphemesFromTxt(std::istream& is, Fn&& filter) -> Morphem
385
385
386
386
if (fd.back ().size () != (fd.size () - 1 ) * 2 )
387
387
{
388
- throw Exception { " wrong position information : " + utf16To8 (fd[0 ]) + " " + utf16To8 (fd.back ())};
388
+ throw FormatException { " wrong position information : " + utf16To8 (fd[0 ]) + " " + utf16To8 (fd.back ())};
389
389
}
390
390
auto posMap = normalizeHangulWithPosition (joinHangul (it->first .first )).second ;
391
391
for (size_t i = 0 ; i < fd.size () - 1 ; ++i)
392
392
{
393
393
auto f = split (fd[i], u' /' );
394
- if (f.size () != 2 ) throw Exception { " wrong format of morpheme : " + utf16To8 (fd[i]) };
394
+ if (f.size () != 2 ) throw FormatException { " wrong format of morpheme : " + utf16To8 (fd[i]) };
395
395
auto norm = normalizeHangul (f[0 ]);
396
396
auto tag = toPOSTag (f[1 ]);
397
397
auto it = morphMap.find (make_pair (norm, tag));
398
398
if (it == morphMap.end ())
399
399
{
400
- throw Exception { " cannot find morpheme : " + utf16To8 (fd[i]) };
400
+ throw FormatException { " cannot find morpheme : " + utf16To8 (fd[i]) };
401
401
}
402
402
size_t lmId = it->second .first ;
403
403
if (!morphemes[lmId].kform )
404
404
{
405
405
auto it = longTailMap.find (make_pair (norm, tag));
406
406
if (it == longTailMap.end ())
407
407
{
408
- throw Exception { " cannot find morpheme : " + utf16To8 (fd[i]) };
408
+ throw FormatException { " cannot find morpheme : " + utf16To8 (fd[i]) };
409
409
}
410
410
lmId = it->second ;
411
411
}
@@ -1514,7 +1514,7 @@ size_t KiwiBuilder::loadDictionary(const string& dictPath)
1514
1514
size_t fieldSize = split (wstr, u' \t ' , fields.begin (), 2 ) - fields.begin ();
1515
1515
if (fieldSize < 2 )
1516
1516
{
1517
- throw Exception (" [loadUserDictionary] Wrong dictionary format at line " + to_string (lineNo) + " : " + line);
1517
+ throw FormatException (" [loadUserDictionary] Wrong dictionary format at line " + to_string (lineNo) + " : " + line);
1518
1518
}
1519
1519
1520
1520
while (!fields[0 ].empty () && fields[0 ][0 ] == ' ' ) fields[0 ] = fields[0 ].substr (1 );
@@ -1536,26 +1536,26 @@ size_t KiwiBuilder::loadDictionary(const string& dictPath)
1536
1536
size_t p = m.rfind (u' /' );
1537
1537
if (p == m.npos )
1538
1538
{
1539
- throw Exception (" [loadUserDictionary] Wrong dictionary format at line " + to_string (lineNo) + " : " + line);
1539
+ throw FormatException (" [loadUserDictionary] Wrong dictionary format at line " + to_string (lineNo) + " : " + line);
1540
1540
}
1541
1541
auto pos = toPOSTag (m.substr (p + 1 ));
1542
1542
if (pos == POSTag::max)
1543
1543
{
1544
- throw Exception (" [loadUserDictionary] Unknown Tag '" + utf16To8 (fields[1 ]) + " ' at line " + to_string (lineNo));
1544
+ throw FormatException (" [loadUserDictionary] Unknown Tag '" + utf16To8 (fields[1 ]) + " ' at line " + to_string (lineNo));
1545
1545
}
1546
1546
morphemes.emplace_back (m.substr (0 , p), pos);
1547
1547
}
1548
1548
1549
1549
if (fields[0 ].empty ())
1550
1550
{
1551
- throw Exception (" [loadUserDictionary] Wrong dictionary format at line " + to_string (lineNo) + " : " + line);
1551
+ throw FormatException (" [loadUserDictionary] Wrong dictionary format at line " + to_string (lineNo) + " : " + line);
1552
1552
}
1553
1553
1554
1554
if (fields[0 ].back () == ' $' )
1555
1555
{
1556
1556
if (morphemes.size () > 1 )
1557
1557
{
1558
- throw Exception (" [loadUserDictionary] Replace rule cannot have 2 or more forms '" + utf16To8 (fields[1 ]) + " ' at line " + to_string (lineNo));
1558
+ throw FormatException (" [loadUserDictionary] Replace rule cannot have 2 or more forms '" + utf16To8 (fields[1 ]) + " ' at line " + to_string (lineNo));
1559
1559
}
1560
1560
1561
1561
auto suffix = fields[0 ].substr (0 , fields[0 ].size () - 1 );
@@ -1583,7 +1583,7 @@ size_t KiwiBuilder::loadDictionary(const string& dictPath)
1583
1583
auto pos = toPOSTag (fields[1 ]);
1584
1584
if (pos == POSTag::max)
1585
1585
{
1586
- throw Exception (" [loadUserDictionary] Unknown Tag '" + utf16To8 (fields[1 ]) + " ' at line " + to_string (lineNo));
1586
+ throw FormatException (" [loadUserDictionary] Unknown Tag '" + utf16To8 (fields[1 ]) + " ' at line " + to_string (lineNo));
1587
1587
}
1588
1588
addedCnt += addWord (fields[0 ], pos, score).second ? 1 : 0 ;
1589
1589
}
0 commit comments