示例#1
0
 /**
  * No More used
  *
  * @deprecated
  *
  * @param        $id_segment
  * @param        $id_job
  * @param string $suggestions_json_array
  * @param string $suggestion
  * @param string $suggestion_match
  * @param string $suggestion_source
  * @param string $match_type
  * @param int    $eq_words
  * @param int    $standard_words
  * @param string $translation
  * @param string $tm_status_analysis
  * @param int    $warning
  * @param string $err_json
  * @param int    $mt_qe
  * @param int    $pretranslate_100
  *
  * @return int
  */
 public static function addTranslationSuggestion($id_segment, $id_job, $suggestions_json_array = "", $suggestion = "", $suggestion_match = "", $suggestion_source = "", $match_type = "", $eq_words = 0, $standard_words = 0, $translation = "", $tm_status_analysis = "UNDONE", $warning = 0, $err_json = '', $mt_qe = 0, $pretranslate_100 = 0)
 {
     if (!empty($suggestion_source)) {
         if (strpos($suggestion_source, "MT") === false) {
             $suggestion_source = 'TM';
         } else {
             $suggestion_source = 'MT';
         }
     }
     /**
      * For future refactory, with this SQL construct we halve the number of insert/update queries
      *
      * mysql support this:
      *
      *  INSERT INTO example (id,suggestions_array) VALUES (1,'["key":"we don\'t want this update because of tm_analysis_status is not DONE"]')
      *      ON DUPLICATE KEY UPDATE
      *          suggestions_array = IF( tm_analysis_status = 'DONE' , VALUES(suggestions_array) , suggestions_array );
      *
      */
     $segment_status = 'NEW';
     //controllare il valore di suggestion_match
     if ($suggestion_match == "100%" && $pretranslate_100) {
         $segment_status = 'TRANSLATED';
     }
     $insertRes = setSuggestionInsert($id_segment, $id_job, $suggestions_json_array, $suggestion, $suggestion_match, $suggestion_source, $match_type, $eq_words, $standard_words, $translation, $tm_status_analysis, $warning, $err_json, $mt_qe, $segment_status);
     if ($insertRes < 0 and $insertRes != -1062) {
         $result['errors'][] = array("code" => -4, "message" => "error occurred during the storing (INSERT) of the suggestions for the segment {$id_segment} - {$insertRes}");
         return $result;
     }
     if ($insertRes == -1062) {
         // the translaion for this segment still exists : update it
         if ($segment_status !== 'TRANSLATED') {
             $segment_status = null;
         }
         $updateRes = setSuggestionUpdate($id_segment, $id_job, $suggestions_json_array, $suggestion, $suggestion_match, $suggestion_source, $match_type, $eq_words, $standard_words, $translation, $tm_status_analysis, $warning, $err_json, $mt_qe, $segment_status);
         if ($updateRes < 0) {
             $result['errors'][] = array("code" => -5, "message" => "error occurred during the storing (UPDATE) of the suggestions for the segment {$id_segment}");
             return $result;
         }
     }
     return 0;
 }
示例#2
0
 public static function addTranslationSuggestion($id_segment, $id_job, $suggestions_json_array = "", $suggestion = "", $suggestion_match = "", $suggestion_source = "")
 {
     if (!empty($suggestion_source)) {
         if (strpos($suggestion_source, "MT") === false) {
             $suggestion_source = 'TM';
         } else {
             $suggestion_source = 'MT';
         }
     }
     $insertRes = setSuggestionInsert($id_segment, $id_job, $suggestions_json_array, $suggestion, $suggestion_match, $suggestion_source);
     if ($insertRes < 0 and $insertRes != -1062) {
         $result['error'][] = array("code" => -4, "message" => "error occurred during the storing (INSERT) of the suggestions for the segment {$id_segment} - {$insertRes}");
         return $result;
     }
     if ($insertRes == -1062) {
         // the translaion for this segment still exists : update it
         $updateRes = setSuggestionUpdate($id_segment, $id_job, $suggestions_json_array, $suggestion, $suggestion_match, $suggestion_source);
         // log::doLog("updateRes");
         // log::doLog($updateRes);
         if ($updateRes < 0) {
             $result['error'][] = array("code" => -5, "message" => "error occurred during the storing (UPDATE) of the suggestions for the segment {$id_segment}");
             return $result;
         }
     }
     return 0;
 }