Skip to content

Commit

Permalink
tokenization error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Hohyon Ryu committed Nov 5, 2015
1 parent ea01e76 commit ed75217
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,20 @@ object KoreanTokenizer {
* @return sequence of KoreanTokens
*/
def tokenize(text: CharSequence): Seq[KoreanToken] = {
chunk(text).flatMap {
case token: KoreanToken if token.pos == Korean =>
// Get the best parse of each chunk
val parsed = parseKoreanChunk(token)

// Collapse sequence of one-char nouns into one unknown noun: (가Noun 회Noun -> 가회Noun*)
collapseNouns(parsed)
case token: KoreanToken => Seq(token)
try {
chunk(text).flatMap {
case token: KoreanToken if token.pos == Korean =>
// Get the best parse of each chunk
val parsed = parseKoreanChunk(token)

// Collapse sequence of one-char nouns into one unknown noun: (가Noun 회Noun -> 가회Noun*)
collapseNouns(parsed)
case token: KoreanToken => Seq(token)
}
} catch {
case e: Exception =>
System.err.println(s"Error tokenizing a chunk: $text")
throw e
}
}
}

0 comments on commit ed75217

Please sign in to comment.