private void OnRule(char[] source, Rule rule, IList <MatchItem> result) { IList <MatchItem> ruleitems = OnMatchs(rule.Data, rule.Count); for (int i = 0; i < ruleitems.Count; i++) { MatchItem ritem = ruleitems[i]; MatchItem mitem = new MatchItem(); mitem.IsMatch = true; mitem.Data = source; for (int k = 0; k < ritem.KeyWordLength; k++) { int index = rule.Indes[ritem.KeyWordIndexs[k]]; mitem.Add(source[index], index); } result.Add(mitem); } }
public void Match(char[] data, int start, MatchItem result) { BlankType = Epoint.PingBiao.KAnalyze.WordType.None; int blank = MaxBlank; int count = LstItems.Count; BETIN: if (start >= data.Length) { result.IsMatch = false; return; } char key = Utils.Cast(data[start]); CharItem item = null; if (count == 1) { if (LstItems[0].Key == key) { item = LstItems[0]; } } else if (count == 2) { if (LstItems[0].Key == key) { item = LstItems[0]; } else { if (LstItems[1].Key == key) { item = LstItems[1]; } } } else { Items.TryGetValue(key, out item); } if (item != null) { result.IsMatch = true; result.Add(key, start); if (!item.Eof) { item.Match(data, start + 1, result); } } else { if (blank > 0 && (WordType & Utils.GetWordTypeWithChar(key)) == 0 && key != '\0') { WordType chartype = Utils.GetWordTypeWithChar(key); if (BlankType == Epoint.PingBiao.KAnalyze.WordType.None) { BlankType = chartype; } else { if (BlankType != chartype) { blank--; } BlankType = chartype; } start++; goto BETIN; } result.IsMatch = false; } }
public MatchItem Match(char[] data, int index) { MatchItem result = MatchItem; BlankType = Epoint.PingBiao.KAnalyze.WordType.None; result.Add(Key, index); int count = LstItems.Count; int blank = MaxBlank; BETIN: index++; if (index < data.Length) { char key = Utils.Cast(data[index]); CharItem item = null; if (count < 4) { for (int i = 0; i < count; i++) { item = LstItems[i]; if (item.Key == key) { break; } else { item = null; } } } else { Items.TryGetValue(key, out item); } if (item != null) { result.Data = data; result.IsMatch = true; result.Add(key, index); if (!item.Eof) { item.Match(data, index + 1, result); } } else { if (blank > 0 && (WordType & Utils.GetWordTypeWithChar(key)) == 0 && key != '\0') { WordType chartype = Utils.GetWordTypeWithChar(key); if (BlankType == Epoint.PingBiao.KAnalyze.WordType.None) { BlankType = chartype; } else { if (BlankType != chartype) { blank--; } BlankType = chartype; } goto BETIN; } } } Rule(result, data); return(result); }