Open5
compromise, naturalで遊ぶ
単語ごとに分ける
const sentence = "Permission is hereby granted, free of charge, to any person obtaining a copy of this software"
const terms = nlp(sentence).terms().json().map((t: any) => t.terms).flat()
termsに{ pre, text, post}
のデータが入った配列が返ってくる
fuzzy match
「grant」という単語で「granted」を見つる
const sentence = "Permission is hereby granted, free of charge, to any person obtaining a copy of this software"
return nlp(sentence).match("grant", { fuzzy: 0.7 }).text()
syllable
extendが必要
const nlp = require('compromise')
nlp.extend(require('compromise-syllables'))
const json = nlp('chocolate').terms().syllables()
// [ ["cho","co","late"]]
発音
const doc = nlp('knife')
doc.pronounce().map(o=>o.pronounce)
// ["nife"]
naturalのwordnet
- http://naturalnode.github.io/natural/wordnet.html
- naturalのwordnetはprincetonのもの
-
https://github.com/NaturalNode/natural/blob/master/lib/natural/wordnet/wordnet_file.js
- fsで読み出してパースしまくってる?