Example #1
0
 private function createUserObjects()
 {
     /*
      * sentenceObject = {
      *  rid : {
      *      sentenceId : [
      *          {
      *              text : string, 
      *              opinions : [{
      *                  category : string,
      *                  polarity : string
      *              }]
      *          }
      *      ]
      *  }
      * }
      * */
     foreach ($this->sentenceObject as $rid => $s) {
         $user = new User($rid);
         foreach ($s as $sentenceId => $ss) {
             $sentence = new Sentence($sentenceId, $rid, $this->productId, $ss['text']);
             if (array_key_exists('opinions', $ss)) {
                 foreach ($ss['opinions'] as $o) {
                     $opinion = new Opinion($o['category'], $o['polarity']);
                     $sentence->addOpinion($opinion);
                 }
             }
             $user->addSentence($sentence);
         }
         $this->users[] = $user;
     }
     echo "User Object construction completed.\n";
 }