Skip to content

Commit

Permalink
Forced alt-trans matches
Browse files Browse the repository at this point in the history
  with src = trg and match quality < 100 to be 99
  • Loading branch information
Ostico committed Sep 19, 2018
1 parent 81dec4e commit 0e3ce9f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/Features/Microsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Features;

use Analysis\Workers\TMAnalysisWorker;
use API\V2\Json\ProjectUrls;
use Features\Microsoft\Utils\Email\ConfirmedQuotationEmail;
use Features\Microsoft\Utils\Email\ErrorQuotationEmail;
Expand Down Expand Up @@ -166,6 +167,35 @@ public function overrideReviseJobQA( $jobQA, $id_job, $password_job, $job_words
];
}

/**
* @see TMAnalysisWorker::_getMatches()
* @param array $matches
*
* @return array
*/
public function modifyMatches( Array $matches ){
foreach( $matches as $pos => $match ){

foreach( $match[ "tm_properties" ] as $_p => $property ){

if( $property[ 'type' ] != 'x-match-quality' ) {
continue;
}

/*
* Microsoft send alt-trans with the same source of the real source, MyMemory identify these matches as 100% because of src == src
* We force these matches to be 99
*/
if( $property[ 'value' ] < 100 && (int)str_replace( "%", "", $match[ 'match' ] ) >= 100 ){
$matches[ $pos ][ 'match' ] = '99%';
}

}

}
return $matches;
}

/**
* Because of a bug in filters we force languages conversion to it-IT when isCJK
* @param array $array
Expand Down

0 comments on commit 0e3ce9f

Please sign in to comment.