private bool ShouldAnonymizeTmWithCustomResources(IBatchAnonymizerSettings anonymizerSettings) { var isSpecificResourceChecked = anonymizerSettings.SetSpecificResChecked; var hasTmAdded = !string.IsNullOrEmpty(anonymizerSettings.TmName); return(isSpecificResourceChecked && hasTmAdded); }
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); } }
private void AnonymizeTmTransaltionOrigin(IBatchAnonymizerSettings anonymizerSettings, ITranslationOrigin translationOrigin) { var anonymizeWithCustomRes = ShouldAnonymizeTmWithCustomResources(anonymizerSettings); if (!anonymizeWithCustomRes) { AnonymizeToDefaultValues(translationOrigin); } else { AnonymizeTmMatch(translationOrigin, anonymizerSettings, true); } }
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); } }
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); } }
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); } }
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); } }
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; }