88 */
99class Response
1010{
11- const ACT_ASSERT = 'assert ' ;
12- const ACT_COMMAND = 'command ' ;
13- const ACT_WH_QUERY = 'wh-query ' ;
14- const ACT_YN_QUERY = 'yn-query ' ;
15-
16- const TYPE_ABBREVIATION = 'abbr: ' ;
17- const TYPE_ENTITY = 'enty: ' ;
18- const TYPE_DESCRIPTION = 'desc: ' ;
19- const TYPE_HUMAN = 'hum: ' ;
20- const TYPE_LOCATION = 'loc: ' ;
21- const TYPE_NUMBER = 'num: ' ;
22-
23- const SENTIMENT_POSITIVE = 'positive ' ;
24- const SENTIMENT_NEUTRAL = 'neutral ' ;
25- const SENTIMENT_NEGATIVE = 'negative ' ;
26- const SENTIMENT_VPOSITIVE = 'vpositive ' ;
27- const SENTIMENT_VNEGATIVE = 'vnegative ' ;
2811
2912 /**
3013 * Response constructor.
3114 * @param $response
3215 */
3316 public function __construct ($ json )
3417 {
35- $ response = json_decode ($ json );
36-
18+ var_dump ($ json );
19+ $ response = json_decode ( $ json -> body );
3720 $ this ->entities = [];
3821
3922 $ this ->act = $ response ->results ->act ;
@@ -112,31 +95,31 @@ public function intent()
11295 */
11396 public function isAssert ()
11497 {
115- return ($ this ->act === self ::ACT_ASSERT );
98+ return ($ this ->act === Constants ::ACT_ASSERT );
11699 }
117100
118101 /**
119102 * @return bool
120103 */
121104 public function isCommand ()
122105 {
123- return ($ this ->act === self ::ACT_COMMAND );
106+ return ($ this ->act === Constants ::ACT_COMMAND );
124107 }
125108
126109 /**
127110 * @return bool
128111 */
129112 public function isWhQuery ()
130113 {
131- return ($ this ->act === self ::ACT_WH_QUERY );
114+ return ($ this ->act === Constants ::ACT_WH_QUERY );
132115 }
133116
134117 /**
135118 * @return bool
136119 */
137120 public function isYnQuery ()
138121 {
139- return ($ this ->act === self ::ACT_YN_QUERY );
122+ return ($ this ->act === Constants ::ACT_YN_QUERY );
140123 }
141124
142125 /**
@@ -146,7 +129,7 @@ public function isYnQuery()
146129 */
147130 public function isAbbreviation ()
148131 {
149- if (strstr ($ this ->type , self ::TYPE_ABBREVIATION )) {
132+ if (strstr ($ this ->type , Constants ::TYPE_ABBREVIATION )) {
150133 return (true );
151134 }
152135 return (false );
@@ -157,7 +140,7 @@ public function isAbbreviation()
157140 */
158141 public function isEntity ()
159142 {
160- if (strstr ($ this ->type , self ::TYPE_ENTITY )) {
143+ if (strstr ($ this ->type , Constants ::TYPE_ENTITY )) {
161144 return (true );
162145 }
163146 return (false );
@@ -168,7 +151,7 @@ public function isEntity()
168151 */
169152 public function isDescription ()
170153 {
171- if (strstr ($ this ->type , self ::TYPE_DESCRIPTION )) {
154+ if (strstr ($ this ->type , Constants ::TYPE_DESCRIPTION )) {
172155 return (true );
173156 }
174157 return (false );
@@ -179,7 +162,7 @@ public function isDescription()
179162 */
180163 public function isHuman ()
181164 {
182- if (strstr ($ this ->type , self ::TYPE_HUMAN )) {
165+ if (strstr ($ this ->type , Constants ::TYPE_HUMAN )) {
183166 return (true );
184167 }
185168 return (false );
@@ -190,7 +173,7 @@ public function isHuman()
190173 */
191174 public function isLocation ()
192175 {
193- if (strstr ($ this ->type , self ::TYPE_LOCATION )) {
176+ if (strstr ($ this ->type , Constants ::TYPE_LOCATION )) {
194177 return (true );
195178 }
196179 return (false );
@@ -201,7 +184,7 @@ public function isLocation()
201184 */
202185 public function isNumber ()
203186 {
204- if (strstr ($ this ->type , self ::TYPE_NUMBER )) {
187+ if (strstr ($ this ->type , Constants ::TYPE_NUMBER )) {
205188 return (true );
206189 }
207190 return (false );
@@ -215,38 +198,38 @@ public function isNumber()
215198
216199 public function isPositive ()
217200 {
218- return ($ this ->sentiment === self ::SENTIMENT_POSITIVE );
201+ return ($ this ->sentiment === Constants ::SENTIMENT_POSITIVE );
219202 }
220203
221204 /**
222205 * @return bool
223206 */
224207 public function isNeutral ()
225208 {
226- return ($ this ->sentiment === self ::SENTIMENT_NEUTRAL );
209+ return ($ this ->sentiment === Constants ::SENTIMENT_NEUTRAL );
227210 }
228211
229212 /**
230213 * @return bool
231214 */
232215 public function isNegative ()
233216 {
234- return ($ this ->sentiment === self ::SENTIMENT_NEGATIVE );
217+ return ($ this ->sentiment === Constants ::SENTIMENT_NEGATIVE );
235218 }
236219
237220 /**
238221 * @return bool
239222 */
240223 public function isVPositive ()
241224 {
242- return ($ this ->sentiment === self ::SENTIMENT_VPOSITIVE );
225+ return ($ this ->sentiment === Constants ::SENTIMENT_VPOSITIVE );
243226 }
244227
245228 /**
246229 * @return bool
247230 */
248231 public function isVNegative ()
249232 {
250- return ($ this ->sentiment === self ::SENTIMENT_VNEGATIVE );
233+ return ($ this ->sentiment === Constants ::SENTIMENT_VNEGATIVE );
251234 }
252235}
0 commit comments