205 if($s instanceof Resource && preg_match(config('corpusparole.bnf_ark_url_regexp'), $s->getUri(), $mBnf) === 1) { |
205 if($s instanceof Resource && preg_match(config('corpusparole.bnf_ark_url_regexp'), $s->getUri(), $mBnf) === 1) { |
206 |
206 |
207 array_push($res, [ |
207 array_push($res, [ |
208 'uri' => $mBnf[0], |
208 'uri' => $mBnf[0], |
209 'code' => $mBnf[1], |
209 'code' => $mBnf[1], |
210 'type' => 'bnf' |
210 'type' => Utils::SUBJECT_TYPE_BNF |
211 ]); |
211 ]); |
212 } elseif($s instanceof Resource && preg_match(config('corpusparole.lexvo_url_regexp'), $s->getUri(), $mLexvo) === 1) { |
212 } elseif($s instanceof Resource && preg_match(config('corpusparole.lexvo_url_regexp'), $s->getUri(), $mLexvo) === 1) { |
213 array_push($res, [ |
213 array_push($res, [ |
214 'uri' => $mLexvo[0], |
214 'uri' => $mLexvo[0], |
215 'code' => $mLexvo[1], |
215 'code' => $mLexvo[1], |
216 'type' => 'lxv' |
216 'type' => Utils::SUBJECT_TYPE_LEXVO |
217 ]); |
217 ]); |
218 } elseif($s instanceof Literal && strpos($s->getDatatypeUri(), config('corpusparole.olac_base_url')) === 0 ) { |
218 } elseif($s instanceof Literal && strpos($s->getDatatypeUri(), config('corpusparole.olac_base_url')) === 0 ) { |
219 array_push($res, [ |
219 array_push($res, [ |
220 'uri' => $s->getValue(), |
220 'uri' => $s->getValue(), |
221 'code' => $s->getValue(), |
221 'code' => $s->getValue(), |
222 'type' => 'olac' |
222 'type' => Utils::SUBJECT_TYPE_OLAC |
223 ]); |
223 ]); |
224 } elseif($s instanceof Literal) { |
224 } elseif($s instanceof Literal) { |
225 array_push($res, [ |
225 array_push($res, [ |
226 'uri' => $s->getValue(), |
226 'uri' => $s->getValue(), |
227 'code' => $s->getValue(), |
227 'code' => $s->getValue(), |
228 'type' => 'txt' |
228 'type' => Utils::SUBJECT_TYPE_TXT |
229 ]); |
229 ]); |
230 } |
230 } |
231 return $res; |
231 return $res; |
232 }, []); |
232 }, []); |
233 |
233 |
234 $labelsBnf = $this->bnfResolver->getLabels( |
234 $labelsBnf = $this->bnfResolver->getLabels( |
235 array_unique(array_reduce( |
235 array_unique(array_reduce( |
236 $sres, |
236 $sres, |
237 function($r, $so) { |
237 function($r, $so) { |
238 if($so['type'] === 'bnf') { |
238 if($so['type'] === Utils::SUBJECT_TYPE_BNF) { |
239 array_push($r, $so['uri']); |
239 array_push($r, $so['uri']); |
240 } |
240 } |
241 return $r; |
241 return $r; |
242 },[] |
242 },[] |
243 )) |
243 )) |
244 ); |
244 ); |
245 $labelsLexvo = $this->lexvoResolver->getNames( |
245 $labelsLexvo = $this->lexvoResolver->getNames( |
246 array_unique(array_reduce( |
246 array_unique(array_reduce( |
247 $sres, |
247 $sres, |
248 function($r, $so) { |
248 function($r, $so) { |
249 if($so['type'] === 'lxv') { |
249 if($so['type'] === Utils::SUBJECT_TYPE_LEXVO) { |
250 array_push($r, $so['uri']); |
250 array_push($r, $so['uri']); |
251 } |
251 } |
252 return $r; |
252 return $r; |
253 },[] |
253 },[] |
254 )) |
254 )) |
255 ); |
255 ); |
256 |
256 |
257 return array_map(function($so) use ($labelsBnf, $labelsLexvo) { |
257 return array_map(function($so) use ($labelsBnf, $labelsLexvo) { |
258 $label = $so['uri']; |
258 $label = $so['uri']; |
259 if($so['type'] === 'bnf') { |
259 if($so['type'] === Utils::SUBJECT_TYPE_BNF) { |
260 $label = $labelsBnf[$label]; |
260 $label = $labelsBnf[$label]; |
261 } elseif ($so['type'] === 'lxv') { |
261 } elseif ($so['type'] === Utils::SUBJECT_TYPE_LEXVO) { |
262 $label = $labelsLexvo[$label]; |
262 $label = $labelsLexvo[$label]; |
263 } |
263 } |
264 return [ 'label' => $label, 'code' => $so['code'], 'label_code' => $label."|".$so['type']."|".$so['code'] ]; }, $sres |
264 return [ 'label' => $label, 'code' => $so['type']."|".$so['code'], 'label_code' => $label."|".$so['type']."|".$so['code'] ]; }, $sres |
265 ); |
265 ); |
266 } |
266 } |
267 |
267 |
268 private function graphResolvCoordinate($loc, $graph) { |
268 private function graphResolvCoordinate($loc, $graph) { |
269 $latLit = $graph->getLiteral($loc, "<http://www.w3.org/2003/01/geo/wgs84_pos#lat>"); |
269 $latLit = $graph->getLiteral($loc, "<http://www.w3.org/2003/01/geo/wgs84_pos#lat>"); |