How to use the wanakana.toHiragana function in wanakana

To help you get started, we’ve selected a few wanakana examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hexenq / kuroshiro / dist / node / kuroshiro.js View on Github external
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
github Kaniwani / kw-frontend / app / common / utils / filterRomajiReadings.js View on Github external
    (meaning) => !readings.some((reading) => RegExp(`^${reading}`, 'i').test(toHiragana(meaning)))
  );
github Kaniwani / kw-frontend / app / utils / filterRomajiReadings.js View on Github external
    (meaning) => !kanaReadings.some((reading) => RegExp(reading, 'gi').test(toHiragana(meaning)))
  );
github project-yuki / YUKI / src / main / middlewares / MeCabMiddleware.ts View on Github external
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)
  }
}
github hexenq / kuroshiro / dist / node / kuroshiro.js View on Github external
}
                        }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
github nkjm / bot-express / module / parser / string.js View on Github external
}

        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")
            }
        }
github project-yuki / YUKI / src / main / mecab.ts View on Github external
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);
  }
}