0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

node 漢字 to ローマ字

Posted at

install

npm install xlsx
npm install kuroshiro@1.1.2
npm install kuroshiro-analyzer-kuromoji
npm install synchronized-promise

sample

const Kuroshiro = require("kuroshiro")
const KuromojiAnalyzer = require("kuroshiro-analyzer-kuromoji");
const sp = require('synchronized-promise')
//console.log(Kuroshiro)
const kuroshiro = new Kuroshiro();
let syncFunc = sp(sample)
const value = syncFunc("名無しの権兵衛")
console.log(value)

async function sample(str) {
    try {
        await kuroshiro.init(new KuromojiAnalyzer())
        let val = await kuroshiro.convert(str, {
            romajiSystem:"passport", to:"romaji",
        })
        //console.error(val);
        return val
    } catch (err) {
        console.error(err);
    } 
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?