ai/src/utils/includes.ts
2018-09-02 23:40:03 +09:00

11 lines
326 B
TypeScript

import { katakanaToHiragana, hankakuToZenkaku } from './japanese';
export default function(text: string, words: string[]): boolean {
if (text == null) return false;
text = katakanaToHiragana(hankakuToZenkaku(text));
words = words.map(word => katakanaToHiragana(word));
return words.some(word => text.includes(word));
}