ai/src/utils/includes.ts

11 lines
326 B
TypeScript
Raw Normal View History

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