Esempio n. 1
0
 public function not_accept()
 {
     $url = 'http://www.plurk.com/p/6esun8#response-1799208331';
     $annotation = $this->annotation->find('annotation_id', 1017);
     $annotation = new Annotation(1017);
     $original_annotation_id = $annotation->get_id();
     $recommend = new Annotation_recommend();
     $recommend->set_webpage($url);
     $recommend->set_recommended($annotation);
     $recommend->update();
     $annotation = new Annotation(1017);
     $recommend = $annotation->get_recommend();
     //-----------------------------------------------
     $length = $annotation->get_scope_length();
     $recommend = $annotation->get_recommend();
     $annotation = $recommend->set_accept(FALSE);
     $length = $annotation->get_scope_length();
     $this->unit->run($annotation->get_scope_length(), $length, '拒絕推薦之後,由於並沒有改變標註,所以長度還是一樣');
     $this->unit->run($annotation->get_id(), $original_annotation_id, '拒絕推薦之後,這個標註應該跟上面的一樣');
     $recommend = $annotation->get_recommend();
     $this->unit->run($recommend, NULL, '拒絕推薦之後,標註就沒有推薦了');
     $annotation = $this->annotation->find('annotation_id', 1017);
     $this->unit->run($annotation->get_id(), 'is_int', '拒絕推薦之後,原本的標註仍在');
     //        $this->unit->run($test_result
     //                , $expected_result
     //                , $test_name);
     //context_complete();
     unit_test_report($this, __METHOD__);
 }
