OSDN Git Service

AIのDB連携機能を実装中。
[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_PatternTag = function(pattern, uuid, func){
51         AI_PatternTag.base.call(this, AI_PatternTag.base.prototype.Type_Pattern);
52         // p.func(this.env, separated, separated_UUID);
53         //patternには関数も指定できる。その場合、関数の形式は
54         //f(separated, separated_UUID)となる。戻り値がtrueの場合、パターンはマッチしたとみなされる
55         if(pattern){
56                 this.pattern = pattern;
57         }
58         if(uuid){
59                 this.uuid = uuid;
60         }
61         if(func){
62                 this.func = func;
63         }
64 }.extend(AI_MemoryTag, {
65         parseToStringData: function(){
66                 //Not implemented.
67         },
68 });
69
70 var AI_MeaningTag = function(uuid, description){
71         AI_MeaningTag.base.call(this, AI_MeaningTag.base.prototype.Type_Meaning);
72         if(description){
73                 this.description = description;
74         }
75         if(uuid){
76                 this.uuid = uuid;
77         }
78 }.extend(AI_MemoryTag, {
79         parseToStringData: function(){
80                 //Not implemented.
81         },
82 });