-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on edge case of mecab ipadic hiragana conversion #80
Comments
After digging into it a little bit, it's more of a kuroshiro - mecab analyzer - ipadic mixed issue: $ echo "ユニ・チャーム" | mecab
ユニ・チャーム 名詞,固有名詞,組織,*,*,*,ユニ・チャーム,ユニチャーム,ユニチャーム
EOS As result, after [
{
surface_form: 'ユニ・チャーム',
pos: '名詞',
pos_detail_1: '固有名詞',
pos_detail_2: '組織',
pos_detail_3: '*',
conjugated_type: '*',
conjugated_form: '*',
basic_form: 'ユニ・チャーム',
reading: 'ユニチャーム',
pronunciation: 'ユニチャーム'
}
] While in core.js, hiragana and katakana are processed in this way: for (let c2 = 0; c2 < tokens[i].surface_form.length; c2++) {
notations.push([tokens[i].surface_form[c2], 2, toRawHiragana(tokens[i].reading[c2]), (tokens[i].pronunciation && tokens[i].pronunciation[c2]) || tokens[i].reading[c2]]);
} And the issue is, the aforementioned token has this property A quick dirty fix is to update const toRawHiragana = function (str) {
if (!str) return '';
return [...str].map((ch) => {
if (ch > "\u30a0" && ch < "\u30f7") {
return String.fromCharCode(ch.charCodeAt(0) + KATAKANA_HIRAGANA_SHIFT);
}
return ch;
}).join("");
}; |
Code above throws an error complaining about converting undefined to hiragana, with mecab ipadic(-neologd):
The text was updated successfully, but these errors were encountered: