ai/src/utils/includes.ts

11 lines
344 B
TypeScript
Raw Normal View History

2018-08-31 08:24:07 +00:00
import { hiraganaToKatagana, zenkakuToHankaku, hankakuToZenkaku } from './japanese';
export default function(text: string, words: string[]): boolean {
if (text == null) return false;
text = hankakuToZenkaku(hiraganaToKatagana(text));
words = words.map(word => hiraganaToKatagana(word));
return words.some(word => text.includes(word));
}