Improve AI

This commit is contained in:
syuilo
2018-09-02 22:23:10 +09:00
parent ee82078f79
commit 2894d45aa7
5 changed files with 48 additions and 0 deletions

17
src/utils/or.ts Normal file
View File

@ -0,0 +1,17 @@
import { hiraganaToKatagana, hankakuToZenkaku } from './japanese';
export default function(text: string, words: string[]): boolean {
if (text == null) return false;
text = cleanup(hankakuToZenkaku(hiraganaToKatagana(text)));
words = words.map(word => hiraganaToKatagana(word));
return words.some(word => text == word);
}
function cleanup(text: string): string {
return text.trim()
.replace(/[!]+$/, '')
.replace(/。$/, '')
.replace(/(です|デス)$/, '');
}