Esempio n. 2
0
 /**
  * 輸出Annotation的資料
  * @param Annotation $annotation
  * @return string
  */
 private function _print_annotation_table($annotation, &$last_scope)
 {
     $annotation_id = $annotation->get_id();
     $text = '<a name="annotation_' . $annotation_id . '" id="annotation_' . $annotation_id . '"></a><table class="annotation_table"  cellspacing="0" cellpadding="0"><tbody>';
     $scope_collection = $annotation->get_scopes();
     $scope = $scope_collection->get_item(0);
     $from_index = $scope->get_from_index();
     $to_index = $scope->get_to_index();
     if (is_null($last_scope) or !($last_scope[0] == $from_index and $last_scope[1] == $to_index)) {
         $last_scope = array($from_index, $to_index);
         $scope_length = $annotation->get_scope_length();
         $from_to = $from_index;
         if ($from_index != $to_index) {
             $from_to .= '-' . $to_index;
         }
         $anchor_text = $annotation->get_anchor_text();
         $speech = $annotation->get_anchor_speech();
         $speech_list = '';
         foreach ($speech as $s) {
             if ($speech_list != '') {
                 $speech_list .= ', ';
             }
             $speech_list .= $s;
         }
         if ($speech_list == '') {
             $speech_list = '(剖析失敗)';
         }
         //位置
         $location = $annotation->get_feature_location();
         $location_list = '';
         foreach ($location as $l) {
             if ($location_list != '') {
                 $location_list .= ', ';
             }
             $name = '其他';
             $l = intval($l);
             if ($l == 4) {
                 $name = '結尾';
             } else {
                 if ($l == 0) {
                     $name = '開頭';
                 } else {
                     if ($l == 1) {
                         $name = '接近開頭';
                     } else {
                         if ($l == 3) {
                             $name = '接近結尾';
                         } else {
                             if ($l == 5) {
                                 $name = '只有一句';
                             } else {
                                 if ($l == 2) {
                                     $name = '三句中間一句';
                                 }
                             }
                         }
                     }
                 }
             }
             $location_list .= $name . '(' . $l . ')';
         }
         if ($location_list == '') {
             $location_list = '其他';
         }
         $text .= '<tr> <td> <table class="anchor_row" border="1" cellpadding="0" cellspacing="0"><tbody>' . '<tr><th>範圍</th><td>' . $from_to . ' (' . $scope_length . '字)</td><th>詞性(' . count($speech) . ')</th><td>' . $speech_list . '</td><th>位置</th><td>' . $location_list . '</td></tr>' . '<tr><th>錨點文字</th><td colspan="5">' . $anchor_text . '</td></tr>' . '</tbody></table> </td> </tr>';
     }
     //第一列
     //
     // email 發表日期 修改日期 被喜愛 被共識 被回應 編號
     $email = $annotation->get_user()->get_email();
     $print_email = substr($email, 0, 8);
     $print_email = '<a href="' . site_url('/admin_apps/exp201012annotation/email_list/' . $this->_find_email_key($email)) . '">' . $print_email . '</a>';
     //類別
     $type_name = $annotation->get_type()->get_name();
     $type_name_lang = $this->lang->line('web_apps.' . $type_name);
     $type_name_classname = substr($type_name, strrpos($type_name, '.') + 1);
     $create_timestamp = $annotation->get_create_timestamp();
     //2010-12-08 23:17:10.984+08
     //01234567890123456789
     $create_timestamp = $this->_trim_timestamp($create_timestamp);
     $update_timestamp = $annotation->get_update_timestamp();
     $update_timestamp = $this->_trim_timestamp($update_timestamp);
     $liked_count = $annotation->get_like_count();
     $consensus_count = $annotation->get_consensus_count();
     $topic_respond_count = $annotation->get_topic_respond_coll()->length();
     $text .= '<tr> <td> <table class="row" border="1" cellpadding="0" cellspacing="0"><tbody><tr>' . '<th class="email">' . $print_email . '</th>' . '<th class="type ' . $type_name_classname . '">' . $type_name_lang . '</th>' . '<th>建立日期:</th><td class="date">' . $create_timestamp . '</td>' . '<th>修改日期:</th><td class="date">' . $update_timestamp . '</td>' . '<td class="annotation_id">#' . $annotation_id . '</td>' . '</tr></tbody></table> </td> </tr>';
     //第二列
     //  標註類別 位置 分數 建議的ID 推薦的ID 接受建議間隔
     //分數
     $score = $annotation->get_score(0)->get_score();
     //是否有建議?顯示建議的ID
     $query = $this->db->select('recommend_id, accept, (checked_timestamp - annotation.create_timestamp) as check_interval, recommend_by_annotation_id')->from('recommend join annotation on recommended_annotation_id = annotation.annotation_id')->where('recommended_annotation_id', $annotation_id)->get();
     $recommend_table;
     if ($query->num_rows() == 0) {
         $recommend_table = '沒有建議';
     } else {
         $row = $query->row_array();
         $recommend_id = $row['recommend_id'];
         $recommed_by_annotation_id = $row['recommend_by_annotation_id'];
         $accept = $row['accept'];
         $recommend_table = '建議ID:' . $recommend_id;
         if ($accept == '') {
             //尚未確認
             $recommend_table .= ' <span class="state">尚未確認</span>';
         } else {
             $accept_text = '<span class="state accpet">接受</span>';
             if ($accept == 'f') {
                 $accept_text = '<span class="state reject">拒絕</span>';
             }
             $check_interval = $row['check_interval'];
             $point = strrpos($check_interval, '.');
             if ($point !== FALSE) {
                 $check_interval = substr($check_interval, 0, $point);
             }
             $recommend_table .= '; ' . $accept_text . '; 確認間隔: ' . $check_interval;
         }
         if ($recommed_by_annotation_id != '') {
             $recommend_table .= '; <a href="#annotation_' . $recommed_by_annotation_id . '">推薦標註: ' . $recommed_by_annotation_id . '</a>';
         }
     }
     $text .= '<tr> <td> <table class="row" border="1" cellpadding="0" cellspacing="0"><tbody><tr>' . '<th>喜愛共識:</th><td>' . $liked_count . '</td>' . '<th>範圍共識:</th><td>' . $consensus_count . '</td>' . '<th>回應:</th><td>' . $topic_respond_count . '</td>' . '<th>分數</th><td>' . $score . '</td>' . '<th>建議</th><td class="recommend">' . $recommend_table . '</td>' . '</tr></tbody></table> </td> </tr>';
     $note = $annotation->get_note();
     if ($note != '') {
         $text .= '<tr><td><table class="note" width="100%" border="1" cellpadding="0" cellspacing="0"><tbody><tr><td>' . $note . '</td></tr></tbody></table></td></tr>';
     }
     if ($topic_respond_count > 0) {
         $respond_annotation_table = $this->_print_respond($annotation);
         $text .= '<tr><td>' . $respond_annotation_table . '</td></tr>';
     }
     $text .= '</tbody></table>';
     return $text;
 }