Beispiel #1
0
 public function parseRelations()
 {
     if ($this->response->status()) {
         $json_data = json_decode($this->response->response());
         if ($json_data && $json_data->status == "OK") {
             foreach ($json_data->relations as $relation) {
                 $object_data = "";
                 if (property_exists($relation, "object")) {
                     $object_data = $relation->object->text;
                 }
                 $action_data = "";
                 if (property_exists($relation, "action")) {
                     $action_data = $relation->action->text;
                 }
                 $location_data = "";
                 if (property_exists($relation, "location")) {
                     $location_data = $relation->location->text;
                 }
                 $sentence = new Sentence();
                 $sentence->full_text = $this->full_text;
                 $sentence->subject = $relation->subject->text;
                 $sentence->action = $action_data;
                 $sentence->object = $object_data;
                 $sentence->location = $location_data;
                 $sentence->subject_url = $relation->subject;
                 if ($object_data != "") {
                     $sentence->object_url = $relation->object;
                 }
                 if ($location_data != "") {
                     $sentence->location_url = $relation->location;
                 }
                 $sentence->save();
                 array_push($this->relations, $sentence);
             }
         }
     }
     return $this->relations;
 }
 public function createSentence($paragraph, $order, $text, $idLanguage)
 {
     $sentence = new Sentence();
     if (substr($text, 0, 1) == ':') {
         $text = substr($text, 1);
     }
     $sentence->setText($text);
     $sentence->setParagraphOrder($order);
     $sentence->setIdParagraph($paragraph->getId());
     $sentence->setIdLanguage($idLanguage);
     $sentence->save();
     return $sentence;
 }