diff --git a/lib/Utils/Engines/MyMemory.php b/lib/Utils/Engines/MyMemory.php index 4178028285..6222691f53 100644 --- a/lib/Utils/Engines/MyMemory.php +++ b/lib/Utils/Engines/MyMemory.php @@ -911,21 +911,24 @@ public function getTagProjection( $config ) { //tag replace $source_string = $config['source']; $target_string = $config['target']; -// $re2 = ''; -// preg_match_all("/" . $re2 .'/siU', $source_string, $source_matches_tag,PREG_OFFSET_CAPTURE, 0); -// preg_match_all("/" . $re2 .'/siU', $target_string, $target_matches_tag,PREG_OFFSET_CAPTURE, 0); -// -// $map=[]; -// foreach ($source_matches_tag[0] as $source_key=>$source_tag){ -// foreach ($target_matches_tag[0] as $target_tag){ -// if($source_tag[0] == $target_tag[0]){ -// $replace = md5($source_matches_tag[2][$source_key][0]); -// $source_string = str_replace($source_tag[0], $replace, $source_string); -// $target_string = str_replace($source_tag[0], $replace, $target_string); -// $map[$replace] = $source_tag[0]; -// } -// } -// } + // + $re2 = ''; + preg_match_all("/" . $re2 .'/siU', $source_string, $source_matches_tag,PREG_OFFSET_CAPTURE, 0); + preg_match_all("/" . $re2 .'/siU', $target_string, $target_matches_tag,PREG_OFFSET_CAPTURE, 0); + + $map=[]; + foreach ($source_matches_tag[0] as $source_key=>$source_tag){ + foreach ($target_matches_tag[0] as $target_tag){ + if($source_tag[0] == $target_tag[0]){ + $replace = md5($source_matches_tag[2][$source_key][0]); + $source_string = str_replace($source_tag[0], $replace, $source_string); + $target_string = str_replace($source_tag[0], $replace, $target_string); + $map[$replace] = $source_tag[0]; + } + } + } + // + //formatting strip $re = '( |\p{Zs}| |\n|\t|⇥|\x{21E5}|\xc2\xa0|\xE2|\x81|\xA0)+'; @@ -953,10 +956,12 @@ public function getTagProjection( $config ) { if (!empty($this->result->responseData)){ //formatting replace $this->result->responseData = $l_matches . $this->result->responseData . $r_matches; + // //tag replace -// foreach ($map as $key=>$value){ -// $this->result->responseData = str_replace($key, $value, $this->result->responseData); -// } + foreach ($map as $key=>$value){ + $this->result->responseData = str_replace($key, $value, $this->result->responseData); + } + // } return $this->result;