public string GetIndex(PartItem partItem) { return(Stammer.Stamm(partItem.PartNumber) + @" " + String.Join(" ", partItem.Name.Split(' ').Select(Stammer.Stamm)) + @" " + Stammer.Stamm(partItem.Brand) + @" " + String.Join(@" ", partItem.Analogs.Split(' ').Select(Stammer.Stamm))); }
private float GetWeight(string text, string[] tokens) { var originTokens = GetTokens(text); float equals = originTokens.Count(tokens.Contains); equals = equals / originTokens.Length; float starts = (from o in originTokens from t in tokens where o.StartsWith(t) select o).Count(); starts = starts / originTokens.Length; float matches = (from o in originTokens from t in tokens where o.Contains(t) select(float) t.Length / o.Length).Sum(); matches = matches / _stammer.Stamm(text).Length; return((equals * 100 + starts * 5 + matches) / 3); }
public PartItem BuildFrom(CatalogImportItem item) { var analogs = String.Join(" ", item.Analogs.Select(a => a.Replace(" ", ""))); var partItem = new PartItem() { Balance = item.Balance, Brand = item.Brand, Commentary = item.Commentary, Name = item.Name, Price = item.Price, PartNumber = item.PartNumber, StammedPartNumber = Stammer.Stamm(item.PartNumber), SourceArgument = item.SourceArgument, Analogs = analogs }; partItem.SearchString = IndexFormatter.GetIndex(partItem); return(partItem); }
private string[] GetSearchTokens(string text) { return(text.Split(' ').Select(t => Stammer.Stamm(t)).Where(t => t.Length > 0).ToArray()); }
protected override IEnumerable <string> GetSearchTokens(string text) { return(text.Split(' ').Select(t => Stammer.Stamm(t)).Where(t => t.Length > 0).ToArray()); }