Exemplo n.º 1
0
    public function testSpaces_1()
    {
        $source_seg = <<<SRC
<g id="pt2">WASHINGTON </g><g id="pt3">— The Treasury Department and Internal Revenue Service today requested public comment on issues relating to the shared responsibility provisions included in the Affordable Care Act that will apply to certain employers starting in 2014.</g>
SRC;
        $target_seg = <<<TRG
<g id="pt2"> WASHINGTON </g><g id="pt3">- Il Dipartimento del Tesoro e Internal Revenue Service di oggi hanno chiesto un commento pubblico sulle questioni relative alle disposizioni di responsabilità condivise incluse nel Affordable Care Act che verranno applicate a certi datori di lavoro a partire dal 2014. </g>
TRG;
        $source_seg = CatUtils::view2rawxliff($source_seg);
        $target_seg = CatUtils::view2rawxliff($target_seg);
        $check = new QA($source_seg, $target_seg);
        $check->performConsistencyCheck();
        $notices = $check->getNotices();
        $warnings = $check->getWarnings();
        $errors = $check->getErrors();
        $this->assertFalse($check->thereAreErrors());
        $this->assertFalse($check->thereAreWarnings());
        $this->assertTrue($check->thereAreNotices());
        $this->assertEquals(count($notices), 2);
        $this->assertEquals(1100, $notices[0]->outcome);
        $this->assertEquals(count($warnings), 1);
        $this->assertEquals(0, $warnings[0]->outcome);
        $this->assertEquals(count($errors), 1);
        $this->assertEquals(0, $errors[0]->outcome);
        $normalized = $check->getTrgNormalized();
        //" 1 " -> 20 31 20
        $this->assertEquals('<g id="pt2"> WASHINGTON </g><g id="pt3">- Il Dipartimento del Tesoro e Internal Revenue Service di oggi hanno chiesto un commento pubblico sulle questioni relative alle disposizioni di responsabilità condivise incluse nel Affordable Care Act che verranno applicate a certi datori di lavoro a partire dal 2014. </g>', $normalized);
    }
Exemplo n.º 2
0
 /**
  * Performs a check on single segment
  *
  */
 private function __segmentWarningsCall()
 {
     $this->result['details'] = null;
     $this->result['token'] = $this->__postInput->token;
     $this->result['total'] = 0;
     $QA = new QA($this->__postInput->src_content, $this->__postInput->trg_content);
     $QA->performConsistencyCheck();
     if (is_array($this->__postInput->glossaryList) && !empty($this->__postInput->glossaryList)) {
         /**
          * FIXME: temporarily disabled due to a bug.
          */
         //            $QA->performGlossaryCheck( $this->__postInput->glossaryList );
     }
     if ($QA->thereAreNotices()) {
         //        if ( $QA->thereAreErrors() ) {
         $this->result['details'] = array();
         $this->result['details']['id_segment'] = $this->__postInput->id;
         //            $this->result[ 'details' ][ 'warnings' ]   = $QA->getErrorsJSON();
         //            $this->result[ 'total' ]                                             = count( $QA->getErrors() );
         $this->result['details']['warnings'] = $QA->getNoticesJSON();
         $this->result['details']['tag_mismatch'] = $QA->getMalformedXmlStructs();
         $this->result['details']['tag_mismatch']['order'] = $QA->getTargetTagPositionError();
         $this->result['total'] = count($QA->getNotices());
         //temp
         //            Log::doLog($this->__postInput->trg_content);
         //            Log::doLog($this->result);
     }
 }
Exemplo n.º 3
0
 /**
  * @return array
  */
 public function getWarning()
 {
     $result = array();
     $QA = new QA($this->source, $this->translation);
     $QA->performConsistencyCheck();
     if ($QA->thereAreNotices()) {
         $notices = $QA->getNoticesJSON();
         $notices = json_decode($notices, true);
         //the outer if it's here because $notices can be
         //an empty string and json_decode will fail into null value
         if (!empty($notices)) {
             $result = array_merge($result, Utils::array_column($notices, 'debug'));
         }
         $tag_mismatch = $QA->getMalformedXmlStructs();
         $tag_order_mismatch = $QA->getTargetTagPositionError();
         if (count($tag_mismatch) > 0) {
             $result[] = sprintf("Tag Mismatch ( %d )", count($tag_mismatch));
         }
         if (count($tag_order_mismatch) > 0) {
             $result[] = sprintf("Tag order mismatch ( %d )", count($tag_order_mismatch));
         }
     }
     $this->warnings = $result;
 }