/** * @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; }
/** * 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); } }
public function testTagPositionHardNesting_2() { $source_seg = <<<SRC <g id="6"> <g id="7">st</g><g id="8"> <span class="this is in entities">Section</span> of <.++* Tokyo <g id="9"><g id="10">Station</g></g>, Osaka </g></g> SRC; $target_seg = <<<TRG <g id="6"> <g id="7">st</g> <g id="8"> <span class="this is in entities">Section</span> of <.++* Tokyo <g id="9"></g><g id="10"> Station</g>, Osaka </g></g> TRG; $source_seg = CatUtils::view2rawxliff($source_seg); $target_seg = CatUtils::view2rawxliff($target_seg); $check = new QA($source_seg, $target_seg); $check->performConsistencyCheck(); $this->assertTrue($check->thereAreWarnings()); $checkPosition = $check->getTargetTagPositionError(); $checkPositionVals = array_keys($checkPosition); $this->assertCount(1, $checkPosition); $this->assertEquals('</g>', end($checkPosition)); }