1 function AI_Think(env){
3 this.jobStack = new Array();
4 this.processingJob = null;
15 tickStartTimeMs = new Date();
16 if(this.env.input.sentenceList.length > 0){
17 this.env.debug("**** Think ****\n");
19 for(var i = 0; i < 64; i++){
20 if((new Date()) - tickStartTimeMs > this.tickLimitMs){
25 s = this.env.input.getSentence();
28 //入力文字列が終了したので、単語候補をソート
29 this.env.wordRecognition.sortCandidateWordListByWordCount();
30 this.env.wordRecognition.computeEachWordLevel();
31 this.env.wordRecognition.sortCandidateWordListByWordLevel();
32 this.env.wordRecognition.cleanCandidateWordList();
35 if(this.env.input.lastSentenceSourceType){
36 this.env.message(this.env.input.lastSentenceSourceType, true);
38 this.env.message("Unknown", true);
40 this.env.message("> " + s + "\n", true);
42 this.env.wordRecognition.slideLookUpCandidateWordByHistory(s);
44 separated = this.env.wordRecognition.splitByWord(s);
45 this.env.debug("[" + separated.join(" ") + "]\n");
46 separated_UUID = this.env.wordRecognition.getUUIDListFromSeparatedString(separated);
47 //分割の結果、未定義文字列と判別された部分を候補単語から探し、候補単語にあれば、その出現回数を+100する。
48 for(var i = 0, iLen = separated_UUID.length;i < iLen; i++){
49 if(separated_UUID[i] == this.env.UUID_Meaning_UndefinedString){
50 t = this.env.wordRecognition.getCandidateWordTagByString(separated[i]);
57 this.checkPattern(separated, separated_UUID);
60 if(this.processingJob && this.processingJob.input(s) === undefined){
61 this.processingJob = null;
64 } else if(this.processingJob || this.jobStack.length > 0){
65 if(!this.processingJob){
66 this.processingJob = this.jobStack.pop();
68 if(this.processingJob.tick() === undefined){
69 this.processingJob = null;
73 checkPattern: function(separated, separated_UUID){
75 this.env.debug("[\n" + separated_UUID.join("\n") + "\n]\n");
76 var pList = this.env.memory.patternList.copy();
78 if(pList.length <= 0 || separated.length <= 0 || separated_UUID.length <= 0){
82 for(var i = 0, iLen = pList.length; i < iLen; i++){
83 var p = pList[i].pattern;
84 if(p instanceof Function){
85 if(pList[i].pattern(separated, separated_UUID)){
88 } else if(p instanceof Array){
90 if(separated_UUID.length == p.length){
91 for(var j = 0, jLen = separated_UUID.length; j < jLen; j++){
92 if(p[j] != separated_UUID[j]){
101 pList.removeByIndex(i);
105 //マッチしたパターンに設定された関数の呼び出し
106 for(var i = 0, iLen = pList.length; i < iLen; i++){
109 p.func(this.env, separated, separated_UUID);