1 | <?php |
---|
2 | |
---|
3 | class Recommender extends CI_Model { |
---|
4 | |
---|
5 | function __construct() |
---|
6 | { |
---|
7 | // Call the Model constructor |
---|
8 | parent::__construct(); |
---|
9 | |
---|
10 | $this->load->library('Myword'); |
---|
11 | $this->load->library('Mymatching'); |
---|
12 | } |
---|
13 | |
---|
14 | private function SUMcount() { |
---|
15 | $output = null; |
---|
16 | |
---|
17 | $this->db->select('SUM(P_StatsUserPicto.countx1) as count'); |
---|
18 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
19 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
20 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
21 | $this->db->from('P_StatsUserPicto'); |
---|
22 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
23 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
24 | $query = $this->db->get(); |
---|
25 | |
---|
26 | if ($query->num_rows() > 0) { |
---|
27 | $output = $query->result(); |
---|
28 | } |
---|
29 | return $output; |
---|
30 | } |
---|
31 | |
---|
32 | private function unique_multidim_array($array, $key) { |
---|
33 | $temp_array = array(); |
---|
34 | $i = 0; |
---|
35 | $key_array = array(); |
---|
36 | |
---|
37 | foreach($array as $val) { |
---|
38 | if (!in_array($val->$key, $key_array)) { |
---|
39 | $key_array[$i] = $val->$key; |
---|
40 | $temp_array[$i] = $val; |
---|
41 | } |
---|
42 | $i++; |
---|
43 | } |
---|
44 | return $temp_array; |
---|
45 | } |
---|
46 | |
---|
47 | private function getIdsElem(){ |
---|
48 | $output = array(); |
---|
49 | $output = null; |
---|
50 | |
---|
51 | $this->db->select('pictoid'); |
---|
52 | $this->db->from('R_S_TempPictograms'); |
---|
53 | $this->db->where('ID_RSTPUser', $this->session->userdata('idusu')); |
---|
54 | $query = $this->db->get(); |
---|
55 | |
---|
56 | if ($query->num_rows() > 0) { |
---|
57 | $output = $query->result(); |
---|
58 | } |
---|
59 | return $output; |
---|
60 | } |
---|
61 | |
---|
62 | private function getTypesElem($pictoid){ |
---|
63 | $output = array(); |
---|
64 | $output = null; |
---|
65 | |
---|
66 | $this->db->select('pictoType'); |
---|
67 | $this->db->from('Pictograms'); |
---|
68 | $this->db->where('pictoid', $pictoid); |
---|
69 | $query = $this->db->get(); |
---|
70 | |
---|
71 | if ($query->num_rows() > 0) { |
---|
72 | $output = $query->result(); |
---|
73 | } |
---|
74 | return $output; |
---|
75 | } |
---|
76 | |
---|
77 | private function getNameClass($pictoid){ |
---|
78 | $output = array(); |
---|
79 | $output = null; |
---|
80 | |
---|
81 | $this->db->select('class'); |
---|
82 | $this->db->from('NameClass'.$this->session->userdata('ulangabbr')); |
---|
83 | $this->db->where('nameid', $pictoid); |
---|
84 | $query = $this->db->get(); |
---|
85 | |
---|
86 | if ($query->num_rows() > 0) { |
---|
87 | $output = $query->result(); |
---|
88 | } |
---|
89 | return $output; |
---|
90 | } |
---|
91 | |
---|
92 | private function getAdvType($pictoid){ |
---|
93 | $output = array(); |
---|
94 | $output = null; |
---|
95 | |
---|
96 | $this->db->select('type'); |
---|
97 | $this->db->from('AdvType'.$this->session->userdata('ulangabbr')); |
---|
98 | $this->db->where('advid', $pictoid); |
---|
99 | $query = $this->db->get(); |
---|
100 | |
---|
101 | if ($query->num_rows() > 0) { |
---|
102 | $output = $query->result(); |
---|
103 | } |
---|
104 | return $output; |
---|
105 | } |
---|
106 | |
---|
107 | private function getSubj() { |
---|
108 | $output = array(); |
---|
109 | $output = null; |
---|
110 | |
---|
111 | // Ids of the Pictograms for "I" and "you" in all languages |
---|
112 | $subjList = array(444, 466); |
---|
113 | |
---|
114 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
115 | $this->db->from('PictogramsLanguage'); |
---|
116 | $this->db->join('Pictograms', 'PictogramsLanguage.pictoid = Pictograms.pictoid', 'left'); |
---|
117 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
118 | $this->db->where_in('Pictograms.pictoid', $subjList); |
---|
119 | $query = $this->db->get(); |
---|
120 | |
---|
121 | if ($query->num_rows() > 0) { |
---|
122 | $output = $query->result(); |
---|
123 | } |
---|
124 | return $output; |
---|
125 | } |
---|
126 | |
---|
127 | private function getfreqUsuariX2($inputid1) { |
---|
128 | $output = array(); |
---|
129 | $output = null; |
---|
130 | |
---|
131 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
132 | $this->db->from('P_StatsUserPictox2'); |
---|
133 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
134 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
135 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
136 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
137 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
138 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
139 | $this->db->order_by('countx2', 'desc'); |
---|
140 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
141 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
142 | $this->db->limit(3); |
---|
143 | $query = $this->db->get(); |
---|
144 | |
---|
145 | if ($query->num_rows() > 0) { |
---|
146 | $output = $query->result(); |
---|
147 | } |
---|
148 | return $output; |
---|
149 | } |
---|
150 | |
---|
151 | private function getfreqUsuariX2NV($inputid1) { |
---|
152 | $output = array(); |
---|
153 | $output = null; |
---|
154 | |
---|
155 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
156 | $this->db->from('P_StatsUserPictox2'); |
---|
157 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
158 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
159 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
160 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
161 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
162 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
163 | $this->db->where('Pictograms.pictoType !=', 'verb'); |
---|
164 | $this->db->order_by('countx2', 'desc'); |
---|
165 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
166 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
167 | $this->db->limit(3); |
---|
168 | $query = $this->db->get(); |
---|
169 | |
---|
170 | if ($query->num_rows() > 0) { |
---|
171 | $output = $query->result(); |
---|
172 | } |
---|
173 | return $output; |
---|
174 | } |
---|
175 | |
---|
176 | private function getfreqUsuariX2NonExpan($inputid1) { |
---|
177 | $output = array(); |
---|
178 | $output = null; |
---|
179 | |
---|
180 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
181 | $this->db->from('P_StatsUserPictox2'); |
---|
182 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
183 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
184 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
185 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
186 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
187 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
188 | $this->db->order_by('countx2', 'desc'); |
---|
189 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
190 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
191 | $query = $this->db->get(); |
---|
192 | |
---|
193 | if ($query->num_rows() > 0) { |
---|
194 | $output = $query->result(); |
---|
195 | } |
---|
196 | return $output; |
---|
197 | } |
---|
198 | |
---|
199 | private function getfreqUsuariNameX2($inputid1, $fits) { |
---|
200 | $output = array(); |
---|
201 | $output = null; |
---|
202 | |
---|
203 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
204 | $this->db->from('P_StatsUserPictox2'); |
---|
205 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
206 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
207 | $this->db->join('NameClass'.$this->session->userdata('ulangabbr'), 'P_StatsUserPictox2.picto2id = NameClass'.$this->session->userdata('ulangabbr').'.nameid', 'left'); |
---|
208 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
209 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
210 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
211 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
212 | $this->db->where_in('NameClass'.$this->session->userdata('ulangabbr').'.class', $fits); |
---|
213 | $this->db->order_by('countx2', 'desc'); |
---|
214 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
215 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
216 | $query = $this->db->get(); |
---|
217 | |
---|
218 | if ($query->num_rows() > 0) { |
---|
219 | $output = $query->result(); |
---|
220 | } |
---|
221 | return $output; |
---|
222 | } |
---|
223 | |
---|
224 | private function getDbSearchQuant($pictoType) { |
---|
225 | $output = array(); |
---|
226 | $output = null; |
---|
227 | |
---|
228 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
229 | $this->db->from('P_StatsUserPicto'); |
---|
230 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
231 | $this->db->join('Pictograms', 'PictogramsLanguage.pictoid = Pictograms.pictoid', 'left'); |
---|
232 | $this->db->join('Modifier'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = Modifier'.$this->session->userdata('ulangabbr').'.modid', 'left'); |
---|
233 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
234 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
235 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
236 | $this->db->where('Modifier'.$this->session->userdata('ulangabbr').'.type', $pictoType); |
---|
237 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
238 | $this->db->order_by('repes', 'desc'); |
---|
239 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
240 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
241 | $query = $this->db->get(); |
---|
242 | |
---|
243 | if ($query->num_rows() > 0) { |
---|
244 | $output = $query->result(); |
---|
245 | } |
---|
246 | return $output; |
---|
247 | } |
---|
248 | |
---|
249 | private function getfreqUsuariQuantX2($inputid1, $fits) { |
---|
250 | $output = array(); |
---|
251 | $output = null; |
---|
252 | |
---|
253 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
254 | $this->db->from('P_StatsUserPictox2'); |
---|
255 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
256 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
257 | $this->db->join('Modifier'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = Modifier'.$this->session->userdata('ulangabbr').'.modid', 'left'); |
---|
258 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
259 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
260 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
261 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
262 | $this->db->where('Modifier'.$this->session->userdata('ulangabbr').'.type', $fits); |
---|
263 | $this->db->order_by('countx2', 'desc'); |
---|
264 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
265 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
266 | $query = $this->db->get(); |
---|
267 | |
---|
268 | if ($query->num_rows() > 0) { |
---|
269 | $output = $query->result(); |
---|
270 | } |
---|
271 | return $output; |
---|
272 | } |
---|
273 | |
---|
274 | private function getfreqUsuariQuantX3($inputid1, $inputid2, $fits) { |
---|
275 | $output = array(); |
---|
276 | $output = null; |
---|
277 | |
---|
278 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
279 | $this->db->from('P_StatsUserPictox3'); |
---|
280 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
281 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
282 | $this->db->join('Modifier'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = Modifier'.$this->session->userdata('ulangabbr').'.modid', 'left'); |
---|
283 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
284 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
285 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
286 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
287 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
288 | $this->db->where('Modifier'.$this->session->userdata('ulangabbr').'.type', $fits); |
---|
289 | $this->db->order_by('countx3', 'desc'); |
---|
290 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
291 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
292 | $query = $this->db->get(); |
---|
293 | |
---|
294 | if ($query->num_rows() > 0) { |
---|
295 | $output = $query->result(); |
---|
296 | } |
---|
297 | return $output; |
---|
298 | } |
---|
299 | |
---|
300 | private function getfreqUsuariAdvManeraX2($inputid1, $fits) { |
---|
301 | $output = array(); |
---|
302 | $output = null; |
---|
303 | |
---|
304 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
305 | $this->db->from('P_StatsUserPictox2'); |
---|
306 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
307 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
308 | $this->db->join('AdvType'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = AdvType'.$this->session->userdata('ulangabbr').'.advid', 'left'); |
---|
309 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
310 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
311 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
312 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
313 | $this->db->where('AdvType'.$this->session->userdata('ulangabbr').'.type', $fits); |
---|
314 | $this->db->order_by('countx2', 'desc'); |
---|
315 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
316 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
317 | $query = $this->db->get(); |
---|
318 | |
---|
319 | if ($query->num_rows() > 0) { |
---|
320 | $output = $query->result(); |
---|
321 | } |
---|
322 | return $output; |
---|
323 | } |
---|
324 | |
---|
325 | private function getfreqUsuariAdvManeraX3($inputid1, $inputid2, $fits) { |
---|
326 | $output = array(); |
---|
327 | $output = null; |
---|
328 | |
---|
329 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
330 | $this->db->from('P_StatsUserPictox3'); |
---|
331 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
332 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
333 | $this->db->join('AdvType'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = AdvType'.$this->session->userdata('ulangabbr').'.advid', 'left'); |
---|
334 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
335 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
336 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
337 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
338 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
339 | $this->db->where('AdvType'.$this->session->userdata('ulangabbr').'.type', $fits); |
---|
340 | $this->db->order_by('countx3', 'desc'); |
---|
341 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
342 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
343 | $query = $this->db->get(); |
---|
344 | |
---|
345 | if ($query->num_rows() > 0) { |
---|
346 | $output = $query->result(); |
---|
347 | } |
---|
348 | return $output; |
---|
349 | } |
---|
350 | |
---|
351 | private function getfreqUsuariAdjAdvX2($inputid1, $fits) { |
---|
352 | $output = array(); |
---|
353 | $output = null; |
---|
354 | |
---|
355 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
356 | $this->db->from('P_StatsUserPictox2'); |
---|
357 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
358 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
359 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
360 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
361 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
362 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
363 | $this->db->where('Pictograms.pictoType', $fits); |
---|
364 | $this->db->order_by('countx2', 'desc'); |
---|
365 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
366 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
367 | $query = $this->db->get(); |
---|
368 | |
---|
369 | if ($query->num_rows() > 0) { |
---|
370 | $output = $query->result(); |
---|
371 | } |
---|
372 | return $output; |
---|
373 | } |
---|
374 | |
---|
375 | private function getfreqUsuariAdjAdvX3($inputid1, $inputid2, $fits) { |
---|
376 | $output = array(); |
---|
377 | $output = null; |
---|
378 | |
---|
379 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
380 | $this->db->from('P_StatsUserPictox3'); |
---|
381 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
382 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto2id = Pictograms.pictoid', 'left'); |
---|
383 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
384 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
385 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
386 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
387 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
388 | $this->db->where('Pictograms.pictoType', $fits); |
---|
389 | $this->db->order_by('countx3', 'desc'); |
---|
390 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
391 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
392 | $query = $this->db->get(); |
---|
393 | |
---|
394 | if ($query->num_rows() > 0) { |
---|
395 | $output = $query->result(); |
---|
396 | } |
---|
397 | return $output; |
---|
398 | } |
---|
399 | |
---|
400 | private function getfreqUsuariOrdinalX2($inputid1, $fits) { |
---|
401 | $output = array(); |
---|
402 | $output = null; |
---|
403 | |
---|
404 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
405 | $this->db->from('P_StatsUserPictox2'); |
---|
406 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
407 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
408 | $this->db->join('AdjClass'.$this->session->userdata('ulangabbr'), 'P_StatsUserPictox2.picto2id = AdjClass'.$this->session->userdata('ulangabbr').'.adjid', 'left'); |
---|
409 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
410 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
411 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
412 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
413 | $this->db->where('AdjClass'.$this->session->userdata('ulangabbr').'.class', $fits); |
---|
414 | $this->db->order_by('countx2', 'desc'); |
---|
415 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
416 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
417 | $query = $this->db->get(); |
---|
418 | |
---|
419 | if ($query->num_rows() > 0) { |
---|
420 | $output = $query->result(); |
---|
421 | } |
---|
422 | return $output; |
---|
423 | } |
---|
424 | |
---|
425 | private function getfreqUsuariNameX3($inputid1, $inputid2, $fits) { |
---|
426 | $output = array(); |
---|
427 | $output = null; |
---|
428 | |
---|
429 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
430 | $this->db->from('P_StatsUserPictox3'); |
---|
431 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
432 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
433 | $this->db->join('NameClass'.$this->session->userdata('ulangabbr'), 'P_StatsUserPictox3.picto3id = NameClass'.$this->session->userdata('ulangabbr').'.nameid', 'left'); |
---|
434 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
435 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
436 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
437 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
438 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
439 | $this->db->where_in('NameClass'.$this->session->userdata('ulangabbr').'.class', $fits); |
---|
440 | $this->db->order_by('countx3', 'desc'); |
---|
441 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
442 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
443 | $query = $this->db->get(); |
---|
444 | |
---|
445 | if ($query->num_rows() > 0) { |
---|
446 | $output = $query->result(); |
---|
447 | } |
---|
448 | return $output; |
---|
449 | } |
---|
450 | |
---|
451 | private function getfreqUsuariOrdinalX3($inputid1, $inputid2, $fits) { |
---|
452 | $output = array(); |
---|
453 | $output = null; |
---|
454 | |
---|
455 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
456 | $this->db->from('P_StatsUserPictox3'); |
---|
457 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
458 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
459 | $this->db->join('AdjClass'.$this->session->userdata('ulangabbr'), 'P_StatsUserPictox3.picto3id = AdjClass'.$this->session->userdata('ulangabbr').'.adjid', 'left'); |
---|
460 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
461 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
462 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
463 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
464 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
465 | $this->db->where('AdjClass'.$this->session->userdata('ulangabbr').'.class', $fits); |
---|
466 | $this->db->order_by('countx3', 'desc'); |
---|
467 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
468 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
469 | $query = $this->db->get(); |
---|
470 | |
---|
471 | if ($query->num_rows() > 0) { |
---|
472 | $output = $query->result(); |
---|
473 | } |
---|
474 | return $output; |
---|
475 | } |
---|
476 | |
---|
477 | private function getDbSearchOrdinal($pictoType) { |
---|
478 | $output = array(); |
---|
479 | $output = null; |
---|
480 | |
---|
481 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
482 | $this->db->from('P_StatsUserPicto'); |
---|
483 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
484 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
485 | $this->db->join('AdjClass'.$this->session->userdata('ulangabbr'), 'PictogramsLanguage.pictoid = AdjClass'.$this->session->userdata('ulangabbr').'.adjid', 'left'); |
---|
486 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
487 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
488 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
489 | $this->db->where('AdjClass'.$this->session->userdata('ulangabbr').'.class', $pictoType); |
---|
490 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
491 | $this->db->order_by('repes', 'desc'); |
---|
492 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
493 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
494 | $query = $this->db->get(); |
---|
495 | |
---|
496 | if ($query->num_rows() > 0) { |
---|
497 | $output = $query->result(); |
---|
498 | } |
---|
499 | return $output; |
---|
500 | } |
---|
501 | |
---|
502 | private function getContextType2Days($pictoType) { |
---|
503 | |
---|
504 | $output = null; |
---|
505 | $date = array(date("Y-m-d"), date("Y-m-d", strtotime("yesterday"))); |
---|
506 | |
---|
507 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
508 | $this->db->from('P_StatsUserPicto'); |
---|
509 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
510 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
511 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
512 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
513 | $this->db->where_in('P_StatsUserPicto.lastdate', $date); |
---|
514 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
515 | $this->db->where('Pictograms.pictoType', $pictoType); |
---|
516 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
517 | $this->db->order_by('repes', 'desc'); |
---|
518 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
519 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
520 | $query = $this->db->get(); |
---|
521 | |
---|
522 | if ($query->num_rows() > 0) { |
---|
523 | $output = $query->result(); |
---|
524 | } |
---|
525 | return $output; |
---|
526 | } |
---|
527 | |
---|
528 | private function getContextFitsNClass2Days($fits) { |
---|
529 | $output = null; |
---|
530 | $date = array(date("Y-m-d"), date("Y-m-d", strtotime("yesterday"))); |
---|
531 | |
---|
532 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
533 | $this->db->from('P_StatsUserPicto'); |
---|
534 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
535 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
536 | $this->db->join('NameClass'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = NameClass'.$this->session->userdata('ulangabbr').'.nameid', 'left'); |
---|
537 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
538 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
539 | $this->db->where_in('P_StatsUserPicto.lastdate', $date); |
---|
540 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
541 | $this->db->where_in('NameClass'.$this->session->userdata('ulangabbr').'.class', $fits); |
---|
542 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
543 | $this->db->order_by('repes', 'desc'); |
---|
544 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
545 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
546 | $query = $this->db->get(); |
---|
547 | |
---|
548 | if ($query->num_rows() > 0) { |
---|
549 | $output = $query->result(); |
---|
550 | } |
---|
551 | return $output; |
---|
552 | } |
---|
553 | |
---|
554 | private function getContextFitsNClassAll($fits) { |
---|
555 | $output = null; |
---|
556 | |
---|
557 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
558 | $this->db->from('P_StatsUserPicto'); |
---|
559 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
560 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
561 | $this->db->join('NameClass'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = NameClass'.$this->session->userdata('ulangabbr').'.nameid', 'left'); |
---|
562 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
563 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
564 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
565 | $this->db->where_in('NameClass'.$this->session->userdata('ulangabbr').'.class', $fits); |
---|
566 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
567 | $this->db->order_by('repes', 'desc'); |
---|
568 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
569 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
570 | $query = $this->db->get(); |
---|
571 | |
---|
572 | if ($query->num_rows() > 0) { |
---|
573 | $output = $query->result(); |
---|
574 | } |
---|
575 | return $output; |
---|
576 | } |
---|
577 | |
---|
578 | private function getContextTypeAdvManeraAll($pictoType) { |
---|
579 | $output = array(); |
---|
580 | $output = null; |
---|
581 | |
---|
582 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
583 | $this->db->from('P_StatsUserPicto'); |
---|
584 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
585 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
586 | $this->db->join('AdvType'.$this->session->userdata('ulangabbr'), 'P_StatsUserPicto.pictoid = AdvType'.$this->session->userdata('ulangabbr').'.advid', 'left'); |
---|
587 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
588 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
589 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
590 | $this->db->where('AdvType'.$this->session->userdata('ulangabbr').'.type', $pictoType); |
---|
591 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
592 | $this->db->order_by('repes', 'desc'); |
---|
593 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
594 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
595 | $query = $this->db->get(); |
---|
596 | |
---|
597 | if ($query->num_rows() > 0) { |
---|
598 | $output = $query->result(); |
---|
599 | } |
---|
600 | return $output; |
---|
601 | } |
---|
602 | |
---|
603 | private function getContextTypeAll($pictoType) { |
---|
604 | $output = null; |
---|
605 | |
---|
606 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
607 | $this->db->from('P_StatsUserPicto'); |
---|
608 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
609 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
610 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
611 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
612 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
613 | $this->db->where('Pictograms.pictoType', $pictoType); |
---|
614 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
615 | $this->db->order_by('repes', 'desc'); |
---|
616 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
617 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
618 | $query = $this->db->get(); |
---|
619 | |
---|
620 | if ($query->num_rows() > 0) { |
---|
621 | $output = $query->result(); |
---|
622 | } |
---|
623 | return $output; |
---|
624 | } |
---|
625 | |
---|
626 | private function getContextTypeAllSE($pictoType, $inputid) { |
---|
627 | $output = null; |
---|
628 | $this->db->select('P_StatsUserPicto.pictoid, P_StatsUserPicto.countx1 as repes, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
629 | $this->db->from('P_StatsUserPicto'); |
---|
630 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
631 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
632 | $this->db->join('Adjective'.$this->session->userdata('ulangabbr'), 'Pictograms.pictoid = Adjective'.$this->session->userdata('ulangabbr').'.adjid', 'left'); |
---|
633 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
634 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
635 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
636 | $this->db->where('Pictograms.pictoType', $pictoType); |
---|
637 | $this->db->where('Adjective'.$this->session->userdata('ulangabbr').'.defaultverb', $inputid); |
---|
638 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
639 | $this->db->order_by('repes', 'desc'); |
---|
640 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
641 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
642 | $query = $this->db->get(); |
---|
643 | |
---|
644 | if ($query->num_rows() > 0) { |
---|
645 | $output = $query->result(); |
---|
646 | } |
---|
647 | return $output; |
---|
648 | } |
---|
649 | |
---|
650 | public function startsWith($haystack, $needle) { |
---|
651 | return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; |
---|
652 | } |
---|
653 | |
---|
654 | private function boolDetPos($pictoid) { |
---|
655 | $output = null; |
---|
656 | |
---|
657 | $this->db->select('type'); |
---|
658 | $this->db->from('Modifier'.$this->session->userdata('ulangabbr')); |
---|
659 | $this->db->where('modid', $pictoid); |
---|
660 | $query = $this->db->get(); |
---|
661 | |
---|
662 | if ($query->num_rows() > 0) { |
---|
663 | $output = $query->result(); |
---|
664 | } |
---|
665 | |
---|
666 | $res = false; |
---|
667 | if ($output[0]->type == 'det' || $this->startsWith($output[0]->type, 'pos')) $res = true; |
---|
668 | return $res; |
---|
669 | } |
---|
670 | |
---|
671 | private function getMMFits($tipus, $case){ |
---|
672 | $output = array(); |
---|
673 | $output = null; |
---|
674 | $caseTipus = $case."tipus"; |
---|
675 | // puede haber locfrom opt sin locfromtipus |
---|
676 | if($tipus[0]->$caseTipus != null) { |
---|
677 | $matching = new Mymatching(); |
---|
678 | $key = $matching->nounsFitKeys[$tipus[0]->$caseTipus]; |
---|
679 | $keyw = array_keys($matching->nounsFit[$key], 0); |
---|
680 | for ($i = 0; $i < sizeof($keyw); $i++) { |
---|
681 | $output[] = array_keys($matching->nounsFitKeys, $keyw[$i])[0]; |
---|
682 | } |
---|
683 | } |
---|
684 | return $output; |
---|
685 | } |
---|
686 | |
---|
687 | private function get1Opt($picto1id, $case) { |
---|
688 | $output = array(); |
---|
689 | $output = null; |
---|
690 | $this->db->select($case); |
---|
691 | $this->db->from('Pattern'.$this->session->userdata('ulangabbr')); |
---|
692 | $this->db->where('verbid', $picto1id); |
---|
693 | $query = $this->db->get(); |
---|
694 | |
---|
695 | if ($query->num_rows() > 0) { |
---|
696 | $output = $query->result(); |
---|
697 | } |
---|
698 | return $output; |
---|
699 | } |
---|
700 | |
---|
701 | private function getCaseTipus($picto1id, $case, $b) { |
---|
702 | $output = array(); |
---|
703 | $output = null; |
---|
704 | $this->db->select($case.'tipus'); |
---|
705 | $this->db->from('Pattern'.$this->session->userdata('ulangabbr')); |
---|
706 | $this->db->where('verbid', $picto1id); |
---|
707 | $this->db->where($case, $b); |
---|
708 | $query = $this->db->get(); |
---|
709 | |
---|
710 | if ($query->num_rows() > 0) { |
---|
711 | $output = $query->result(); |
---|
712 | } |
---|
713 | return $output; |
---|
714 | } |
---|
715 | |
---|
716 | private function get1OptFitsX2($inputid1, $case, $VF, $TSize, $fits) { |
---|
717 | if ($case == "locat") $fits = "lloc"; |
---|
718 | else if ($case == "acomp") $fits = "human"; |
---|
719 | |
---|
720 | if ($case == "theme") { |
---|
721 | if ($fits == 'adj' || $fits == 'adv') { |
---|
722 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
723 | $res = $this->getfreqUsuariAdjAdvX2($inputid1, $fits); |
---|
724 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
725 | } |
---|
726 | else if ($fits == 'ordinal') { |
---|
727 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
728 | $res = $this->getfreqUsuariOrdinalX2($inputid1, $fits); |
---|
729 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
730 | } |
---|
731 | else if ($fits != null && $fits != 'modif' && $fits != 'quant') { |
---|
732 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
733 | $res = $this->getfreqUsuariNameX2($inputid1, $fits); |
---|
734 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
735 | } |
---|
736 | } |
---|
737 | else if ($case == "manera") { |
---|
738 | if ($fits == 'quant') { // (case: manera) |
---|
739 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
740 | $res = $this->getfreqUsuariQuantX2($inputid1, $fits); |
---|
741 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
742 | } |
---|
743 | else if ($fits == 'manera') { // (case: manera) |
---|
744 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
745 | $res = $this->getfreqUsuariAdvManeraX2($inputid1, $fits); |
---|
746 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
747 | } |
---|
748 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj') { |
---|
749 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
750 | $res = $this->getfreqUsuariNameX2($inputid1, $fits); |
---|
751 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
752 | } |
---|
753 | } |
---|
754 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj' && $fits != 'adv' && $fits != 'quant') { |
---|
755 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
756 | $res = $this->getfreqUsuariNameX2($inputid1, $fits); |
---|
757 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
758 | } |
---|
759 | |
---|
760 | if ($case == "theme") { |
---|
761 | if ($fits == 'adj' || $fits == 'adv') { |
---|
762 | // Algorisme V6 - Predictor de context (adj i adv) total |
---|
763 | if ($fits == 'adj' && $inputid1 == '86') $res = $this->getContextTypeAllSE($fits, $inputid1); |
---|
764 | else if ($fits == 'adj' && $inputid1 == '100') $res = $this->getContextTypeAllSE($fits, $inputid1); |
---|
765 | else $res = $this->getContextTypeAll($fits); |
---|
766 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
767 | } |
---|
768 | else if ($fits == 'ordinal') { // (case: theme) |
---|
769 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. context) |
---|
770 | $res = $this->getDbSearchOrdinal($fits); |
---|
771 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
772 | } |
---|
773 | else if ($fits != null && $fits != 'modif' && $fits != 'quant') { |
---|
774 | // Algorisme V6 - Predictor de context ($fits) últims 2 dies |
---|
775 | $res = $this->getContextFitsNClass2Days($fits); |
---|
776 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
777 | |
---|
778 | // Algorisme V6 - Predictor de context ($fits) total |
---|
779 | $res = $this->getContextFitsNClassAll($fits); |
---|
780 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
781 | } |
---|
782 | } |
---|
783 | else if ($case == "manera") { |
---|
784 | if ($fits == 'quant') { // (case: manera) |
---|
785 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. context) |
---|
786 | $res = $this->getDbSearchQuant($fits); |
---|
787 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
788 | //return $res; |
---|
789 | } |
---|
790 | if ($fits == 'manera') { // (case: manera) |
---|
791 | // Algorisme V6 - Predictor de context (adv manera) total |
---|
792 | $res = $this->getContextTypeAdvManeraAll($fits); |
---|
793 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
794 | //return $contextTypeAdvManeraAll; |
---|
795 | } |
---|
796 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj') { // ¿ algun caso ? |
---|
797 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
798 | $res = $this->getContextType2Days('name'); |
---|
799 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
800 | |
---|
801 | // Algorisme V6 - Predictor de context (name) total |
---|
802 | $res = $this->getContextTypeAll('name'); |
---|
803 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
804 | } |
---|
805 | } |
---|
806 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj' && $fits != 'adv' && $fits != 'quant') { |
---|
807 | // Algorisme V6 - Predictor de context ($fits) últims 2 dies |
---|
808 | $res = $this->getContextFitsNClass2Days($fits); |
---|
809 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
810 | |
---|
811 | // Algorisme V6 - Predictor de context ($fits) total |
---|
812 | $res = $this->getContextFitsNClassAll($fits); |
---|
813 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
814 | } |
---|
815 | return $VF; |
---|
816 | } |
---|
817 | |
---|
818 | private function get1OptFitsX3($inputid1, $inputid2, $case, $VF, $TSize, $fits, $inputid) { |
---|
819 | if ($case == "locat") $fits = "lloc"; |
---|
820 | else if ($case == "acomp") $fits = "human"; |
---|
821 | |
---|
822 | if ($case == "theme") { |
---|
823 | if ($fits == 'adj' || $fits == 'adv') { |
---|
824 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
825 | $res = $this->getfreqUsuariAdjAdvX3($inputid1, $inputid2, $fits); |
---|
826 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
827 | } |
---|
828 | else if ($fits == 'ordinal') { |
---|
829 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
830 | $res = $this->getfreqUsuariOrdinalX3($inputid1, $inputid2, $fits); |
---|
831 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
832 | } |
---|
833 | else if ($fits != null && $fits != 'modif' && $fits != 'quant') { |
---|
834 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
835 | $res = $this->getfreqUsuariNameX3($inputid1, $inputid2, $fits); |
---|
836 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
837 | } |
---|
838 | } |
---|
839 | else if ($case == "manera") { |
---|
840 | if ($fits == 'quant') { // (case: manera) |
---|
841 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
842 | $res = $this->getfreqUsuariQuantX3($inputid1, $inputid2, $fits); |
---|
843 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
844 | } |
---|
845 | else if ($fits == 'manera') { // (case: manera) |
---|
846 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
847 | $res = $this->getfreqUsuariAdvManeraX3($inputid1, $inputid2, $fits); |
---|
848 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
849 | } |
---|
850 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj') { |
---|
851 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
852 | $res = $this->getfreqUsuariNameX3($inputid1, $inputid2, $fits); |
---|
853 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
854 | } |
---|
855 | } |
---|
856 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj' && $fits != 'adv' && $fits != 'quant') { |
---|
857 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. usuari) |
---|
858 | $res = $this->getfreqUsuariNameX3($inputid1, $inputid2, $fits); |
---|
859 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
860 | } |
---|
861 | |
---|
862 | if ($case == "theme") { |
---|
863 | if ($fits == 'adj' || $fits == 'adv') { |
---|
864 | // Algorisme V6 - Predictor de context (adj i adv) total |
---|
865 | if ($fits == 'adj' && $inputid == '86') $res = $this->getContextTypeAllSE($fits, $inputid); |
---|
866 | else if ($fits == 'adj' && $inputid == '100') $res = $this->getContextTypeAllSE($fits, $inputid); |
---|
867 | else $res = $this->getContextTypeAll($fits); |
---|
868 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
869 | } |
---|
870 | else if ($fits == 'ordinal') { // (case: theme) |
---|
871 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. context) |
---|
872 | $res = $this->getDbSearchOrdinal($fits); |
---|
873 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
874 | } |
---|
875 | else if ($fits != null && $fits != 'modif' && $fits != 'quant') { |
---|
876 | // Algorisme V6 - Predictor de context ($fits) últims 2 dies |
---|
877 | $res = $this->getContextFitsNClass2Days($fits); |
---|
878 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
879 | |
---|
880 | // Algorisme V6 - Predictor de context ($fits) total |
---|
881 | $res = $this->getContextFitsNClassAll($fits); |
---|
882 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
883 | } |
---|
884 | } |
---|
885 | else if ($case == "manera") { |
---|
886 | if ($fits == 'quant') { // (case: manera) |
---|
887 | // Algorismes V3 i V4 - Predictor verbs I i II (basat en freq. context) |
---|
888 | $res = $this->getDbSearchQuant($fits); |
---|
889 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
890 | //return $res; |
---|
891 | } |
---|
892 | if ($fits == 'manera') { // (case: manera) |
---|
893 | // Algorisme V6 - Predictor de context (adv manera) total |
---|
894 | $res = $this->getContextTypeAdvManeraAll($fits); |
---|
895 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
896 | //return $contextTypeAdvManeraAll; |
---|
897 | } |
---|
898 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj') { // ¿ algun caso ? |
---|
899 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
900 | $res = $this->getContextType2Days('name'); |
---|
901 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
902 | |
---|
903 | // Algorisme V6 - Predictor de context (name) total |
---|
904 | $res = $this->getContextTypeAll('name'); |
---|
905 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
906 | } |
---|
907 | } |
---|
908 | else if ($fits != null && $fits != 'ordinal' && $fits != 'modif' && $fits != 'adj' && $fits != 'adv' && $fits != 'quant') { |
---|
909 | // Algorisme V6 - Predictor de context ($fits) últims 2 dies |
---|
910 | $res = $this->getContextFitsNClass2Days($fits); |
---|
911 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
912 | |
---|
913 | // Algorisme V6 - Predictor de context ($fits) total |
---|
914 | $res = $this->getContextFitsNClassAll($fits); |
---|
915 | $VF = $this->rellenaVFX2X3($VF, $res, $TSize); |
---|
916 | } |
---|
917 | return $VF; |
---|
918 | } |
---|
919 | |
---|
920 | private function get1OptFits($inputid1, $case, $b) { |
---|
921 | $fits = null; |
---|
922 | $tipus = $this->getCaseTipus($inputid1, $case, $b); |
---|
923 | $caseTipus = $case."tipus"; |
---|
924 | if ($tipus != null && $tipus[0]->$caseTipus != 'adj' && $tipus[0]->$caseTipus != 'adv' && $tipus[0]->$caseTipus != 'modif' && $tipus[0]->$caseTipus != 'quant' && $tipus[0]->$caseTipus != 'verb' && $tipus[0]->$caseTipus != 'ordinal') { |
---|
925 | $fits = $this->getMMFits($tipus, $case); |
---|
926 | } |
---|
927 | |
---|
928 | if ($tipus != null && $tipus[0]->$caseTipus == 'verb') { |
---|
929 | $fits = 'verb'; |
---|
930 | } |
---|
931 | else if ($tipus != null && $tipus[0]->$caseTipus == 'adj') { |
---|
932 | $fits = 'adj'; |
---|
933 | } |
---|
934 | else if ($tipus != null && $case == "manera" && $tipus[0]->$caseTipus == 'adv') { |
---|
935 | $fits = 'manera'; |
---|
936 | } |
---|
937 | else if ($tipus != null && $tipus[0]->$caseTipus == 'adv') { |
---|
938 | $fits = 'adv'; |
---|
939 | } |
---|
940 | else if ($tipus != null && $tipus[0]->$caseTipus == 'quant') { |
---|
941 | $fits = 'quant'; |
---|
942 | } |
---|
943 | else if ($tipus != null && $tipus[0]->$caseTipus == 'ordinal') { |
---|
944 | $fits = 'ordinal'; |
---|
945 | } |
---|
946 | else if ($tipus != null && $case == 'locto') { |
---|
947 | $fits = 'lloc'; |
---|
948 | } |
---|
949 | else if ($tipus != null && $case == 'locfrom') { |
---|
950 | $fits = 'lloc'; |
---|
951 | } |
---|
952 | return $fits; |
---|
953 | } |
---|
954 | |
---|
955 | private function getHora (){ |
---|
956 | return date('G', time()); |
---|
957 | } |
---|
958 | |
---|
959 | private function getDia() { |
---|
960 | return date('D', time()); |
---|
961 | } |
---|
962 | |
---|
963 | private function getContextTypeAllDeep($pictoType, $minCount) { |
---|
964 | $output = null; |
---|
965 | |
---|
966 | $horaMinus = ($this->getHora()-1); |
---|
967 | if ($horaMinus < 0) $horaMinus += 24; |
---|
968 | |
---|
969 | $horaPlus = ($this->getHora()+1); |
---|
970 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
971 | |
---|
972 | $hora = $this->getHora(); |
---|
973 | |
---|
974 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPicto.'.$horaMinus.'h+P_StatsUserPicto.'.$hora.'h+P_StatsUserPicto.'.$horaPlus.'h+P_StatsUserPicto.'.$this->getDia().'+P_StatsUserPicto.'.$this->getDia().') as repes'); |
---|
975 | $this->db->from('P_StatsUserPicto'); |
---|
976 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
977 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
978 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
979 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
980 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
981 | $this->db->where('Pictograms.pictoType', $pictoType); |
---|
982 | $this->db->group_by('P_StatsUserPicto.pictoid, PictogramsLanguage.pictotext, Pictograms.imgPicto'); |
---|
983 | $this->db->having('repes >=', $minCount); |
---|
984 | $this->db->order_by('repes', 'desc'); |
---|
985 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
986 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
987 | $query = $this->db->get(); |
---|
988 | |
---|
989 | if ($query->num_rows() > 0) { |
---|
990 | $output = $query->result(); |
---|
991 | foreach($output as $value) { |
---|
992 | $value->repes = $value->repes*10; |
---|
993 | } |
---|
994 | } |
---|
995 | return $output; |
---|
996 | } |
---|
997 | |
---|
998 | private function getfreqUsuariX3NonExpanDeep($inputid1, $inputid2, $minCount) { |
---|
999 | $output = array(); |
---|
1000 | $output = null; |
---|
1001 | |
---|
1002 | $horaMinus = ($this->getHora()-1); |
---|
1003 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1004 | |
---|
1005 | $horaPlus = ($this->getHora()+1); |
---|
1006 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1007 | |
---|
1008 | $hora = $this->getHora(); |
---|
1009 | |
---|
1010 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPictox3.'.$horaMinus.'h+P_StatsUserPictox3.'.$hora.'h+P_StatsUserPictox3.'.$horaPlus.'h+P_StatsUserPictox3.'.$this->getDia().'+P_StatsUserPictox3.'.$this->getDia().') as count'); |
---|
1011 | $this->db->from('P_StatsUserPictox3'); |
---|
1012 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
1013 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
1014 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1015 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
1016 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1017 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
1018 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
1019 | $this->db->having('count >=', $minCount); |
---|
1020 | $this->db->order_by('count', 'desc'); |
---|
1021 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1022 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1023 | $query = $this->db->get(); |
---|
1024 | |
---|
1025 | if ($query->num_rows() > 0) { |
---|
1026 | $output = $query->result(); |
---|
1027 | foreach($output as $value) { |
---|
1028 | $value->count = $value->count*10; |
---|
1029 | } |
---|
1030 | } |
---|
1031 | return $output; |
---|
1032 | } |
---|
1033 | |
---|
1034 | private function getfreqUsuariX3Deep($inputid1, $inputid2, $minCount) { |
---|
1035 | $output = array(); |
---|
1036 | $output = null; |
---|
1037 | |
---|
1038 | $horaMinus = ($this->getHora()-1); |
---|
1039 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1040 | |
---|
1041 | $horaPlus = ($this->getHora()+1); |
---|
1042 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1043 | |
---|
1044 | $hora = $this->getHora(); |
---|
1045 | |
---|
1046 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPictox3.'.$horaMinus.'h+P_StatsUserPictox3.'.$hora.'h+P_StatsUserPictox3.'.$horaPlus.'h+P_StatsUserPictox3.'.$this->getDia().'+P_StatsUserPictox3.'.$this->getDia().') as count'); |
---|
1047 | $this->db->from('P_StatsUserPictox3'); |
---|
1048 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
1049 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
1050 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1051 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
1052 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1053 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
1054 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
1055 | $this->db->having('count >=', $minCount); |
---|
1056 | $this->db->order_by('count', 'desc'); |
---|
1057 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1058 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1059 | $this->db->limit(3); |
---|
1060 | $query = $this->db->get(); |
---|
1061 | |
---|
1062 | if ($query->num_rows() > 0) { |
---|
1063 | $output = $query->result(); |
---|
1064 | foreach($output as $value) { |
---|
1065 | $value->count = $value->count*10; |
---|
1066 | } |
---|
1067 | } |
---|
1068 | return $output; |
---|
1069 | } |
---|
1070 | |
---|
1071 | private function getfreqUsuariX2DeepNV($inputid1, $minCount) { |
---|
1072 | $output = array(); |
---|
1073 | $output = null; |
---|
1074 | |
---|
1075 | $horaMinus = ($this->getHora()-1); |
---|
1076 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1077 | |
---|
1078 | $horaPlus = ($this->getHora()+1); |
---|
1079 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1080 | |
---|
1081 | $hora = $this->getHora(); |
---|
1082 | |
---|
1083 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPictox2.'.$horaMinus.'h+P_StatsUserPictox2.'.$hora.'h+P_StatsUserPictox2.'.$horaPlus.'h+P_StatsUserPictox2.'.$this->getDia().'+P_StatsUserPictox2.'.$this->getDia().') as count'); |
---|
1084 | $this->db->from('P_StatsUserPictox2'); |
---|
1085 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
1086 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
1087 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1088 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
1089 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1090 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
1091 | $this->db->where('Pictograms.pictoType', 'verb'); |
---|
1092 | $this->db->having('count >=', $minCount); |
---|
1093 | $this->db->order_by('count', 'desc'); |
---|
1094 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1095 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1096 | $this->db->limit(3); |
---|
1097 | $query = $this->db->get(); |
---|
1098 | |
---|
1099 | if ($query->num_rows() > 0) { |
---|
1100 | $output = $query->result(); |
---|
1101 | foreach($output as $value) { |
---|
1102 | $value->count = $value->count*10; |
---|
1103 | } |
---|
1104 | } |
---|
1105 | return $output; |
---|
1106 | } |
---|
1107 | |
---|
1108 | private function getfreqUsuariX2Deep($inputid1, $minCount) { |
---|
1109 | $output = array(); |
---|
1110 | $output = null; |
---|
1111 | |
---|
1112 | $horaMinus = ($this->getHora()-1); |
---|
1113 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1114 | |
---|
1115 | $horaPlus = ($this->getHora()+1); |
---|
1116 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1117 | |
---|
1118 | $hora = $this->getHora(); |
---|
1119 | |
---|
1120 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPictox2.'.$horaMinus.'h+P_StatsUserPictox2.'.$hora.'h+P_StatsUserPictox2.'.$horaPlus.'h+P_StatsUserPictox2.'.$this->getDia().'+P_StatsUserPictox2.'.$this->getDia().') as count'); |
---|
1121 | $this->db->from('P_StatsUserPictox2'); |
---|
1122 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
1123 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
1124 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1125 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
1126 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1127 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
1128 | $this->db->having('count >=', $minCount); |
---|
1129 | $this->db->order_by('count', 'desc'); |
---|
1130 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1131 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1132 | $this->db->limit(3); |
---|
1133 | $query = $this->db->get(); |
---|
1134 | |
---|
1135 | if ($query->num_rows() > 0) { |
---|
1136 | $output = $query->result(); |
---|
1137 | foreach($output as $value) { |
---|
1138 | $value->count = $value->count*10; |
---|
1139 | } |
---|
1140 | } |
---|
1141 | return $output; |
---|
1142 | } |
---|
1143 | |
---|
1144 | private function getfreqUsuariX2NonExpanDeep($inputid1, $minCount) { |
---|
1145 | $output = array(); |
---|
1146 | $output = null; |
---|
1147 | |
---|
1148 | $horaMinus = ($this->getHora()-1); |
---|
1149 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1150 | |
---|
1151 | $horaPlus = ($this->getHora()+1); |
---|
1152 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1153 | |
---|
1154 | $hora = $this->getHora(); |
---|
1155 | |
---|
1156 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPictox2.'.$horaMinus.'h+P_StatsUserPictox2.'.$hora.'h+P_StatsUserPictox2.'.$horaPlus.'h+P_StatsUserPictox2.'.$this->getDia().'+P_StatsUserPictox2.'.$this->getDia().') as count'); |
---|
1157 | $this->db->from('P_StatsUserPictox2'); |
---|
1158 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox2.picto2id = PictogramsLanguage.pictoid', 'left'); |
---|
1159 | $this->db->join('Pictograms', 'P_StatsUserPictox2.picto2id = Pictograms.pictoid', 'left'); |
---|
1160 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1161 | $this->db->where('P_StatsUserPictox2.ID_PSUP2User', $this->session->userdata('idusu')); |
---|
1162 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1163 | $this->db->where('P_StatsUserPictox2.picto1id', $inputid1); |
---|
1164 | $this->db->having('count >=', $minCount); |
---|
1165 | $this->db->order_by('count', 'desc'); |
---|
1166 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1167 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1168 | $query = $this->db->get(); |
---|
1169 | |
---|
1170 | if ($query->num_rows() > 0) { |
---|
1171 | $output = $query->result(); |
---|
1172 | foreach($output as $value) { |
---|
1173 | $value->count = $value->count*10; |
---|
1174 | } |
---|
1175 | } |
---|
1176 | return $output; |
---|
1177 | } |
---|
1178 | |
---|
1179 | private function getfreqUsuariX1DeepNV($minCount) { |
---|
1180 | $output = array(); |
---|
1181 | $output = null; |
---|
1182 | |
---|
1183 | $horaMinus = ($this->getHora()-1); |
---|
1184 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1185 | |
---|
1186 | $horaPlus = ($this->getHora()+1); |
---|
1187 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1188 | |
---|
1189 | $hora = $this->getHora(); |
---|
1190 | |
---|
1191 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPicto.'.$horaMinus.'h+P_StatsUserPicto.'.$hora.'h+P_StatsUserPicto.'.$horaPlus.'h+P_StatsUserPicto.'.$this->getDia().'+P_StatsUserPicto.'.$this->getDia().') as count'); |
---|
1192 | $this->db->from('P_StatsUserPicto'); |
---|
1193 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
1194 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
1195 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1196 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
1197 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1198 | $this->db->where('Pictograms.pictoType !=', 'verb'); |
---|
1199 | $this->db->having('count >=', $minCount); |
---|
1200 | $this->db->order_by('count', 'desc'); |
---|
1201 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1202 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1203 | $query = $this->db->get(); |
---|
1204 | |
---|
1205 | if ($query->num_rows() > 0) { |
---|
1206 | $output = $query->result(); |
---|
1207 | foreach($output as $value) { |
---|
1208 | $value->count = $value->count*10; |
---|
1209 | } |
---|
1210 | } |
---|
1211 | |
---|
1212 | return $output; |
---|
1213 | } |
---|
1214 | |
---|
1215 | private function getfreqUsuariX1Deep($minCount) { |
---|
1216 | $output = array(); |
---|
1217 | $output = null; |
---|
1218 | |
---|
1219 | $horaMinus = ($this->getHora()-1); |
---|
1220 | if ($horaMinus < 0) $horaMinus += 24; |
---|
1221 | |
---|
1222 | $horaPlus = ($this->getHora()+1); |
---|
1223 | if ($horaPlus > 23) $horaPlus -= 24; |
---|
1224 | |
---|
1225 | $hora = $this->getHora(); |
---|
1226 | |
---|
1227 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, (P_StatsUserPicto.'.$horaMinus.'h+P_StatsUserPicto.'.$hora.'h+P_StatsUserPicto.'.$horaPlus.'h+P_StatsUserPicto.'.$this->getDia().'+P_StatsUserPicto.'.$this->getDia().') as count'); |
---|
1228 | $this->db->from('P_StatsUserPicto'); |
---|
1229 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
1230 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
1231 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1232 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
1233 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1234 | $this->db->having('count >=', $minCount); |
---|
1235 | $this->db->order_by('count', 'desc'); |
---|
1236 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1237 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1238 | $query = $this->db->get(); |
---|
1239 | |
---|
1240 | if ($query->num_rows() > 0) { |
---|
1241 | $output = $query->result(); |
---|
1242 | foreach($output as $value) { |
---|
1243 | $value->count = $value->count*10; |
---|
1244 | } |
---|
1245 | } |
---|
1246 | |
---|
1247 | return $output; |
---|
1248 | } |
---|
1249 | |
---|
1250 | private function getfreqUsuariX1() { |
---|
1251 | $output = array(); |
---|
1252 | $output = null; |
---|
1253 | |
---|
1254 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, P_StatsUserPicto.countx1 as count'); |
---|
1255 | $this->db->from('P_StatsUserPicto'); |
---|
1256 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
1257 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
1258 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1259 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
1260 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1261 | $this->db->order_by('count', 'desc'); |
---|
1262 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1263 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1264 | $query = $this->db->get(); |
---|
1265 | |
---|
1266 | if ($query->num_rows() > 0) { |
---|
1267 | $output = $query->result(); |
---|
1268 | } |
---|
1269 | return $output; |
---|
1270 | } |
---|
1271 | |
---|
1272 | private function getfreqUsuariX1NV() { |
---|
1273 | $output = array(); |
---|
1274 | $output = null; |
---|
1275 | |
---|
1276 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext, P_StatsUserPicto.countx1 as count'); |
---|
1277 | $this->db->from('P_StatsUserPicto'); |
---|
1278 | $this->db->join('PictogramsLanguage', 'P_StatsUserPicto.pictoid = PictogramsLanguage.pictoid', 'left'); |
---|
1279 | $this->db->join('Pictograms', 'P_StatsUserPicto.pictoid = Pictograms.pictoid', 'left'); |
---|
1280 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1281 | $this->db->where('P_StatsUserPicto.ID_PSUPUser', $this->session->userdata('idusu')); |
---|
1282 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1283 | $this->db->where('Pictograms.pictoType !=', 'verb'); |
---|
1284 | $this->db->order_by('count', 'desc'); |
---|
1285 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1286 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1287 | $query = $this->db->get(); |
---|
1288 | |
---|
1289 | if ($query->num_rows() > 0) { |
---|
1290 | $output = $query->result(); |
---|
1291 | } |
---|
1292 | return $output; |
---|
1293 | } |
---|
1294 | |
---|
1295 | private function getfreqUsuariX3($inputid1, $inputid2) { |
---|
1296 | $output = array(); |
---|
1297 | $output = null; |
---|
1298 | |
---|
1299 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
1300 | $this->db->from('P_StatsUserPictox3'); |
---|
1301 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
1302 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
1303 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1304 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
1305 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1306 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
1307 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
1308 | $this->db->order_by('countx3', 'desc'); |
---|
1309 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1310 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1311 | $this->db->limit(3); |
---|
1312 | $query = $this->db->get(); |
---|
1313 | |
---|
1314 | if ($query->num_rows() > 0) { |
---|
1315 | $output = $query->result(); |
---|
1316 | } |
---|
1317 | return $output; |
---|
1318 | } |
---|
1319 | |
---|
1320 | private function getfreqUsuariX3NonExpan($inputid1, $inputid2) { |
---|
1321 | $output = array(); |
---|
1322 | $output = null; |
---|
1323 | |
---|
1324 | $this->db->select('Pictograms.imgPicto, Pictograms.pictoid, PictogramsLanguage.pictotext'); |
---|
1325 | $this->db->from('P_StatsUserPictox3'); |
---|
1326 | $this->db->join('PictogramsLanguage', 'P_StatsUserPictox3.picto3id = PictogramsLanguage.pictoid', 'left'); |
---|
1327 | $this->db->join('Pictograms', 'P_StatsUserPictox3.picto3id = Pictograms.pictoid', 'left'); |
---|
1328 | $this->db->where_in('Pictograms.ID_PUser', array('1', $this->session->userdata('idusu'))); |
---|
1329 | $this->db->where('P_StatsUserPictox3.ID_PSUP3User', $this->session->userdata('idusu')); |
---|
1330 | $this->db->where('PictogramsLanguage.languageid', $this->session->userdata('ulanguage')); |
---|
1331 | $this->db->where('P_StatsUserPictox3.picto1id', $inputid1); |
---|
1332 | $this->db->where('P_StatsUserPictox3.picto2id', $inputid2); |
---|
1333 | $this->db->order_by('countx3', 'desc'); |
---|
1334 | $this->db->order_by('PictogramsLanguage.pictofreq', 'desc'); |
---|
1335 | $this->db->order_by('Pictograms.pictoid', 'random'); |
---|
1336 | $query = $this->db->get(); |
---|
1337 | |
---|
1338 | if ($query->num_rows() > 0) { |
---|
1339 | $output = $query->result(); |
---|
1340 | } |
---|
1341 | return $output; |
---|
1342 | } |
---|
1343 | |
---|
1344 | private function insertFloorVF($VF, $Prediction, $FSize) { |
---|
1345 | $k = 0; |
---|
1346 | foreach($Prediction as $value) { |
---|
1347 | if (sizeof($VF) == 0) { |
---|
1348 | $VF = array(); |
---|
1349 | $VF[] = $value; |
---|
1350 | } |
---|
1351 | |
---|
1352 | $repe = false; |
---|
1353 | $paraulesFrase = $this->getIdsElem(); |
---|
1354 | for ($i = 0; $i < sizeof($paraulesFrase); $i++) { |
---|
1355 | if ($value->pictoid == $paraulesFrase[$i]->pictoid) { |
---|
1356 | $repe = true; |
---|
1357 | break; |
---|
1358 | } |
---|
1359 | } |
---|
1360 | |
---|
1361 | if (!$repe) { |
---|
1362 | for ($i = 0; $i < sizeof($VF); $i++) { |
---|
1363 | if($k == floor($FSize/2) || $value->pictoid == $VF[$i]->pictoid) { break; } |
---|
1364 | else if ($value->pictoid != $VF[$i]->pictoid && $i+1 === sizeof($VF)) { |
---|
1365 | $VF[] = $value; |
---|
1366 | $k++; |
---|
1367 | } |
---|
1368 | } |
---|
1369 | } |
---|
1370 | } |
---|
1371 | return $VF; |
---|
1372 | } |
---|
1373 | |
---|
1374 | private function insertCeilVF($VF, $Prediction, $FSize) { |
---|
1375 | $k = 0; |
---|
1376 | foreach($Prediction as $value) { |
---|
1377 | $repe = false; |
---|
1378 | $paraulesFrase = $this->getIdsElem(); |
---|
1379 | for ($i = 0; $i < sizeof($paraulesFrase); $i++) { |
---|
1380 | if ($value->pictoid == $paraulesFrase[$i]->pictoid) { |
---|
1381 | $repe = true; |
---|
1382 | break; |
---|
1383 | } |
---|
1384 | } |
---|
1385 | |
---|
1386 | if (!$repe) { |
---|
1387 | if (sizeof($VF) == 0) { |
---|
1388 | $VF = array(); |
---|
1389 | array_push($VF,$value); |
---|
1390 | } |
---|
1391 | for ($i = 0; $i < sizeof($VF); $i++) { |
---|
1392 | if($k == ceil($FSize/2) || $value->pictoid == $VF[$i]->pictoid) { break; } |
---|
1393 | else if ($value->pictoid != $VF[$i]->pictoid && $i+1 === sizeof($VF)) { |
---|
1394 | array_push($VF,$value); |
---|
1395 | $k++; |
---|
1396 | } |
---|
1397 | } |
---|
1398 | } |
---|
1399 | } |
---|
1400 | return $VF; |
---|
1401 | } |
---|
1402 | |
---|
1403 | private function rellenaVFX2X3($VF, $Prediction, $TSize) { |
---|
1404 | foreach($Prediction as $value) { |
---|
1405 | $repe = false; |
---|
1406 | $paraulesFrase = $this->getIdsElem(); |
---|
1407 | for ($i = 0; $i < sizeof($paraulesFrase); $i++) { |
---|
1408 | if ($value->pictoid == $paraulesFrase[$i]->pictoid) { |
---|
1409 | $repe = true; |
---|
1410 | break; |
---|
1411 | } |
---|
1412 | } |
---|
1413 | |
---|
1414 | if (!$repe) { |
---|
1415 | if (sizeof($VF) == 0) { |
---|
1416 | $VF = array(); |
---|
1417 | array_push($VF,$value); |
---|
1418 | } |
---|
1419 | for ($i = 0; sizeof($VF) < $TSize && $i < sizeof($VF); $i++) { |
---|
1420 | if ($value->pictoid == $VF[$i]->pictoid) { break; } |
---|
1421 | else if ($value->pictoid != $VF[$i]->pictoid && $i+1 === sizeof($VF)) { |
---|
1422 | array_push($VF,$value); |
---|
1423 | } |
---|
1424 | } |
---|
1425 | } |
---|
1426 | } |
---|
1427 | return $VF; |
---|
1428 | } |
---|
1429 | |
---|
1430 | private function rellenaVFX1($VF, $Prediction, $TSize) { |
---|
1431 | foreach($Prediction as $value) { |
---|
1432 | |
---|
1433 | $repe = false; |
---|
1434 | $paraulesFrase = $this->getIdsElem(); |
---|
1435 | for ($i = 0; $i < sizeof($paraulesFrase); $i++) { |
---|
1436 | if ($value->pictoid == $paraulesFrase[$i]->pictoid) { |
---|
1437 | $repe = true; |
---|
1438 | break; |
---|
1439 | } |
---|
1440 | } |
---|
1441 | |
---|
1442 | if (!$repe) { |
---|
1443 | for ($i = 0; sizeof($VF) < $TSize && $i < sizeof($VF); $i++) { |
---|
1444 | if ($value->pictoid == $VF[$i]->pictoid) { break; } |
---|
1445 | else if ($value->pictoid != $VF[$i]->pictoid && $i+1 === sizeof($VF)) { |
---|
1446 | array_push($VF,$value); |
---|
1447 | } |
---|
1448 | } |
---|
1449 | } |
---|
1450 | } |
---|
1451 | return $VF; |
---|
1452 | } |
---|
1453 | |
---|
1454 | function getRecommenderX1() { |
---|
1455 | $pred = null; |
---|
1456 | if ($this->session->userdata('cfgExpansionOnOff')) $pred = $this->getRecommenderX1Expan(1); |
---|
1457 | else $pred = $this->getRecommenderX1NonExpan(); |
---|
1458 | return $pred; |
---|
1459 | } |
---|
1460 | |
---|
1461 | function getRecommenderX2() { |
---|
1462 | $pred = null; |
---|
1463 | if ($this->session->userdata('cfgExpansionOnOff')) $pred = $this->getRecommenderX2Expan(); |
---|
1464 | else $pred = $this->getRecommenderX2NonExpan(); |
---|
1465 | return $pred; |
---|
1466 | } |
---|
1467 | |
---|
1468 | function getRecommenderX3() { |
---|
1469 | $pred = null; |
---|
1470 | if ($this->session->userdata('cfgExpansionOnOff')) $pred = $this->getRecommenderX3Expan(); |
---|
1471 | else $pred = $this->getRecommenderX3NonExpan(); |
---|
1472 | return $pred; |
---|
1473 | } |
---|
1474 | |
---|
1475 | function getcountElem(){ |
---|
1476 | $output = 0; |
---|
1477 | $this->db->where('ID_RSTPUser', $this->session->userdata('idusu')); |
---|
1478 | $query = $this->db->get('R_S_TempPictograms'); |
---|
1479 | |
---|
1480 | if ($query->num_rows() > 0) { |
---|
1481 | $output = $query->num_rows(); |
---|
1482 | } |
---|
1483 | return $output; |
---|
1484 | } |
---|
1485 | |
---|
1486 | private function getRecommenderX1Expan($primera) { |
---|
1487 | $TSize = $this->session->userdata('cfgPredBarNumPred'); |
---|
1488 | |
---|
1489 | // Algorisme V5 - Predictor inicial (cas 00 no hi ha res (fix jo i tu) |
---|
1490 | $VF = $this->getSubj(); |
---|
1491 | if (!$primera) { |
---|
1492 | unset($VF[0]); |
---|
1493 | unset($VF[1]); |
---|
1494 | } |
---|
1495 | |
---|
1496 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
1497 | $contextTypeName2Days = $this->getContextType2Days('name'); |
---|
1498 | $k = 0; |
---|
1499 | foreach($contextTypeName2Days as $value) { |
---|
1500 | for ($i = 0; $i < sizeof($VF); $i++) { |
---|
1501 | if($k == ceil(($TSize-2)/2) || $value->pictoid == $VF[$i]->pictoid) { break; } |
---|
1502 | else if ($value->pictoid != $VF[$i]->pictoid && $i+1 === sizeof($VF)) { |
---|
1503 | array_push($VF,$value); |
---|
1504 | $k++; |
---|
1505 | } |
---|
1506 | } |
---|
1507 | } |
---|
1508 | |
---|
1509 | // Algorisme V2 - Predictor freqüència II (d'usuari) |
---|
1510 | $contextTypeNamesAll = $this->getContextTypeAll('name'); |
---|
1511 | $contextTypeNamesAllDeep = $this->getContextTypeAllDeep('name', round(($this->SUMcount()[0]->count-sizeof($contextTypeNamesAll))*0.01)); |
---|
1512 | if (empty($contextTypeNamesAllDeep)) $freqTotal = $contextTypeNamesAll; |
---|
1513 | else { |
---|
1514 | $freqTemp = array_merge($contextTypeNamesAllDeep, $contextTypeNamesAll); |
---|
1515 | usort($freqTemp, function ($a, $b) { |
---|
1516 | if ($a->repes == $b->repes) return 0; |
---|
1517 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1518 | }); |
---|
1519 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1520 | } |
---|
1521 | $k = 0; |
---|
1522 | foreach($freqTotal as $value) { |
---|
1523 | for ($i = 0; $i < sizeof($VF); $i++) { |
---|
1524 | if($k == floor(($TSize-2)/2) || $value->pictoid == $VF[$i]->pictoid) { break; } |
---|
1525 | else if ($value->pictoid != $VF[$i]->pictoid && $i+1 === sizeof($VF)) { |
---|
1526 | array_push($VF,$value); |
---|
1527 | $k++; |
---|
1528 | } |
---|
1529 | } |
---|
1530 | } |
---|
1531 | // rellena |
---|
1532 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX1($VF, $contextTypeName2Days, $TSize); |
---|
1533 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX1($VF, $freqTotal, $TSize); |
---|
1534 | // rellena - Algorisme V6 - Predictor de context (name) total |
---|
1535 | if (sizeof($VF) < $TSize) { |
---|
1536 | $freqUsuari = $this->getfreqUsuariX1(); |
---|
1537 | $freqUsuariDeep = $this->getfreqUsuariX1Deep(round(($this->SUMcount()[0]->count-sizeof($freqUsuari))*0.01)); |
---|
1538 | if (empty($freqUsuariDeep)) $freqTotal = $freqUsuari; |
---|
1539 | else { |
---|
1540 | $freqTemp = array_merge($freqUsuariDeep, $freqUsuari); |
---|
1541 | usort($freqTemp, function ($a, $b) { |
---|
1542 | if ($a->count == $b->count) return 0; |
---|
1543 | else return ($a->count < $b->count) ? 1 : -1; |
---|
1544 | }); |
---|
1545 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1546 | } |
---|
1547 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
1548 | } |
---|
1549 | return $VF; |
---|
1550 | } |
---|
1551 | |
---|
1552 | private function getRecommenderX1NonExpan() { |
---|
1553 | $TSize = $this->session->userdata('cfgPredBarNumPred'); |
---|
1554 | |
---|
1555 | // Algorisme V5 - Predictor inicial (cas 00 no hi ha res (fix jo i tu) |
---|
1556 | $VF = $this->getSubj(); |
---|
1557 | |
---|
1558 | // Algorisme V2 - Predictor freqüència II (d'usuari) |
---|
1559 | $freqUsuari = $this->getfreqUsuariX1(); |
---|
1560 | $freqUsuariDeep = $this->getfreqUsuariX1Deep(round(($this->SUMcount()[0]->count-sizeof($freqUsuari))*0.01)); |
---|
1561 | if (empty($freqUsuariDeep)) $freqTotal = $freqUsuari; |
---|
1562 | else { |
---|
1563 | $freqTemp = array_merge($freqUsuariDeep, $freqUsuari); |
---|
1564 | usort($freqTemp, function ($a, $b) { |
---|
1565 | if ($a->count == $b->count) return 0; |
---|
1566 | else return ($a->count < $b->count) ? 1 : -1; |
---|
1567 | }); |
---|
1568 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1569 | } |
---|
1570 | $VF = $this->rellenaVFX1($VF, $freqTotal, $TSize); |
---|
1571 | |
---|
1572 | return $VF; |
---|
1573 | } |
---|
1574 | |
---|
1575 | private function getRecommenderX2Expan() { |
---|
1576 | $paraulesFrase = $this->getIdsElem(); |
---|
1577 | $inputid1 = $paraulesFrase[sizeof($paraulesFrase)-1]->pictoid; |
---|
1578 | $inputType = $this->getTypesElem($inputid1); |
---|
1579 | |
---|
1580 | // Algorisme V2 - Predictor freqüència II (d'usuari) |
---|
1581 | $VF = array(); |
---|
1582 | $freqUsuari = $this->getfreqUsuariX2($inputid1); |
---|
1583 | $freqUsuariDeep = $this->getfreqUsuariX2Deep($inputid1, round(($this->SUMcount()[0]->count-sizeof($freqUsuari))*0.01)); |
---|
1584 | if (empty($freqUsuariDeep)) $freqTotal = $freqUsuari; |
---|
1585 | else { |
---|
1586 | $freqTemp = array_merge($freqUsuariDeep, $freqUsuari); |
---|
1587 | usort($freqTemp, function ($a, $b) { |
---|
1588 | if ($a->count == $b->count) |
---|
1589 | return 0; |
---|
1590 | else |
---|
1591 | return ($a->count < $b->count) ? 1 : -1; |
---|
1592 | }); |
---|
1593 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1594 | } |
---|
1595 | $VF = array_merge($VF, $freqTotal); |
---|
1596 | $TSize = $this->session->userdata('cfgPredBarNumPred'); |
---|
1597 | $FSize = $TSize - sizeof($VF); |
---|
1598 | |
---|
1599 | if ($inputType[0]->pictoType == 'name') { |
---|
1600 | // Algorisme V6 - Predictor de context (verb) últims 2 dies |
---|
1601 | $contextTypeVerb2Day = $this->getContextType2Days('verb'); |
---|
1602 | $VF = $this->insertFloorVF($VF, $contextTypeVerb2Day, $FSize); |
---|
1603 | |
---|
1604 | // Algorisme V6 - Predictor de context (verb) total |
---|
1605 | $contextTypeVerbsAll = $this->getContextTypeAll('verb'); |
---|
1606 | $contextTypeVerbsAllDeep = $this->getContextTypeAllDeep('verb', round(($this->SUMcount()[0]->count-sizeof($contextTypeVerbsAll))*0.01)); |
---|
1607 | if (empty($contextTypeVerbsAllDeep)) $freqTotal = $contextTypeVerbsAll; |
---|
1608 | else { |
---|
1609 | $freqTemp = array_merge($contextTypeVerbsAllDeep, $contextTypeVerbsAll); |
---|
1610 | usort($freqTemp, function ($a, $b) { |
---|
1611 | if ($a->repes == $b->repes) return 0; |
---|
1612 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1613 | }); |
---|
1614 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1615 | } |
---|
1616 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
1617 | |
---|
1618 | // rellena |
---|
1619 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerbAll, $TSize); |
---|
1620 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerb2Day, $TSize); |
---|
1621 | } |
---|
1622 | else if ($inputType[0]->pictoType == 'verb') { |
---|
1623 | $caseList = array("theme", "manera", "locat", "locto", "locfrom", "time", "tool", "acomp"); |
---|
1624 | foreach ($caseList as $case) { |
---|
1625 | if ($case == "time" || $case == "tool" || $case == "locat" || $case == "acomp") { |
---|
1626 | if (sizeof($VF) < $TSize && $this->get1Opt($inputid1, $case)[0]->$case == 1) $VF = $this->get1OptFitsX2($inputid1, $case, $VF, $TSize, $case); |
---|
1627 | } |
---|
1628 | else { |
---|
1629 | if (sizeof($VF) < $TSize) { |
---|
1630 | $fits = $this->get1OptFits($inputid1, $case, 1); |
---|
1631 | $VF = $this->get1OptFitsX2($inputid1, $case, $VF, $TSize, $fits); |
---|
1632 | } |
---|
1633 | } |
---|
1634 | } |
---|
1635 | foreach ($caseList as $case) { |
---|
1636 | if ($case == "time" || $case == "tool" || $case == "locat" || $case == "acomp") { |
---|
1637 | if (sizeof($VF) < $TSize && $this->get1Opt($inputid1, $case)[0]->$case == 'opt') { |
---|
1638 | $VF = $this->get1OptFitsX2($inputid1, $case, $VF, $TSize, $case); |
---|
1639 | } |
---|
1640 | } |
---|
1641 | else { |
---|
1642 | if (sizeof($VF) < $TSize) { |
---|
1643 | $fits = $this->get1OptFits($inputid1, $case, 'opt'); |
---|
1644 | $VF = $this->get1OptFitsX2($inputid1, $case, $VF, $TSize, $fits); |
---|
1645 | } |
---|
1646 | } |
---|
1647 | } |
---|
1648 | } |
---|
1649 | else if ($inputType[0]->pictoType == 'modifier' && $this->boolDetPos($inputid1)) { |
---|
1650 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
1651 | $contextTypeName2Days = $this->getContextType2Days('name'); |
---|
1652 | $VF = $this->insertCeilVF($VF, $contextTypeName2Days, $FSize); |
---|
1653 | |
---|
1654 | // Algorisme V6 - Predictor de context (name) total |
---|
1655 | $contextTypeNamesAll = $this->getContextTypeAll('name'); |
---|
1656 | $contextTypeNamesAllDeep = $this->getContextTypeAllDeep('name', round(($this->SUMcount()[0]->count-sizeof($contextTypeNamesAll))*0.01)); |
---|
1657 | if (empty($contextTypeNamesAllDeep)) $freqTotal = $contextTypeNamesAll; |
---|
1658 | else { |
---|
1659 | $freqTemp = array_merge($contextTypeNamesAllDeep, $contextTypeNamesAll); |
---|
1660 | usort($freqTemp, function ($a, $b) { |
---|
1661 | if ($a->repes == $b->repes) return 0; |
---|
1662 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1663 | }); |
---|
1664 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1665 | } |
---|
1666 | $VF = $this->insertFloorVF($VF, $freqTotal, $FSize); |
---|
1667 | |
---|
1668 | // rellena |
---|
1669 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeName2Days, $TSize); |
---|
1670 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
1671 | } |
---|
1672 | else { |
---|
1673 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
1674 | $contextTypeName2Days = $this->getContextType2Days('name'); |
---|
1675 | $VF = $this->insertCeilVF($VF, $contextTypeName2Days, $FSize); |
---|
1676 | |
---|
1677 | // Algorisme V6 - Predictor de context (verb) total |
---|
1678 | $contextTypeVerbsAll = $this->getContextTypeAll('verb'); |
---|
1679 | $contextTypeVerbsAllDeep = $this->getContextTypeAllDeep('verb', round(($this->SUMcount()[0]->count-sizeof($contextTypeVerbsAll))*0.01)); |
---|
1680 | if (empty($contextTypeVerbsAllDeep)) $freqTotal = $contextTypeVerbsAll; |
---|
1681 | else { |
---|
1682 | $freqTemp = array_merge($contextTypeVerbsAllDeep, $contextTypeVerbsAll); |
---|
1683 | usort($freqTemp, function ($a, $b) { |
---|
1684 | if ($a->repes == $b->repes) return 0; |
---|
1685 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1686 | }); |
---|
1687 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1688 | } |
---|
1689 | $VF = $this->insertFloorVF($VF, $freqTotal, $FSize); |
---|
1690 | |
---|
1691 | // rellena |
---|
1692 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeName2Days, $TSize); |
---|
1693 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerbsAll, $TSize); |
---|
1694 | } |
---|
1695 | |
---|
1696 | // rellena |
---|
1697 | if (sizeof($VF) < $TSize) { |
---|
1698 | $freqX1 = $this->getRecommenderX1(); |
---|
1699 | unset($freqX1[0]); |
---|
1700 | unset($freqX1[1]); |
---|
1701 | $VF = $this->rellenaVFX2X3($VF, $freqX1, $TSize); |
---|
1702 | } |
---|
1703 | |
---|
1704 | // Algorisme V6 - Predictor de context (name) total |
---|
1705 | if (sizeof($VF) < $TSize) { |
---|
1706 | $contextTypeNamesAll = $this->getContextTypeAll('name'); |
---|
1707 | $contextTypeNamesAllDeep = $this->getContextTypeAllDeep('name', round(($this->SUMcount()[0]->count-sizeof($contextTypeNamesAll))*0.01)); |
---|
1708 | if (empty($contextTypeNamesAllDeep)) $freqTotal = $contextTypeNamesAll; |
---|
1709 | else { |
---|
1710 | $freqTemp = array_merge($contextTypeNamesAllDeep, $contextTypeNamesAll); |
---|
1711 | usort($freqTemp, function ($a, $b) { |
---|
1712 | if ($a->repes == $b->repes) return 0; |
---|
1713 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1714 | }); |
---|
1715 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1716 | } |
---|
1717 | $VF = $this->rellenaVFX1($VF, $freqTotal, $TSize); |
---|
1718 | } |
---|
1719 | return $VF; |
---|
1720 | } |
---|
1721 | |
---|
1722 | private function getRecommenderX2NonExpan() { |
---|
1723 | |
---|
1724 | $paraulesFrase = $this->getIdsElem(); |
---|
1725 | $inputid1 = $paraulesFrase[sizeof($paraulesFrase)-1]->pictoid; |
---|
1726 | |
---|
1727 | // Algorisme V2 - Predictor freqüència II (d'usuari) |
---|
1728 | $VF = array(); |
---|
1729 | $freqUsuari = $this->getfreqUsuariX2NonExpan($inputid1); |
---|
1730 | $freqUsuariDeep = $this->getfreqUsuariX2NonExpanDeep($inputid1, round(($this->SUMcount()[0]->count-sizeof($freqUsuari))*0.01)); |
---|
1731 | if (empty($freqUsuariDeep)) $freqTotal = $freqUsuari; |
---|
1732 | else { |
---|
1733 | $freqTemp = array_merge($freqUsuariDeep, $freqUsuari); |
---|
1734 | usort($freqTemp, function ($a, $b) { |
---|
1735 | if ($a->count == $b->count) return 0; |
---|
1736 | else return ($a->count < $b->count) ? 1 : -1; |
---|
1737 | }); |
---|
1738 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1739 | } |
---|
1740 | $VF = array_merge($VF,$freqTotal); |
---|
1741 | $TSize = $this->session->userdata('cfgPredBarNumPred'); |
---|
1742 | |
---|
1743 | // rellena |
---|
1744 | if (sizeof($VF) < $TSize) { |
---|
1745 | $freqX1 = $this->getfreqUsuariX1(); |
---|
1746 | unset($freqX1[0]); |
---|
1747 | unset($freqX1[1]); |
---|
1748 | $freqUsuariDeep = $this->getfreqUsuariX1Deep(round(($this->SUMcount()[0]->count-sizeof($freqX1))*0.01)); |
---|
1749 | if (empty($freqUsuariDeep)) $freqTotal = $freqX1; |
---|
1750 | else { |
---|
1751 | $freqTemp = array_merge($freqUsuariDeep, $freqX1); |
---|
1752 | usort($freqTemp, function ($a, $b) { |
---|
1753 | if ($a->count == $b->count) return 0; |
---|
1754 | else return ($a->count < $b->count) ? 1 : -1; |
---|
1755 | }); |
---|
1756 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1757 | } |
---|
1758 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
1759 | } |
---|
1760 | |
---|
1761 | return $VF; |
---|
1762 | } |
---|
1763 | |
---|
1764 | private function getRecommenderX3Expan() { |
---|
1765 | $paraulesFrase = $this->getIdsElem(); |
---|
1766 | $inputid1 = $paraulesFrase[sizeof($paraulesFrase)-2]->pictoid; |
---|
1767 | $inputid2 = $paraulesFrase[sizeof($paraulesFrase)-1]->pictoid; |
---|
1768 | |
---|
1769 | $inputType1 = $this->getTypesElem($inputid1); |
---|
1770 | $inputType2 = $this->getTypesElem($inputid2); |
---|
1771 | |
---|
1772 | $verb = false; |
---|
1773 | for ($i = sizeof($paraulesFrase); $i > 0; $i--) { |
---|
1774 | if ($this->getTypesElem($paraulesFrase[$i-1]->pictoid)[0]->pictoType == 'verb') |
---|
1775 | { |
---|
1776 | $verb = true; |
---|
1777 | break; |
---|
1778 | } |
---|
1779 | } |
---|
1780 | |
---|
1781 | // Algorisme V2 - Predictor freqüència II (d'usuari) |
---|
1782 | $VF = array(); |
---|
1783 | $freqUsuari = $this->getfreqUsuariX3($inputid1, $inputid2); |
---|
1784 | $freqUsuariDeep = $this->getfreqUsuariX3Deep($inputid1, $inputid2, round(($this->SUMcount()[0]->count-sizeof($freqUsuari))*0.01)); |
---|
1785 | if (empty($freqUsuariDeep)) $freqTotal = $freqUsuari; |
---|
1786 | else { |
---|
1787 | $freqTemp = array_merge($freqUsuariDeep, $freqUsuari); |
---|
1788 | usort($freqTemp, function ($a, $b) { |
---|
1789 | if ($a->count == $b->count) |
---|
1790 | return 0; |
---|
1791 | else |
---|
1792 | return ($a->count < $b->count) ? 1 : -1; |
---|
1793 | }); |
---|
1794 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1795 | } |
---|
1796 | $VF = array_merge($VF,$freqTotal); |
---|
1797 | // rellena 1ra mitad |
---|
1798 | if (sizeof($VF) < 3) { |
---|
1799 | $freqX2 = $this->getfreqUsuariX2($inputid2); |
---|
1800 | if ($verb) { |
---|
1801 | $freqX2 = $this->getfreqUsuariX2NV($inputid2); |
---|
1802 | $freqUsuariDeep = $this->getfreqUsuariX2DeepNV($inputid2, round(($this->SUMcount()[0]->count-sizeof($freqX2))*0.01)); |
---|
1803 | } |
---|
1804 | else { |
---|
1805 | $freqX2 = $this->getfreqUsuariX2($inputid2); |
---|
1806 | $freqUsuariDeep = $this->getfreqUsuariX2Deep($inputid2, round(($this->SUMcount()[0]->count-sizeof($freqX2))*0.01)); |
---|
1807 | } |
---|
1808 | if (empty($freqUsuariDeep)) $freqTotal = $freqX2; |
---|
1809 | else { |
---|
1810 | $freqTemp = array_merge($freqUsuariDeep, $freqX2); |
---|
1811 | usort($freqTemp, function ($a, $b) { |
---|
1812 | if ($a->count == $b->count) |
---|
1813 | return 0; |
---|
1814 | else |
---|
1815 | return ($a->count < $b->count) ? 1 : -1; |
---|
1816 | }); |
---|
1817 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1818 | } |
---|
1819 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, 3); |
---|
1820 | } |
---|
1821 | // rellena 1ra mitad |
---|
1822 | if (sizeof($VF) < 3) { |
---|
1823 | if ($verb) { |
---|
1824 | $freqX1 = $this->getfreqUsuariX1NV(); |
---|
1825 | $freqUsuariDeep = $this->getfreqUsuariX1DeepNV(round(($this->SUMcount()[0]->count-sizeof($freqX1))*0.01)); |
---|
1826 | } |
---|
1827 | else { |
---|
1828 | $freqX1 = $this->getfreqUsuariX1(); |
---|
1829 | $freqUsuariDeep = $this->getfreqUsuariX1Deep(round(($this->SUMcount()[0]->count-sizeof($freqX1))*0.01)); |
---|
1830 | } |
---|
1831 | if (empty($freqUsuariDeep)) $freqTotal = $freqX1; |
---|
1832 | else { |
---|
1833 | $freqTemp = array_merge($freqUsuariDeep, $freqX1); |
---|
1834 | usort($freqTemp, function ($a, $b) { |
---|
1835 | if ($a->count == $b->count) return 0; |
---|
1836 | else return ($a->count < $b->count) ? 1 : -1; |
---|
1837 | }); |
---|
1838 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1839 | } |
---|
1840 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, 3); |
---|
1841 | } |
---|
1842 | |
---|
1843 | $TSize = $this->session->userdata('cfgPredBarNumPred'); |
---|
1844 | $FSize = $TSize - sizeof($VF); |
---|
1845 | |
---|
1846 | if ($inputType2[0]->pictoType == 'modifier' && $this->boolDetPos($inputid2)) { |
---|
1847 | |
---|
1848 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
1849 | $contextTypeName2Days = $this->getContextType2Days('name'); |
---|
1850 | $VF = $this->insertCeilVF($VF, $contextTypeName2Days, $FSize); |
---|
1851 | |
---|
1852 | // Algorisme V6 - Predictor de context (name) total |
---|
1853 | $contextTypeNamesAll = $this->getContextTypeAll('name'); |
---|
1854 | $contextTypeNamesAllDeep = $this->getContextTypeAllDeep('name', round(($this->SUMcount()[0]->count-sizeof($contextTypeNamesAll))*0.01)); |
---|
1855 | if (empty($contextTypeNamesAllDeep)) $freqTotal = $contextTypeNamesAll; |
---|
1856 | else { |
---|
1857 | $freqTemp = array_merge($contextTypeNamesAllDeep, $contextTypeNamesAll); |
---|
1858 | usort($freqTemp, function ($a, $b) { |
---|
1859 | if ($a->repes == $b->repes) return 0; |
---|
1860 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1861 | }); |
---|
1862 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1863 | } |
---|
1864 | $VF = $this->insertFloorVF($VF, $freqTemp, $FSize); |
---|
1865 | |
---|
1866 | // rellena |
---|
1867 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeName2Days, $TSize); |
---|
1868 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
1869 | } |
---|
1870 | else if (!$verb && ($inputType1[0]->pictoType == 'name' || $inputType2[0]->pictoType == 'name')) { |
---|
1871 | // Algorisme V6 - Predictor de context (verb) últims 2 dies |
---|
1872 | $contextTypeVerbs2Days = $this->getContextType2Days('verb'); |
---|
1873 | $VF = $this->insertCeilVF($VF, $contextTypeVerbs2Days, $FSize); |
---|
1874 | |
---|
1875 | // Algorisme V6 - Predictor de context (verb) total |
---|
1876 | $contextTypeVerbsAll = $this->getContextTypeAll('verb'); |
---|
1877 | $contextTypeVerbsAllDeep = $this->getContextTypeAllDeep('verb', round(($this->SUMcount()[0]->count-sizeof($contextTypeVerbsAll))*0.01)); |
---|
1878 | if (empty($contextTypeVerbsAllDeep)) $freqTotal = $contextTypeVerbsAll; |
---|
1879 | else { |
---|
1880 | $freqTemp = array_merge($contextTypeNamesAllDeep, $contextTypeVerbsAll); |
---|
1881 | usort($freqTemp, function ($a, $b) { |
---|
1882 | if ($a->repes == $b->repes) return 0; |
---|
1883 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1884 | }); |
---|
1885 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1886 | } |
---|
1887 | $VF = $this->insertFloorVF($VF, $freqTotal, $FSize); |
---|
1888 | |
---|
1889 | // rellena |
---|
1890 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerbs2Days, $TSize); |
---|
1891 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerbsAll, $TSize); |
---|
1892 | |
---|
1893 | if (sizeof($VF) < $TSize) { |
---|
1894 | $freqX2 = $this->getRecommenderX2(); |
---|
1895 | $VF = $this->rellenaVFX2X3($VF, $freqX2, $TSize); |
---|
1896 | } |
---|
1897 | } |
---|
1898 | else if (!$verb && $inputType2[0]->pictoType != 'name') { |
---|
1899 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
1900 | $contextTypeName2Days = $this->getContextType2Days('name'); |
---|
1901 | $VF = $this->insertCeilVF($VF, $contextTypeName2Days, $FSize); |
---|
1902 | |
---|
1903 | // Algorisme V6 - Predictor de context (verb) total |
---|
1904 | $contextTypeVerbsAll = $this->getContextTypeAll('verb'); |
---|
1905 | $contextTypeVerbsAllDeep = $this->getContextTypeAllDeep('verb', round(($this->SUMcount()[0]->count-sizeof($contextTypeVerbsAll))*0.01)); |
---|
1906 | if (empty($contextTypeVerbsAllDeep)) $freqTotal = $contextTypeVerbsAll; |
---|
1907 | else { |
---|
1908 | $freqTemp = array_merge($contextTypeVerbsAllDeep, $contextTypeVerbsAll); |
---|
1909 | usort($freqTemp, function ($a, $b) { |
---|
1910 | if ($a->repes == $b->repes) return 0; |
---|
1911 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
1912 | }); |
---|
1913 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
1914 | } |
---|
1915 | $VF = $this->insertFloorVF($VF, $freqTotal, $FSize); |
---|
1916 | |
---|
1917 | // rellena |
---|
1918 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeName2Days, $TSize); |
---|
1919 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerbsAll, $TSize); |
---|
1920 | } |
---|
1921 | else { // ni name ni verb |
---|
1922 | if ($verb) { |
---|
1923 | $caseList = array("theme", "manera", "locat", "locto", "locfrom", "tool", "acomp"); |
---|
1924 | for ($j = sizeof($paraulesFrase); $j > 0; $j--) { |
---|
1925 | if ($this->getTypesElem($paraulesFrase[$j-1]->pictoid)[0]->pictoType == 'verb') { |
---|
1926 | $inputid1 = $paraulesFrase[$j-1]->pictoid; |
---|
1927 | foreach ($caseList as $case) { |
---|
1928 | if ($case == "time" || $case == "tool" || $case == "locat" || $case == "acomp") { |
---|
1929 | if (sizeof($VF) < $TSize && $this->get1Opt($inputid1, $case)[0]->$case == 1) { |
---|
1930 | $repe = false; |
---|
1931 | for ($k = sizeof($paraulesFrase); $k > 0; $k--) { |
---|
1932 | $inputid2 = $paraulesFrase[$k-1]->pictoid; |
---|
1933 | if (($case == 'time' || $case == 'tool') && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == $case) { |
---|
1934 | $repe = true; |
---|
1935 | break; |
---|
1936 | } |
---|
1937 | else if ($case == 'locat' && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == 'lloc') { |
---|
1938 | $repe = true; |
---|
1939 | break; |
---|
1940 | } |
---|
1941 | else if ($case == 'acomp' && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == 'human' && $inputid2 != 444) { |
---|
1942 | $repe = true; |
---|
1943 | break; |
---|
1944 | } |
---|
1945 | } |
---|
1946 | if ($repe) continue; |
---|
1947 | $VF = $this->get1OptFitsX3($inputid1, $inputid2, $case, $VF, $TSize, $case, $inputid1); |
---|
1948 | } |
---|
1949 | } |
---|
1950 | else { |
---|
1951 | if (sizeof($VF) < $TSize) { |
---|
1952 | $fits = $this->get1OptFits($inputid1, $case, 1); |
---|
1953 | $repe = false; |
---|
1954 | for ($w = sizeof($paraulesFrase); $w > 0; $w--) { |
---|
1955 | $inputid2 = $paraulesFrase[$w-1]->pictoid; |
---|
1956 | if ($case == 'theme' && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == $fits[0]) { |
---|
1957 | $repe = true; |
---|
1958 | break; |
---|
1959 | } |
---|
1960 | if ($case == 'manera' && $this->getTypesElem($inputid2)[0]->pictoType == 'adv' && $this->getAdvType($inputid2)[0]->class == $fits) { |
---|
1961 | $repe = true; |
---|
1962 | break; |
---|
1963 | } |
---|
1964 | else if (($case == 'locto' || $case == 'locfrom') && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == $fits) { |
---|
1965 | $repe = true; |
---|
1966 | break; |
---|
1967 | } |
---|
1968 | } |
---|
1969 | if ($repe) continue; |
---|
1970 | $VF = $this->get1OptFitsX3($inputid1, $inputid2, $case, $VF, $TSize, $fits, $inputid1); |
---|
1971 | } |
---|
1972 | } |
---|
1973 | } |
---|
1974 | foreach ($caseList as $case) { |
---|
1975 | if ($case == "time" || $case == "tool" || $case == "locat" || $case == "acomp") { |
---|
1976 | if (sizeof($VF) < $TSize && $this->get1Opt($inputid1, $case)[0]->$case == 'opt') { |
---|
1977 | $repe = false; |
---|
1978 | for ($k = sizeof($paraulesFrase); $k > 0; $k--) { |
---|
1979 | $inputid2 = $paraulesFrase[$k-1]->pictoid; |
---|
1980 | if (($case == 'time' || $case == 'tool') && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == $case) { |
---|
1981 | $repe = true; |
---|
1982 | break; |
---|
1983 | } |
---|
1984 | else if ($case == 'locat' && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == 'lloc') { |
---|
1985 | $repe = true; |
---|
1986 | break; |
---|
1987 | } |
---|
1988 | else if ($case == 'acomp' && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == 'human' && $inputid2 != 444) { |
---|
1989 | $repe = true; |
---|
1990 | break; |
---|
1991 | } |
---|
1992 | } |
---|
1993 | if ($repe) continue; |
---|
1994 | $VF = $this->get1OptFitsX3($inputid1, $inputid2, $case, $VF, $TSize, $case, $inputid1); |
---|
1995 | } |
---|
1996 | } |
---|
1997 | else { |
---|
1998 | if (sizeof($VF) < $TSize) { |
---|
1999 | $fits = $this->get1OptFits($inputid1, $case, 'opt'); |
---|
2000 | $repe = false; |
---|
2001 | for ($w = sizeof($paraulesFrase); $w > 0; $w--) { |
---|
2002 | $inputid2 = $paraulesFrase[$w-1]->pictoid; |
---|
2003 | if ($case == 'theme' && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == $fits[0]) { |
---|
2004 | $repe = true; |
---|
2005 | break; |
---|
2006 | } |
---|
2007 | if ($case == 'manera' && $this->getTypesElem($inputid2)[0]->pictoType == 'adv' && $this->getAdvType($inputid2)[0]->class == $fits) { |
---|
2008 | $repe = true; |
---|
2009 | break; |
---|
2010 | } |
---|
2011 | else if (($case == 'locto' || $case == 'locfrom') && $this->getTypesElem($inputid2)[0]->pictoType == 'name' && $this->getNameClass($inputid2)[0]->class == $fits) { |
---|
2012 | $repe = true; |
---|
2013 | break; |
---|
2014 | } |
---|
2015 | } |
---|
2016 | if ($repe) continue; |
---|
2017 | $VF = $this->get1OptFitsX3($inputid1, $inputid2, $case, $VF, $TSize, $fits, $inputid1); |
---|
2018 | } |
---|
2019 | } |
---|
2020 | } |
---|
2021 | } |
---|
2022 | } |
---|
2023 | } |
---|
2024 | else { |
---|
2025 | // Algorisme V6 - Predictor de context (name) últims 2 dies |
---|
2026 | $contextTypeName2Days = $this->getContextType2Days('name'); |
---|
2027 | $VF = $this->insertCeilVF($VF, $contextTypeName2Days, $FSize); |
---|
2028 | |
---|
2029 | // Algorisme V6 - Predictor de context (verb) total |
---|
2030 | $contextTypeVerbsAll = $this->getContextTypeAll('verb'); |
---|
2031 | $contextTypeVerbsAllDeep = $this->getContextTypeAllDeep('verb', round(($this->SUMcount()[0]->count-sizeof($contextTypeVerbsAll))*0.01)); |
---|
2032 | if (empty($contextTypeVerbsAllDeep)) $freqTotal = $contextTypeVerbsAll; |
---|
2033 | else { |
---|
2034 | $freqTemp = array_merge($contextTypeVerbsAllDeep, $contextTypeVerbsAll); |
---|
2035 | usort($freqTemp, function ($a, $b) { |
---|
2036 | if ($a->repes == $b->repes) return 0; |
---|
2037 | else return ($a->repes < $b->repes) ? 1 : -1; |
---|
2038 | }); |
---|
2039 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
2040 | } |
---|
2041 | $VF = $this->insertFloorVF($VF, $freqTotal, $FSize); |
---|
2042 | |
---|
2043 | // rellena |
---|
2044 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeName2Days, $TSize); |
---|
2045 | if (sizeof($VF) < $TSize) $VF = $this->rellenaVFX2X3($VF, $contextTypeVerbsAll, $TSize); |
---|
2046 | |
---|
2047 | if (sizeof($VF) < $TSize) { |
---|
2048 | $freqX2 = $this->getRecommenderX2(); |
---|
2049 | $VF = $this->rellenaVFX2X3($VF, $freqX2, $TSize); |
---|
2050 | } |
---|
2051 | } |
---|
2052 | } |
---|
2053 | |
---|
2054 | // rellena |
---|
2055 | if (sizeof($VF) < $TSize) { |
---|
2056 | $freqX1 = $this->getRecommenderX1Expan(0); |
---|
2057 | $VF = $this->rellenaVFX2X3($VF, $freqX1, $TSize); |
---|
2058 | } |
---|
2059 | |
---|
2060 | return $VF; |
---|
2061 | } |
---|
2062 | |
---|
2063 | private function getRecommenderX3NonExpan() { |
---|
2064 | $paraulesFrase = $this->getIdsElem(); |
---|
2065 | $inputid1 = $paraulesFrase[sizeof($paraulesFrase)-2]->pictoid; |
---|
2066 | $inputid2 = $paraulesFrase[sizeof($paraulesFrase)-1]->pictoid; |
---|
2067 | |
---|
2068 | $inputType1 = $this->getTypesElem($inputid1); |
---|
2069 | $inputType2 = $this->getTypesElem($inputid2); |
---|
2070 | |
---|
2071 | // Algorisme V2 - Predictor freqüència II (d'usuari) |
---|
2072 | $VF = array(); |
---|
2073 | $freqUsuari = $this->getfreqUsuariX3NonExpan($inputid1, $inputid2); |
---|
2074 | $freqUsuariDeep = $this->getfreqUsuariX3NonExpanDeep($inputid1, $inputid2, round(($this->SUMcount()[0]->count-sizeof($freqUsuari))*0.01)); |
---|
2075 | if (empty($freqUsuariDeep)) $freqTotal = $freqUsuari; |
---|
2076 | else { |
---|
2077 | $freqTemp = array_merge($freqUsuariDeep, $freqUsuari); |
---|
2078 | usort($freqTemp, function ($a, $b) { |
---|
2079 | if ($a->count == $b->count) return 0; |
---|
2080 | else return ($a->count < $b->count) ? 1 : -1; |
---|
2081 | }); |
---|
2082 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
2083 | } |
---|
2084 | $VF = array_merge($VF,$freqTotal); |
---|
2085 | $TSize = $this->session->userdata('cfgPredBarNumPred'); |
---|
2086 | |
---|
2087 | // rellena |
---|
2088 | if (sizeof($VF) < $TSize) { |
---|
2089 | $freqX2 = $this->getfreqUsuariX2NonExpan($inputid2); |
---|
2090 | $freqUsuariDeep = $this->getfreqUsuariX2NonExpanDeep(round(($this->SUMcount()[0]->count-sizeof($freqX2))*0.01)); |
---|
2091 | if (empty($freqUsuariDeep)) $freqTotal = $freqX2; |
---|
2092 | else { |
---|
2093 | $freqTemp = array_merge($freqUsuariDeep, $freqX2); |
---|
2094 | usort($freqTemp, function ($a, $b) { |
---|
2095 | if ($a->count == $b->count) return 0; |
---|
2096 | else return ($a->count < $b->count) ? 1 : -1; |
---|
2097 | }); |
---|
2098 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
2099 | } |
---|
2100 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
2101 | } |
---|
2102 | |
---|
2103 | // rellena |
---|
2104 | if (sizeof($VF) < $TSize) { |
---|
2105 | $freqX1 = $this->getfreqUsuariX1(); |
---|
2106 | unset($freqX1[0]); |
---|
2107 | unset($freqX1[1]); |
---|
2108 | $freqUsuariDeep = $this->getfreqUsuariX1Deep(round(($this->SUMcount()[0]->count-sizeof($freqX1))*0.01)); |
---|
2109 | if (empty($freqUsuariDeep)) $freqTotal = $freqX1; |
---|
2110 | else { |
---|
2111 | $freqTemp = array_merge($freqUsuariDeep, $freqX1); |
---|
2112 | usort($freqTemp, function ($a, $b) { |
---|
2113 | if ($a->count == $b->count) return 0; |
---|
2114 | else return ($a->count < $b->count) ? 1 : -1; |
---|
2115 | }); |
---|
2116 | $freqTotal = $this->unique_multidim_array($freqTemp, 'pictoid'); |
---|
2117 | } |
---|
2118 | $VF = $this->rellenaVFX2X3($VF, $freqTotal, $TSize); |
---|
2119 | } |
---|
2120 | |
---|
2121 | return $VF; |
---|
2122 | } |
---|
2123 | |
---|
2124 | private function delfreqUsuariX1() { |
---|
2125 | $this->db->where('ID_PSUPUser', $this->session->userdata('idusu')); |
---|
2126 | $this->db->delete('P_StatsUserPicto'); |
---|
2127 | } |
---|
2128 | |
---|
2129 | public function delfreqUsuariX2() { |
---|
2130 | $this->db->where('ID_PSUP2User', $this->session->userdata('idusu')); |
---|
2131 | $this->db->delete('P_StatsUserPictox2'); |
---|
2132 | } |
---|
2133 | |
---|
2134 | public function delfreqUsuariX3() { |
---|
2135 | $this->db->where('ID_PSUP3User', $this->session->userdata('idusu')); |
---|
2136 | $this->db->delete('P_StatsUserPictox3'); |
---|
2137 | } |
---|
2138 | } |
---|
2139 | |
---|
2140 | ?> |
---|