OSDN Git Service

ノードの更新が反映されるようになった
[chnosproject/AI004.git] / aimemtag.js
1 var AI_CandidateWordTag = function(str){
2         AI_CandidateWordTag.base.call(this, AI_CandidateWordTag.base.prototype.Type_CandidateWord);
3         this.str = str;
4         this.wordCount = 0;
5         this.wordLevel = 0;
6 }.extend(AI_MemoryTag, {
7         parseToStringData: function(){
8                 //uuid:type:str:wordCount:wordLevel
9                 var e = encodeURIComponent;
10                 var d = new Object();
11                 d.s = e(this.str);
12                 d.c = this.wordCount;
13                 d.l = this.wordLevel.toString();
14                 
15                 return AI_CandidateWordTag.base.prototype.parseToStringData.call(this, d);
16         },
17         loadFromMemoryData: function(data){
18                 var e = decodeURIComponent;
19                 this.str = e(data.s);
20                 this.wordCount = data.c;
21                 this.wordLevel = data.l;
22         },
23 });
24
25 var AI_WordTag = function(str, uuid){
26         AI_WordTag.base.call(this, AI_WordTag.base.prototype.Type_Word);
27         if(str){
28                 this.str = str;
29         }
30         if(uuid){
31                 this.uuid = uuid;
32         }
33         this.wordCount = 0;
34 }.extend(AI_MemoryTag, {
35         parseToStringData: function(){
36                 //uuid:type:str:wordCount:wordLevel
37                 var e = encodeURIComponent;
38                 var d = new Object();
39                 d.s = e(this.str);
40                 d.c = this.wordCount;
41                 return AI_WordTag.base.prototype.parseToStringData.call(this, d);
42         },
43         loadFromMemoryData: function(data){
44                 var e = decodeURIComponent;
45                 this.str = e(data.s);
46                 this.wordCount = data.c;
47         },
48 });
49
50 var AI_DatabaseInfoTag = function(){
51         AI_DatabaseInfoTag.base.call(this, AI_DatabaseInfoTag.base.prototype.Type_DatabaseInfo);
52         this.readLineCount = 0;
53 }.extend(AI_MemoryTag, {
54         parseToStringData: function(){
55                 //uuid:type:str:wordCount:wordLevel
56                 var d = new Object();
57                 d.rlc = this.readLineCount;
58                 return AI_DatabaseInfoTag.base.prototype.parseToStringData.call(this, d);
59         },
60         loadFromMemoryData: function(data){
61                 this.readLineCount = data.rlc;
62         },
63         bindDatabaseInfo: function(aimemory){
64                 //このインスタンスがもつ情報をAI_Memoryのデータに反映させる
65                 aimemory.dbInfo.readLineCount = this.readLineCount;
66         },
67 });
68
69 var AI_PatternTag = function(pattern, uuid, func){
70         AI_PatternTag.base.call(this, AI_PatternTag.base.prototype.Type_Pattern);
71         // p.func(this.env, separated, separated_UUID);
72         //patternには関数も指定できる。その場合、関数の形式は
73         //f(separated, separated_UUID)となる。戻り値がtrueの場合、パターンはマッチしたとみなされる
74         if(pattern){
75                 this.pattern = pattern;
76         }
77         if(uuid){
78                 this.uuid = uuid;
79         }
80         if(func){
81                 this.func = func;
82         }
83 }.extend(AI_MemoryTag, {
84         parseToStringData: function(){
85                 //Not implemented.
86         },
87 });
88
89 var AI_MeaningTag = function(uuid, description){
90         AI_MeaningTag.base.call(this, AI_MeaningTag.base.prototype.Type_Meaning);
91         if(description){
92                 this.description = description;
93         }
94         if(uuid){
95                 this.uuid = uuid;
96         }
97 }.extend(AI_MemoryTag, {
98         parseToStringData: function(){
99                 //Not implemented.
100         },
101 });