コード例 #1
0
ファイル: ErrorCorrectionEmulator.cs プロジェクト: Ogonik/LWS
 private static LinguisticObjectDetectionMetrics _getCorrectedMetrics(LinguisticObjectDetectionMetrics metrics)
 {
     return new LinguisticObjectDetectionMetrics
     {
         CorrectDetectionsCount = metrics.CorrectDetectionsCount,
         Type   = metrics.Type,
         TargetWordsCount = metrics.TargetWordsCount,
         EssentialErrorIndexes = metrics.EssentialErrorIndexes,
         EssentialErrors = metrics.EssentialErrors,
         MissedEssentialWordIndexes = metrics.MissedEssentialWordIndexes,
         MissedEssentialWords = metrics.MissedEssentialWords,
         MissedNonEssentialWordIndexes = metrics.MissedNonEssentialWordIndexes,
         MissedNonEssentialWords = metrics.MissedNonEssentialWords,
         NonEssentialErrorIndexes = metrics.NonEssentialErrorIndexes,
         NonEssentialErrors = metrics.NonEssentialErrors,
         SampleIndex = metrics.SampleIndex,
         SampleWordIndexes = metrics.SampleWordIndexes,
         SampleWords = metrics.SampleWords,
         SampleWordsCount = metrics.SampleWordsCount,
         SurplusEssentialWordIndexes = metrics.SurplusEssentialWordIndexes,
         SurplusEssentialWords = metrics.SurplusEssentialWords,
         SurplusNonEssentialWordIndexes = metrics.SurplusNonEssentialWordIndexes,
         SurplusNonEssentialWords = metrics.SurplusNonEssentialWords,
         TargetIndex = metrics.TargetIndex,
         TargetWordIndexes = metrics.TargetWordIndexes,
         TargetWords = metrics.TargetWords,
         DetectionQuality = 1d
     };
 }
コード例 #2
0
ファイル: ErrorCorrectionEmulator.cs プロジェクト: Ogonik/LWS
        private static bool _isMatch(ClasterizedSentenceError error, LinguisticObjectDetectionMetrics metrics)
        {
            if (error.DetectedWordsCount != metrics.TargetWordsCount ||
                error.SampleWordsCount != metrics.SampleWordsCount || error.ErrorType != metrics.Type)
            {
                return false;
            }

            var metricsSampleWords = Enumerable.Zip(metrics.SampleWords, metrics.SampleWordIndexes,
                (s, i) => String.Format("{0} ({1})", s, i)).ToList();

            var metricsDetectedWords = Enumerable.Zip(metrics.TargetWords, metrics.TargetWordIndexes,
                (s, i) => String.Format("{0} ({1})", s, i)).ToList();

            return !metricsSampleWords.Except(error.SampleWords).Any() &&
                   !metricsDetectedWords.Except(error.DetectedWords).Any() &&
                   !error.SampleWords.Except(metricsSampleWords).Any() &&
                   !error.DetectedWords.Except(metricsDetectedWords).Any();
        }
コード例 #3
0
ファイル: ModelConverter.cs プロジェクト: Ogonik/LWS
        private void _fillMetrics(LinguisticObjectDetectionMetrics m, bool wasEmulated)
        {
            _addValue(SampleWordsCount, m.SampleWordsCount);
            _addValue(SampleWordIndexes, _indexedWords(m.SampleWordIndexes, m.SampleWords));

            _addValue(AutoWordsCount, m.TargetWordsCount);
            _addValue(AutoWordsIndexes, _indexedWords(m.TargetWordIndexes, m.TargetWords));

            _addValue(NonEssentialErrors, m.NonEssentialErrors.Length);
            _addValue(NonEssentialErrorIndexes, _indexedWords(m.NonEssentialErrorIndexes, m.NonEssentialErrors));

            _addValue(EssentialErrors, m.EssentialErrors.Length);
            _addValue(EssentialErrorIndexes, _indexedWords(m.EssentialErrorIndexes, m.EssentialErrors));

            _addValue(SurplusNonEssentialWords, m.SurplusNonEssentialWords.Length);
            _addValue(SurplusNonEssentialWordIndexes, _indexedWords(m.SurplusNonEssentialWordIndexes, m.SurplusNonEssentialWords));

            _addValue(MissedNonEssentialWords, m.MissedNonEssentialWords.Length);
            _addValue(MissedNonEssentialWordIndexes, _indexedWords(m.MissedNonEssentialWordIndexes, m.MissedNonEssentialWords));

            _addValue(SurplusEssentialWords, m.SurplusEssentialWords.Length);
            _addValue(SurplusEssentialWordIndexes, _indexedWords(m.SurplusEssentialWordIndexes, m.SurplusEssentialWords));

            _addValue(MissedEssentialWords, m.MissedEssentialWords.Length);
            _addValue(MissedEssentialWordIndexes, _indexedWords(m.MissedEssentialWordIndexes, m.MissedEssentialWords));

            _addValue(CorrectDetectionsCount, m.CorrectDetectionsCount);
            _addValue(DetectionQuality, m.DetectionQuality, wasEmulated);
        }