private IReadOnlyList <string> suggestAllFieldValues(string value, string language) { if (string.IsNullOrEmpty(value)) { throw new ArgumentException($"empty {nameof(value)}", nameof(value)); } var numericValues = new HashSet <string>(); bool valueIsInt = value.IsInt(); bool valueIsFloat = value.IsFloat(); if (valueIsInt || valueIsFloat) { foreach (var userField in _adapter.GetUserFields()) { bool matchesNumericType = _adapter.IsFloatField(userField) || _adapter.IsIntField(userField) && valueIsInt; if (!matchesNumericType) { continue; } var cache = GetValuesCache(userField, language); var similarNumbers = getNumericallySimilarValues(cache, value); numericValues.UnionWith(similarNumbers); } } var enumerable = numericValues .OrderBy(Str.Comparer) .Take(MaxCount); if (IsLoaded) { var spellcheckerValues = Spellchecker.SuggestSimilar(null, value, MaxCount); enumerable = enumerable .Concat(spellcheckerValues.Where(v => !numericValues.Contains(v))) .ToReadOnlyList(); } return(enumerable.ToReadOnlyList()); }
private IReadOnlyList <string> suggestValues(string userField, string language, string value) { if (string.IsNullOrEmpty(value)) { var cache = GetValuesCache(userField, language); return(new ListSegment <string>(cache, 0, MaxCount)); } if (_adapter.IsNumericField(userField)) { var cache = GetValuesCache(userField, language); return(getNumericallySimilarValues(cache, value).Take(MaxCount).ToReadOnlyList()); } if (!IsLoaded) { return(ReadOnlyList.Empty <string>()); } var spellcheckerField = _adapter.GetSpellcheckerFieldIn(userField, language); return(Spellchecker.SuggestSimilar(spellcheckerField, value, MaxCount)); }