Open5

compromise, naturalで遊ぶ

terrierscriptterrierscript

単語ごとに分ける

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}のデータが入った配列が返ってくる

terrierscriptterrierscript

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()