Esempio n. 1
0
        private bool ShouldAnonymizeTmWithCustomResources(IBatchAnonymizerSettings anonymizerSettings)
        {
            var isSpecificResourceChecked = anonymizerSettings.SetSpecificResChecked;
            var hasTmAdded = !string.IsNullOrEmpty(anonymizerSettings.TmName);

            return(isSpecificResourceChecked && hasTmAdded);
        }
Esempio n. 2
0
        private bool ShouldAnonymizeAtWithCustomResources(IBatchAnonymizerSettings anonymizerSettings)
        {
            var isSpecificResourceChecked = anonymizerSettings.SetSpecificResChecked;
            var isFuzzyChanged            = anonymizerSettings.FuzzyScore > 0;  // default value is 0
            var hasTmAdded = !string.IsNullOrEmpty(anonymizerSettings.TmName);

            return(isSpecificResourceChecked && (isFuzzyChanged || hasTmAdded));
        }
        public void RemoveTm(ISegmentPair segmentPair, IBatchAnonymizerSettings anonymizerSettings)
        {
            var translationOrigin = segmentPair?.Properties?.TranslationOrigin;

            if (translationOrigin != null && IsTmTransaltion(translationOrigin))
            {
                AnonymizeTranslationOrigin(segmentPair, anonymizerSettings, translationOrigin);
            }
        }
Esempio n. 4
0
        private void AnonymizeTmTransaltionOrigin(IBatchAnonymizerSettings anonymizerSettings, ITranslationOrigin translationOrigin)
        {
            var anonymizeWithCustomRes = ShouldAnonymizeTmWithCustomResources(anonymizerSettings);

            if (!anonymizeWithCustomRes)
            {
                AnonymizeToDefaultValues(translationOrigin);
            }
            else
            {
                AnonymizeTmMatch(translationOrigin, anonymizerSettings, true);
            }
        }
Esempio n. 5
0
 private void AnonymizeTmMatch(ITranslationOrigin translationOrigin, IBatchAnonymizerSettings anonymizerSettings, bool tmAnonymization)
 {
     translationOrigin.OriginType = DefaultTranslationOrigin.TranslationMemory;
     if (!string.IsNullOrEmpty(anonymizerSettings.TmName))
     {
         translationOrigin.OriginSystem = Path.GetFileNameWithoutExtension(anonymizerSettings.TmName);
     }
     if (anonymizerSettings.FuzzyScore > 0 && !tmAnonymization)
     {
         var fuzzy = anonymizerSettings.FuzzyScore.ToString(CultureInfo.InvariantCulture);
         translationOrigin.MatchPercent = byte.Parse(fuzzy);
     }
 }
Esempio n. 6
0
        public void AnonymizeCreatedByAndEdited(ISegmentPair segmentPair, IBatchAnonymizerSettings anonymizerSettings)
        {
            var translationOrigin = segmentPair.Properties.TranslationOrigin;

            if (anonymizerSettings.CreatedByChecked)
            {
                EditUserMetadata(translationOrigin, "created_by", anonymizerSettings.CreatedByName);
            }
            if (anonymizerSettings.ModifyByChecked)
            {
                EditUserMetadata(translationOrigin, "last_modified_by", anonymizerSettings.ModifyByName);
            }
        }
Esempio n. 7
0
        public void RemoveTm(ISegmentPair segmentPair, IBatchAnonymizerSettings anonymizerSettings)
        {
            var translationOrigin      = segmentPair?.Properties?.TranslationOrigin;
            var originBefereAdaptation = segmentPair?.Properties?.TranslationOrigin.OriginBeforeAdaptation;

            if (translationOrigin != null && IsTmTransaltion(translationOrigin))
            {
                AnonymizeTmTransaltionOrigin(anonymizerSettings, translationOrigin);
            }
            if (originBefereAdaptation != null && IsTmTransaltion(originBefereAdaptation))
            {
                AnonymizeTmTransaltionOrigin(anonymizerSettings, originBefereAdaptation);
            }
        }
Esempio n. 8
0
        public void RemoveMt(ISegmentPair segmentPair, IBatchAnonymizerSettings anonymizerSettings)
        {
            var translationOrigin      = segmentPair?.Properties?.TranslationOrigin;
            var originBeforeAdaptation = segmentPair?.Properties?.TranslationOrigin?.OriginBeforeAdaptation;

            if (translationOrigin != null && IsAutomatedTranslated(translationOrigin))
            {
                AnonymizeMtTranslationOrigin(segmentPair, anonymizerSettings, translationOrigin);
            }
            if (originBeforeAdaptation != null && IsAutomatedTranslated(originBeforeAdaptation))
            {
                AnonymizeMtTranslationOrigin(segmentPair, anonymizerSettings, originBeforeAdaptation);
            }
        }
Esempio n. 9
0
        private void AnonymizeMtTranslationOrigin(ISegmentPair segmentPair, IBatchAnonymizerSettings anonymizerSettings,
                                                  ITranslationOrigin translationOrigin)
        {
            var anonymizeCustomResources = ShouldAnonymizeAtWithCustomResources(anonymizerSettings);

            AnonymizeToDefaultValues(translationOrigin);             // we need to set the origin to be interactive in order to have edied fuzzy

            if (anonymizeCustomResources)
            {
                if (segmentPair.Properties?.TranslationOrigin.OriginBeforeAdaptation == null)
                {
                    var originClone = (ITranslationOrigin)translationOrigin.Clone();
                    originClone.OriginBeforeAdaptation = null;
                    segmentPair.Properties.TranslationOrigin.OriginBeforeAdaptation = originClone;
                }
                AnonymizeTmMatch(segmentPair.Properties.TranslationOrigin.OriginBeforeAdaptation, anonymizerSettings, false);
            }
        }
 public AnonymizerProcessor(IBatchAnonymizerSettings settings, IUserNameService usernameService, IResourceOriginsService resourceOriginsService)
 {
     _settings               = settings;
     _usernameService        = usernameService;
     _resourceOriginsService = resourceOriginsService;
 }