public void CalculateQuadrant() { var firstQuadrant = new Point { X = 3, Y = 9 }; var secondQuadrant = new Point { X = -3, Y = 9 }; var thirdQuadrant = new Point { X = -3, Y = -9 }; var fourthQuadrant = new Point { X = 3, Y = -9 }; var fuzzyHelper = new FuzzyHelper(); var quadrantI = fuzzyHelper.InWhichQuadrant(firstQuadrant); var quadrantII = fuzzyHelper.InWhichQuadrant(secondQuadrant); var quadrantIII = fuzzyHelper.InWhichQuadrant(thirdQuadrant); var quadrantIV = fuzzyHelper.InWhichQuadrant(fourthQuadrant); quadrantI.ShouldBe(Quadrant.I); quadrantII.ShouldBe(Quadrant.II); quadrantIII.ShouldBe(Quadrant.III); quadrantIV.ShouldBe(Quadrant.IV); }
public void FuzzyEmailTest() { string _email = "*****@*****.**"; string _action = FuzzyHelper.FuzzyEmail(_email); string _expected = "ch*********@outlook.com"; Assert.AreEqual(_action, _expected); }
public void FuzzyUserNameTest() { string _userName = "******"; string _action = FuzzyHelper.FuzzyUserName(_userName); string _expected = "朱***八"; Assert.AreEqual(_action, _expected); }
public void FuzzyMobieNumberTest() { string _phoneNumber = "18501600110"; string _action = FuzzyHelper.FuzzyMobieNumber(_phoneNumber); string _expected = "185****0110"; Assert.AreEqual(_action, _expected); }
public RobotArm(double l1, double l2, double theta1Min, double theta1Max, double theta2Min, double theta2Max) { L1 = l1; L2 = l2; Theta1Max = theta1Max; Theta2Max = theta2Max; Theta1Min = theta1Min; Theta2Min = theta2Min; _fuzzyHelper = new FuzzyHelper(); }
public RobotArm(double l1, double l2, double theta1Min, double theta1Max, double theta2Min, double theta2Max, FuzzyHelper fuzzyHelper) { L1 = l1; L2 = l2; Theta1Max = theta1Max; Theta2Max = theta2Max; Theta1Min = theta1Min; Theta2Min = theta2Min; _fuzzyHelper = fuzzyHelper; }
public static bool IsPreviousUnEditedFuzzyMatchFound(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings) { if (!rowInfo.IsSegment) { return(false); } return(settings.PreviousOriginTypes.Any(a => a == OriginType.UneditedFuzzy.ToString()) && FuzzyHelper.ContainsFuzzyMatch(rowInfo.SegmentPair.Target?.Properties?.TranslationOrigin?.OriginBeforeAdaptation) && !FuzzyHelper.IsEditedFuzzyMatch(rowInfo.SegmentPair.Target?.Properties?.TranslationOrigin?.OriginBeforeAdaptation)); }
private static LinguisticVariable CreateCrit() { double a = 0; double b = 1; double h = 0.1; double x = 0; List <Term> terms = new List <Term>(); List <KeyValuePair <double, double> > list = new List <KeyValuePair <double, double> >(); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), -0.3, 0, 0.3); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Low", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0, 0.3, 0.7); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Medium", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0.3, 0.7, 1); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("High", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0.7, 1, 1.3); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Very High", new ContinuousFuzzySet <double, double>(list))); return(new LinguisticVariable("Crit", terms, null)); }
public static bool IsEditedFuzzyMatchFound(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings) { if (!rowInfo.IsSegment) { return(false); } return(settings.OriginTypes.Any(a => a == DisplayFilterSettings.OriginTypeExtended.EditedFuzzy.ToString()) && FuzzyHelper.ContainsFuzzyMatch(rowInfo.SegmentPair.Target?.Properties?.TranslationOrigin) && FuzzyHelper.IsEditedFuzzyMatch(rowInfo.SegmentPair.Target?.Properties?.TranslationOrigin)); }
private static LinguisticVariable CreateLuck() { double a = 0; double b = 10; double h = 0.1; double x = 0; List <Term> terms = new List <Term>(); List <KeyValuePair <double, double> > list = new List <KeyValuePair <double, double> >(); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), -3.3, 0, 3.3); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Loser", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0, 3.3, 6.7); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Normal", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 3.3, 6.7, 10); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Lucky", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 6.7, 10, 13.3); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("FavoriteOfDesteny", new ContinuousFuzzySet <double, double>(list))); return(new LinguisticVariable("Luck", terms, null)); }
public async Task checkStrategyOfCalculationCoordinates(double l1, double l2) { var fuzzyHelper = new FuzzyHelper(); var temp = new List <double[, ]>(); var temp1 = new double[2, 3] { { 1, 2, 3 }, { 1, 2, 3 } }; var temp2 = new double[2, 3] { { 1, 1, 1 }, { 2, 2, 2 } }; temp.Add(temp1); temp.Add(temp2); var result = await fuzzyHelper.CalculateCoordinates(l1, l2, temp); }
public async Task checkMeshGrid(double[] theta1Vector, double[] theta2Vector) { var fuzzyHelper = new FuzzyHelper(); var result = await fuzzyHelper.MeshGrid(theta1Vector, theta2Vector); result.ShouldNotBeNull(); result.Count().ShouldBe(2); var g = (result.ToList()[0]); var g1 = (result.ToList()[1]); g[1, 1].ShouldBe(2); g[1, 2].ShouldBe(3); g1[1, 1].ShouldBe(2); g1[1, 2].ShouldBe(2); }
public InputKeyMatch FuzzyMatch(InputKeyIndex other, int fuzzy = 0) { if (this.Match(other)) { return(InputKeyMatch.FullMatch); } // We don't want a lot of shorter versions that might match. // This will just flood our results otherwise. if (this.index.Length < other.index.Length) { return(InputKeyMatch.NoMatch); } var startWithResult = FuzzyHelper.StartWith(this.index, other.index); if (startWithResult <= fuzzy) { return(InputKeyMatch.PartialMatch); } return(InputKeyMatch.NoMatch); }
public bool Filter(DisplayFilterRowInfo rowInfo, bool success) { if (!rowInfo.IsSegment) { return(!HasCustomSettings()); } var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (success && _customSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (success && _customSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (success && _customSettings.SplitSegments) { success = SegmentNumbersHelper.IsSplitSegment(rowId, _document); } if (success && (_customSettings.MergedSegments || _customSettings.MergedAcross)) { success = SegmentNumbersHelper.IsMergedSegment(rowId, _document, _customSettings.MergedAcross); } if (success && _customSettings.SourceEqualsTarget) { success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, _customSettings.IsEqualsCaseSensitive); } if (success && _customSettings.Grouped && !string.IsNullOrWhiteSpace(_customSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, _customSettings.GroupedList); } if (success && _customSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(_customSettings.CommentRegex)) { var visitor = new CommentDataVisitor(); var commentsList = visitor.GetComments(rowInfo.SegmentPair.Source); commentsList.AddRange(visitor.GetComments(rowInfo.SegmentPair.Target)); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, _customSettings.CommentRegex); } if (success && _customSettings.Colors?.Count > 0) { success = ColorPickerHelper.ContainsColor(rowInfo, _customSettings.Colors, _customSettings.ColorsFoundIn); } if (success && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, _customSettings.FuzzyMin, _customSettings.FuzzyMax); } if (success && _customSettings.ContainsTags) { var containsTagVisitor = new TagVisitor(); success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source); } if (success && _customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(_customSettings.CreatedBy)) { var userVisitor = new TranslationOriginMetaDataVisitor(); success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, _customSettings.CreatedBy); } if (success && _customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(_customSettings.ModifiedBy)) { var userVisitor = new TranslationOriginMetaDataVisitor(); success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, _customSettings.ModifiedBy); } if (success && !string.IsNullOrEmpty(_customSettings.DocumentStructureInformation)) { success = _settings.IsRegularExpression ? DocumentStructureInfoRegexSearch(rowInfo, _customSettings.DocumentStructureInformation, _settings.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase) : DocumentStructureInfoSearch(rowInfo, _customSettings); } return(success); }
public void StartWith(int[] actual, int[] startWith, int fuzzyCount) { var result = FuzzyHelper.StartWith(startWith, actual); Assert.Equal(fuzzyCount, result); }
private static LinguisticVariable CreateForce() { double a = 0; double b = 10; double h = 0.1; double x = 0; List <Term> terms = new List <Term>(); List <KeyValuePair <double, double> > list = new List <KeyValuePair <double, double> >(); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), -2, 0, 2); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Dweeb", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0, 2, 4); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Week", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 2, 4, 6); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Normal", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 4, 6, 8); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Athlete", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 6, 8, 10); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Hercules", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 8, 10, 12); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("MrUniverse", new ContinuousFuzzySet <double, double>(list))); return(new LinguisticVariable("Force", terms, null)); }
public void CalculateQuadrantByVector(int jointLocation) { var jointPosition = new Point(); var firstQuadrant = new Point { X = 4, Y = 9 }; var secondQuadrant = new Point { X = 2, Y = 10 }; var thirdQuadrant = new Point { X = 1, Y = 9 }; var fourthQuadrant = new Point { X = 4, Y = 6 }; switch (jointLocation) { case 1: jointPosition = new Point { X = 3, Y = 9 }; firstQuadrant = new Point { X = 4, Y = 9 }; secondQuadrant = new Point { X = 2, Y = 10 }; thirdQuadrant = new Point { X = 1, Y = 9 }; fourthQuadrant = new Point { X = 4, Y = 6 }; break; case 2: jointPosition = new Point { X = -3, Y = 9 }; firstQuadrant = new Point { X = -4, Y = 9 }; secondQuadrant = new Point { X = -2, Y = 10 }; thirdQuadrant = new Point { X = -1, Y = 9 }; fourthQuadrant = new Point { X = -4, Y = 6 }; break; case 3: jointPosition = new Point { X = -3, Y = -9 }; firstQuadrant = new Point { X = -4, Y = -9 }; secondQuadrant = new Point { X = -2, Y = -10 }; thirdQuadrant = new Point { X = -1, Y = -9 }; fourthQuadrant = new Point { X = -4, Y = -6 }; break; case 4: jointPosition = new Point { X = 3, Y = -9 }; firstQuadrant = new Point { X = 4, Y = -9 }; secondQuadrant = new Point { X = 2, Y = -10 }; thirdQuadrant = new Point { X = 1, Y = -9 }; fourthQuadrant = new Point { X = 4, Y = -6 }; break; } var fuzzyHelper = new FuzzyHelper(); var quadrantI = fuzzyHelper.InWhichQuadrant(jointPosition, firstQuadrant); var quadrantII = fuzzyHelper.InWhichQuadrant(jointPosition, secondQuadrant); var quadrantIII = fuzzyHelper.InWhichQuadrant(jointPosition, thirdQuadrant); var quadrantIV = fuzzyHelper.InWhichQuadrant(jointPosition, fourthQuadrant); quadrantI.ShouldBe(Quadrant.IV); quadrantII.ShouldBe(Quadrant.I); quadrantIII.ShouldBe(Quadrant.II); quadrantIV.ShouldBe(Quadrant.III); }
public bool EvaluateRow(DisplayFilterRowInfo rowInfo) { var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment); if (rowInfo.IsSegment) { if (ReverseSearch) { return(Reverse(success, rowInfo)); } if (success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any()) { success = rowInfo.IsSegmentReviewTypes(Settings); } if (success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any()) { success = rowInfo.IsConfirmationLevelFound(Settings); } if (success && Settings.OriginTypes != null && Settings.OriginTypes.Any()) { success = rowInfo.IsOriginTypeFound(Settings); } if (success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any()) { success = rowInfo.IsPreviousOriginTypeFound(Settings); } if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any()) { if (!Settings.RepetitionTypes.Contains("Unique")) { success = rowInfo.IsRepetitionTypes(Settings); } } if (success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any()) { success = rowInfo.IsSegmentLockingTypes(Settings); } if (success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any()) { success = rowInfo.IsSegmentContentTypes(Settings); } if (success && Settings.SourceText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInSource(Settings); if (Settings.IsRegularExpression) { var textVisitor = new SegmentTextVisitor(); var text = textVisitor.GetText(rowInfo.SegmentPair.Source); success = ContentHelper.SearchContentRegularExpression(text, Settings.SourceText); } } if (success && Settings.TargetText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInTarget(Settings); } if (success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInComment(Settings); } if (success && Settings.CommentAuthor.Trim() != string.Empty) { success = rowInfo.IsAuthorFoundInComment(Settings); } if (success && Settings.CommentSeverity > 0) { success = rowInfo.IsSeverityFoundInComment(Settings); } if (success && Settings.ContextInfoTypes.Any()) { success = rowInfo.IsContextInfoTypes(Settings); } // check custom settings var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (success && CustomSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (success && CustomSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (success && CustomSettings.SplitSegments) { success = SegmentNumbersHelper.IsSplitSegment(rowId, ActiveDocument); } if (success && (CustomSettings.MergedSegments || CustomSettings.MergedAcross)) { success = SegmentNumbersHelper.IsMergedSegment(rowId, ActiveDocument, CustomSettings.MergedAcross); } if (success && CustomSettings.SourceEqualsTarget) { success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, CustomSettings.IsEqualsCaseSensitive); } if (success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList); } if (success && CustomSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex)) { //create a list with source and target comments var commentsList = rowInfo.SegmentPair.Source.GetComments(); commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments()); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex); } if (success && CustomSettings.Colors.Count > 0) { try { success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors); }catch (Exception e) { } } //fuzzy if (success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax); } //unique if (success && CustomSettings.Unique) { var settings = new DisplayFilterSettings { RepetitionTypes = new List <string> { "FirstOccurrences" } }; var isFirst = rowInfo.IsRepetitionsFirstOccurrences(settings); if (isFirst) { return(true); } var isRepeted = rowInfo.SegmentPair.Properties.TranslationOrigin.IsRepeated; if (!isRepeted) { return(true); } return(false); } } return(success); }
private bool Reverse(bool success, DisplayFilterRowInfo rowInfo) { success = false; if (!success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any()) { success = rowInfo.IsSegmentReviewTypes(Settings); } if (!success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any()) { success = rowInfo.IsConfirmationLevelFound(Settings); } if (!success && Settings.OriginTypes != null && Settings.OriginTypes.Any()) { success = rowInfo.IsOriginTypeFound(Settings); } if (!success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any()) { success = rowInfo.IsPreviousOriginTypeFound(Settings); } if (!success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any()) { success = rowInfo.IsRepetitionTypes(Settings); } if (!success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any()) { success = rowInfo.IsSegmentLockingTypes(Settings); } if (!success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any()) { success = rowInfo.IsSegmentContentTypes(Settings); } if (!success && Settings.SourceText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInSource(Settings); } if (!success && Settings.TargetText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInTarget(Settings); } if (!success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInComment(Settings); } if (!success && Settings.CommentAuthor.Trim() != string.Empty) { success = rowInfo.IsAuthorFoundInComment(Settings); } if (!success && Settings.CommentSeverity > 0) { success = rowInfo.IsSeverityFoundInComment(Settings); } if (!success && Settings.ContextInfoTypes.Any()) { success = rowInfo.IsContextInfoTypes(Settings); } // check custom settings var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (!success && CustomSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (!success && CustomSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (!success && CustomSettings.SplitSegments) { success = SegmentNumbersHelper.IsSplitSegment(rowId, ActiveDocument); } if (!success && (CustomSettings.MergedSegments || CustomSettings.MergedAcross)) { success = SegmentNumbersHelper.IsMergedSegment(rowId, ActiveDocument, CustomSettings.MergedAcross); } if (!success && CustomSettings.SourceEqualsTarget) { success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, CustomSettings.IsEqualsCaseSensitive); } if (!success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList); } if (!success && CustomSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex)) { //create a list with source and target comments var commentsList = rowInfo.SegmentPair.Source.GetComments(); commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments()); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex); } if (!success && CustomSettings.Colors.Count > 0) { try { success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors); }catch (Exception e) { } } //fuzzy if (!success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax); } return(!success); }
public void CalculateAngle() { var vectorA = new Point() { X = 100, Y = 0 }; var vectorB = new Point() { X = -20, Y = 20 }; var fuzzyHelper = new FuzzyHelper(); var angle = fuzzyHelper.AngleBetweenVectors(vectorA, vectorB).ConvertRadiansToDegrees(); angle.ShouldBe(135, 0.5); vectorA = new Point() { X = 100, Y = 0 }; vectorB = new Point() { X = 20, Y = -20 }; angle = fuzzyHelper.AngleBetweenVectors(vectorA, vectorB); var quadrant = fuzzyHelper.InWhichQuadrant(vectorB); switch (quadrant) { case Quadrant.IV: angle = (2 * Math.PI - angle).Round(); break; case Quadrant.None: case Quadrant.I: default: break; } angle.ConvertRadiansToDegrees().ShouldBe(315, 0.5); vectorA = new Point() { X = 100, Y = 0 }; vectorB = new Point() { X = -20, Y = -20 }; angle = fuzzyHelper.AngleBetweenVectors(vectorA, vectorB); quadrant = fuzzyHelper.InWhichQuadrant(vectorB); switch (quadrant) { case Quadrant.III: case Quadrant.IV: angle = (2 * Math.PI - angle).Round(); break; case Quadrant.None: case Quadrant.I: default: break; } angle.ConvertRadiansToDegrees().ShouldBe(225, 0.5); }
private static LinguisticVariable CreateDexterity() { double a = 0; double b = 10; double h = 0.1; double x = 0; List <Term> terms = new List <Term>(); List <KeyValuePair <double, double> > list = new List <KeyValuePair <double, double> >(); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), -2.5, 0, 2.5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Clumsy", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0, 2.5, 5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Normal", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 2.5, 5, 7.5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Dexterous", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 5, 7.5, 10); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Gymnast", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 7.5, 10, 12.5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Ninja", new ContinuousFuzzySet <double, double>(list))); return(new LinguisticVariable("Dexterity", terms, null)); }
private static LinguisticVariable CreateWisdom() { double a = 0; double b = 10; double h = 0.1; double x = 0; List <Term> terms = new List <Term>(); List <KeyValuePair <double, double> > list = new List <KeyValuePair <double, double> >(); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), -2.5, 0, 2.5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Low", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 0, 2.5, 5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Medium", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 2.5, 5, 7.5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("High", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 5, 7.5, 10); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Master", new ContinuousFuzzySet <double, double>(list))); list.Clear(); for (x = a; x <= b; x += h) { double key = x; double value = FuzzyHelper.TriangleFunction(Math.Round(x, 10), 7.5, 10, 12.5); list.Add(new KeyValuePair <double, double>(Math.Round(key, 10), value)); } terms.Add(new Term("Professor", new ContinuousFuzzySet <double, double>(list))); return(new LinguisticVariable("Wisdom", terms, null)); }
public bool EvaluateRow(DisplayFilterRowInfo rowInfo) { var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment); if (rowInfo.IsSegment) { if (success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any()) { success = rowInfo.IsSegmentReviewTypes(Settings); } if (success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any()) { success = rowInfo.IsConfirmationLevelFound(Settings); } if (success && Settings.OriginTypes != null && Settings.OriginTypes.Any()) { success = rowInfo.IsOriginTypeFound(Settings); } if (success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any()) { success = rowInfo.IsPreviousOriginTypeFound(Settings); } if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any()) { success = rowInfo.IsRepetitionTypes(Settings); } if (success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any()) { success = rowInfo.IsSegmentLockingTypes(Settings); } if (success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any()) { success = rowInfo.IsSegmentContentTypes(Settings); } // if is revert search use custom helper method if (success && !CustomSettings.RevertSerach) { if (success && Settings.SourceText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInSource(Settings); } if (success && Settings.TargetText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInTarget(Settings); } } if (success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInComment(Settings); } if (success && Settings.CommentAuthor.Trim() != string.Empty) { success = rowInfo.IsAuthorFoundInComment(Settings); } if (success && Settings.CommentSeverity > 0) { success = rowInfo.IsSeverityFoundInComment(Settings); } if (success && Settings.ContextInfoTypes.Any()) { success = rowInfo.IsContextInfoTypes(Settings); } // check custom settings var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (success && CustomSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (success && CustomSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList); } if (success && CustomSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex)) { //create a list with source and target comments var commentsList = rowInfo.SegmentPair.Source.GetComments(); commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments()); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex); } //revert search if (success && CustomSettings.RevertSerach && Settings.SourceText.Trim() != string.Empty) { success = ContentHelper.ReverseSearch(rowInfo.SegmentPair.Source.GetString(), Settings.SourceText.Trim()); } if (success && CustomSettings.RevertSerach && Settings.TargetText.Trim() != string.Empty) { success = ContentHelper.ReverseSearch(rowInfo.SegmentPair.Target.GetString(), Settings.TargetText.Trim()); } if (success && CustomSettings.Colors.Count > 0) { if (CustomSettings.FileType != null) { if (CustomSettings.FileType.Contains("IDML")) { success = ColorPickerHelper.ContainsColorForIdmlFileType(rowInfo, CustomSettings.Colors); } else { success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors); } } } //fuzzy if (success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax); } } return(success); }