/// <summary> /// Uses Levenshtein Distance to determine the closest string. Outputs the string and the distance /// </summary> /// <param name="context"></param> protected override void Execute(NativeActivityContext context) { LevenshteinEngine engine = new LevenshteinEngine(BaseString.Get(context)); Boolean first = true; foreach (String possible in Possibles.Get(context)) { int currentDistance = engine.Distance(possible); if (currentDistance < Distance.Get(context) || first) { Distance.Set(context, currentDistance); SelectedString.Set(context, possible); } first = false; } }
protected override void Execute(CodeActivityContext context) { IDistanceEngine engine = DistanceEngineFactory(BaseString.Get(context)); Distance.Set(context, engine.Distance(ComparisonString.Get(context))); }