2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
4
using System . Linq ;
5
- using System . Text ;
6
- using System . Text . RegularExpressions ;
7
5
using Sdl . Community . PostEdit . Compare . Core . Comparison . Text ;
6
+ using Sdl . Community . PostEdit . Compare . Core . Helper ;
8
7
using Sdl . Community . PostEdit . Compare . Core . Reports ;
9
8
using Sdl . Community . PostEdit . Compare . Core . SDLXLIFF ;
9
+ using Convert = System . Convert ;
10
10
11
11
namespace Sdl . Community . PostEdit . Compare . Core . Comparison
12
12
{
@@ -84,9 +84,9 @@ internal Dictionary<string, Dictionary<string, ComparisonParagraphUnit>> GetComp
84
84
}
85
85
86
86
var fileParagraphUnitUpdated = xFileParagraphUnitsUpdated [ fileParagraphUnitOriginal . Key ] ;
87
- if ( ( from paragraphUnitOriginalPair in fileParagraphUnitOriginal . Value
88
- select paragraphUnitOriginalPair . Value into paragraphUnitOriginal
89
- let paragraphUnitUpdated = new ParagraphUnit ( paragraphUnitOriginal . ParagraphUnitId , new List < SegmentPair > ( ) )
87
+ if ( ( from paragraphUnitOriginalPair in fileParagraphUnitOriginal . Value
88
+ select paragraphUnitOriginalPair . Value into paragraphUnitOriginal
89
+ let paragraphUnitUpdated = new ParagraphUnit ( paragraphUnitOriginal . ParagraphUnitId , new List < SegmentPair > ( ) )
90
90
select paragraphUnitOriginal ) . Any ( paragraphUnitOriginal => ! fileParagraphUnitUpdated . ContainsKey ( paragraphUnitOriginal . ParagraphUnitId ) ) )
91
91
{
92
92
errorMatchingParagraphLevel = true ;
@@ -115,8 +115,9 @@ select paragraphUnitOriginalPair.Value into paragraphUnitOriginal
115
115
116
116
117
117
var nameOriginal = Path . GetFileName ( fileParagraphUnitOriginal . Key ) ;
118
- var fileParagraphUnitUpdated = ( from kvp in xFileParagraphUnitsUpdated let fileNameUpdated = Path . GetFileName ( kvp . Key )
119
- where string . Compare ( nameOriginal , fileNameUpdated , StringComparison . OrdinalIgnoreCase ) == 0
118
+ var fileParagraphUnitUpdated = ( from kvp in xFileParagraphUnitsUpdated
119
+ let fileNameUpdated = Path . GetFileName ( kvp . Key )
120
+ where string . Compare ( nameOriginal , fileNameUpdated , StringComparison . OrdinalIgnoreCase ) == 0
120
121
select kvp . Value ) . FirstOrDefault ( ) ;
121
122
122
123
if ( fileParagraphUnitUpdated == null )
@@ -308,7 +309,7 @@ where string.Compare(nameOriginal, fileNameUpdated, StringComparison.OrdinalIgno
308
309
309
310
return comparisonFileParagraphUnits ;
310
311
}
311
-
312
+
312
313
private void AddToComparision ( ref ComparisonParagraphUnit comparisonParagraphUnit
313
314
, ComparisonSegmentUnit comparisonSegmentUnit
314
315
, SegmentPair segmentPairOriginal
@@ -317,6 +318,13 @@ private void AddToComparision(ref ComparisonParagraphUnit comparisonParagraphUni
317
318
comparisonSegmentUnit . SegmentStatusOriginal = segmentPairOriginal . SegmentStatus ;
318
319
comparisonSegmentUnit . SegmentStatusUpdated = segmentPairUpdated . SegmentStatus ;
319
320
321
+
322
+ if ( Processor . Settings . ReportFilterTranslationMatchValuesOriginal == SharedStrings . FuzzyMatch )
323
+ if ( ! FuzzyRange . IsInFuzzyRange ( segmentPairOriginal . TranslationOrigin . MatchPercentage , Processor . Settings . FuzzyMatchValuesOriginal ) ) return ;
324
+
325
+ if ( Processor . Settings . ReportFilterTranslationMatchValuesUpdated == SharedStrings . FuzzyMatch )
326
+ if ( ! FuzzyRange . IsInFuzzyRange ( segmentPairUpdated . TranslationOrigin . MatchPercentage , Processor . Settings . FuzzyMatchValuesUpdated ) ) return ;
327
+
320
328
comparisonSegmentUnit . TranslationStatusOriginal = GetTranslationStatus ( segmentPairOriginal ) ;
321
329
comparisonSegmentUnit . TranslationStatusUpdated = GetTranslationStatus ( segmentPairUpdated ) ;
322
330
@@ -334,7 +342,7 @@ private void AddToComparision(ref ComparisonParagraphUnit comparisonParagraphUni
334
342
comparisonSegmentUnit . ComparisonTextUnits = GetComparisonTextUnits ( segmentPairOriginal . TargetSections , segmentPairUpdated . TargetSections ) ;
335
343
336
344
comparisonSegmentUnit . SegmentTextUpdated = true ;
337
- comparisonParagraphUnit . ParagraphIsUpdated = true ;
345
+ comparisonParagraphUnit . ParagraphIsUpdated = true ;
338
346
}
339
347
340
348
comparisonSegmentUnit . SourceWordsOriginal = segmentPairOriginal . SourceWords ;
@@ -379,7 +387,7 @@ private void AddToComparision(ref ComparisonParagraphUnit comparisonParagraphUni
379
387
comparisonParagraphUnit . ComparisonSegmentUnits . Add ( comparisonSegmentUnit ) ;
380
388
}
381
389
382
-
390
+
383
391
private static string GetTranslationStatus ( SegmentPair segmentPair )
384
392
{
385
393
var match = string . Empty ;
@@ -395,24 +403,24 @@ private static string GetTranslationStatus(SegmentPair segmentPair)
395
403
match = "CM" ;
396
404
}
397
405
else if ( string . Compare ( segmentPair . TranslationOrigin . OriginType , "mt" , StringComparison . OrdinalIgnoreCase ) == 0
398
- || string . Compare ( segmentPair . TranslationOrigin . OriginType , "nmt" , StringComparison . OrdinalIgnoreCase ) == 0
399
- || string . Compare ( segmentPair . TranslationOrigin . OriginType , "amt" , StringComparison . OrdinalIgnoreCase ) == 0 )
406
+ || string . Compare ( segmentPair . TranslationOrigin . OriginType , "nmt" , StringComparison . OrdinalIgnoreCase ) == 0
407
+ || string . Compare ( segmentPair . TranslationOrigin . OriginType , "amt" , StringComparison . OrdinalIgnoreCase ) == 0 )
400
408
{
401
409
match = "AT" ;
402
410
}
403
-
404
- else
411
+
412
+ else
405
413
{
406
414
match = segmentPair . TranslationOrigin . MatchPercentage + "%" ;
407
415
}
408
416
}
409
417
else if ( string . Compare ( segmentPair . TranslationOrigin . OriginType , "mt" , StringComparison . OrdinalIgnoreCase ) == 0
410
- || string . Compare ( segmentPair . TranslationOrigin . OriginType , "nmt" , StringComparison . OrdinalIgnoreCase ) == 0
411
- || string . Compare ( segmentPair . TranslationOrigin . OriginType , "amt" , StringComparison . OrdinalIgnoreCase ) == 0 )
418
+ || string . Compare ( segmentPair . TranslationOrigin . OriginType , "nmt" , StringComparison . OrdinalIgnoreCase ) == 0
419
+ || string . Compare ( segmentPair . TranslationOrigin . OriginType , "amt" , StringComparison . OrdinalIgnoreCase ) == 0 )
412
420
{
413
421
match = "AT" ;
414
- }
415
- else if ( segmentPair . TranslationOrigin . MatchPercentage > 0 )
422
+ }
423
+ else if ( segmentPair . TranslationOrigin . MatchPercentage > 0 )
416
424
{
417
425
match = segmentPair . TranslationOrigin . MatchPercentage + "%" ;
418
426
}
@@ -509,24 +517,24 @@ private static List<string> GetSectionsList(IReadOnlyList<SegmentSection> segmen
509
517
}
510
518
}
511
519
return items ;
512
-
520
+
513
521
}
514
522
internal static int DamerauLevenshteinDistanceFromObject ( List < SegmentSection > source , List < SegmentSection > target )
515
523
{
516
524
517
525
var sourceLen = 0 ;
518
526
var sourceItems = GetSectionsList ( source , ref sourceLen ) ;
519
-
527
+
520
528
var targetLen = 0 ;
521
529
var targetItems = GetSectionsList ( target , ref targetLen ) ;
522
-
523
530
524
- if ( sourceLen == 0 )
531
+
532
+ if ( sourceLen == 0 )
525
533
return targetLen == 0 ? 0 : targetLen ;
526
-
527
- if ( targetLen == 0 )
534
+
535
+ if ( targetLen == 0 )
528
536
return sourceLen ;
529
-
537
+
530
538
531
539
var score = new int [ sourceLen + 2 , targetLen + 2 ] ;
532
540
0 commit comments