Last active
January 23, 2020 16:57
-
-
Save butchi/5acbd64eb59b512eb4c2d8e065f28d5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MeCab = new require('mecab-async') | |
const mecab = new MeCab(); | |
mecab.parse(process.argv[2], (err, result) => { | |
if (err) throw err; | |
const txt = result.map(item => { | |
if (false) { | |
} else if (['接尾'].includes(item[2])) { | |
return item[0]; | |
} else if (['人名', '組織', '地域'].includes(item[3])) { | |
return `[${item[2]}]`; | |
} else if (['固有名詞', '代名詞', '数'].includes(item[2])) { | |
return `[${item[2]}]`; | |
} else if (['名詞', '動詞', '形容詞', '副詞', '感動詞'].includes(item[1])) { | |
return `[${item[1]}]`; | |
} else { | |
return item[0]; | |
} | |
}).join('') | |
console.log(txt); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment