Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(options.mode === 'normal')
return splitObjArray(tokens,'reading');
else
return splitObjArray(tokens,'reading',' ');
break;
case 'romaji':
if(options.mode === 'normal')
return wanakana.toRomaji(splitObjArray(tokens, 'reading'));
else
return wanakana.toRomaji(splitObjArray(tokens, 'reading', ' '));
break;
case 'hiragana':
for(var hi=0;hi
break;
case 'hiragana':
for(var hi=0;hi
(meaning) => !readings.some((reading) => RegExp(`^${reading}`, 'i').test(toHiragana(meaning)))
);
(meaning) => !kanaReadings.some((reading) => RegExp(reading, 'gi').test(toHiragana(meaning)))
);
public process (
context: yuki.TextOutputObject,
next: (newContext: yuki.TextOutputObject) => void
) {
if (!this.mecab) {
next(context)
return
}
const results = this.mecab.parseSync(context.text)
const usefulResult = []
for (const result of results) {
let kana = toHiragana(result[8])
if (kana === result[0]) kana = ''
usefulResult.push(
`${result[0]},${MecabMiddleware.KANJI_TO_ABBR_MAP[result[1]]},${kana}`
)
}
context.text = `$${usefulResult.join('|')}`
next(context)
}
}
}
}else{
isLastTokenKanji = false;
subs.push(tokens[i].surface_form[c]);
pattern += wanakana.isKatakana(tokens[i].surface_form[c]) ? wanakana.toHiragana(tokens[i].surface_form[c]):tokens[i].surface_form[c];
}
}
var reg = new RegExp('^' + pattern + '$');
var matches = reg.exec(tokens[i].reading);
if(matches){
var pickKanji = 1;
for(var c1=0;c1
}
if (policy.sanitize){
value = sanitize(value);
}
if (policy.character){
if (policy.character === "katakana"){
if (wanakana.isKana(value.replace(/(\s| )/g, ""))){
value = wanakana.toKatakana(value)
} else {
throw new Error("be_parser__should_be_katakana")
}
} else if (policy.character === "hiragana"){
if (wanakana.isKana(value.replace(/(\s| )/g, ""))){
value = wanakana.toHiragana(value)
} else {
throw new Error("be_parser__should_be_hiragana")
}
} else if (policy.character === "kana"){
if (!wanakana.isKana(value.replace(/(\s| )/g, ""))){
throw new Error("be_parser__should_be_kana")
}
}
}
if (policy.zenkaku){
if (!value.match(/^[^\x01-\x7E]+$/)){
throw Error("be_parser__should_be_zenkaku")
}
}
process(
context: Yagt.TextOutputObject,
next: (newContext: Yagt.TextOutputObject) => void
) {
if (!this.mecab) {
next(context);
return;
}
let result = this.mecab.parseSync(context.text);
let usefulResult = [];
for (const i in result) {
let kana = toHiragana(result[i][8]);
if (kana === result[i][0]) kana = "";
usefulResult.push(
`${result[i][0]},${
MecabMiddleware.KANJI_TO_ABBR_MAP[result[i][1]]
},${kana}`
);
}
context.text = `$${usefulResult.join("|")}`;
next(context);
}
}