mirror of
https://github.com/nullnyat/NullcatChan.git
synced 2025-08-06 23:13:50 +09:00
Improve AI
This commit is contained in:
17
src/utils/or.ts
Normal file
17
src/utils/or.ts
Normal 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(/(です|デス)$/, '');
|
||||
}
|
Reference in New Issue
Block a user