-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgpits_core.php
More file actions
150 lines (119 loc) · 2.98 KB
/
gpits_core.php
File metadata and controls
150 lines (119 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
/*Chatbot Classes*/
class Entity {
protected $type;
protected $name;
protected $instance;
}
class Context {
protected $path;
protected $entities;
}
abstract class MemoryManager {
public abstract function getUserContext($user);
public abstract function updateUserContext($user, $context);
}
abstract class EntityExtractor {
protected $entities;
public abstract function extractEntities($query);
}
abstract class ChatBotController {
public abstract function processQuery($query, $user);
public abstract function constructQuery($raw);
}
/*Domain Knowledge Access Classes*/
class Field {
public $name;
public $value;
public function __construct($name=null, $value=null) {
$this->name = $name;
$this->value = $value;
}
}
class Query {
public $raw_data = null;
public $get_property = null;
public $fields;
function __construct($raw_data = null) {
$this->raw_data = $raw_data;
$this->fields = array();
}
function addField($name, $value=null) {
$f = new Field($name, $value);
$this->fields[] = $f;
}
function getField($name) {
foreach ($this->fields as $f) {
if($f->name == $name)
return $f->value;
}
return null;
}
public function __toString() {
$return = "Get property: " . $this->get_property . " ";
foreach ($this->fields as $f) {
$return .= $f->name . " : " . $f->value . " ";
}
return $return;
}
public function setField($name, $value) {
$this->fields = array();
$this->addField($name, $value);
}
public function hasField($name, $value) {
foreach ($this->fields as $f) {
if($f->name == $name && $f->value == $value)
return true;
}
return false;
}
}
abstract class Driver {
protected $base = "";
abstract protected function connect();
abstract protected function runQuery($query);
}
abstract class DomainKnowledge {
abstract protected function generateQuery($raw_query);
}
/*ITS Classes*/
class Request {
public $raw_query;
public $user;
public function __construct($raw_query=null, $user=null) {
$this->raw_query = $raw_query;
$this->user = $user;
}
}
abstract class Response {
public $attributes;
public function __construct($attributes = null) {
if($attributes == null)
$this->attributes = array();
else
$this->attributes = $attributes;
}
public abstract function format();
}
abstract class Tutor {
public abstract function decideFedBack($user);
public abstract function attendRequest($request, $user);
}
/*User profiles classes*/
abstract class User {}
class UserProfile {
protected $name;
protected $description;
protected $attributes;
public function __construct($name=null, $description = null, $attributes = null) {
$this->name = $name;
$this->description = $description;
if($attributes == null)
$this->attributes = array();
else
$this->attributes = $attributes;
}
}
abstract class UserProfiler {
public abstract function decideUserProfile($user);
}