internal ICollection <SearchResultFromHead2Left <TValue> > FindFromHead2Left(SsWord headWord) { var ss = default(SortedSet <SearchResultFromHead2Left <TValue> >); var finder = Finder.Create(_root); int index = 0; for (var word = headWord; word != null; word = word.next) { var node = finder.Find(word.valueOriginal); if (node.HasNgrams) { foreach (var ngram in node.Ngrams) { var wordIndex = index - ngram.Words.Length + 1; if (wordIndex == 0) { if (ss == null) { ss = new SortedSet <SearchResultFromHead2Left <TValue> >(SearchResultOfHead2LeftComparer.Instance); } var r = ss.Add(new SearchResultFromHead2Left <TValue>(word, ngram.Words.Length, ngram.Value)); System.Diagnostics.Debug.Assert(r); } } } index++; } if (ss != null) { return(ss); } return(EMPTY_RESULT_2); }
internal ICollection <SearchResult <TValue> > FindAll(DirectAccessList <SsWord> words) { var ss = default(SortedSet <SearchResult <TValue> >); var finder = Finder.Create(_root); for (int index = 0, len = words.Count; index < len; index++) { var node = finder.Find(words._Items[index].valueOriginal); if (node.HasNgrams) { if (ss == null) { ss = new SortedSet <SearchResult <TValue> >(SearchResultComparer.Instance); } foreach (var ngram in node.Ngrams) { var r = ss.Add(new SearchResult <TValue>(index - ngram.Words.Length + 1, ngram.Words.Length, ngram.Value)); System.Diagnostics.Debug.Assert(r); } } } if (ss != null) { return(ss); } return(EMPTY_RESULT_1); }
private SortedSet <SearchResult> FindAllSensitiveCaseInternal(List <Word> words) { var ss = default(SortedSet <SearchResult>); var finder = Finder.Create(_root); for (int index = 0, len = words.Count; index < len; index++) { var valueOriginal = words[index].valueOriginal; if (valueOriginal == null) { continue; } var node = finder.Find(valueOriginal); if (node.HasNgrams) { if (ss == null) { ss = new SortedSet <SearchResult>(SearchResultIComparer.Instance); } foreach (var ngram in node.Ngrams) { ss.Add(new SearchResult(index - ngram.Length + 1, ngram.Length)); } } } return(ss); }
internal ICollection <SearchResult <T> > FindAll(IList <ss_word_t> words) { var ss = default(SortedSet <SearchResult <T> >); var finder = Finder.Create(_Root); for (int index = 0, len = words.Count; index < len; index++) { var node = finder.Find(words[index].valueOriginal); if (node.HasNgrams) { if (ss == null) { ss = new SortedSet <SearchResult <T> >(SearchResult <T> .Comparer.Inst); } foreach (var ngram in node.Ngrams) { var r = ss.Add(new SearchResult <T>(index - ngram.words.Length + 1, ngram.words.Length, ngram.value)); Debug.Assert(r); } } } if (ss != null) { return(ss); } return(EMPTY_RESULT_1); }
private SortedSet <SearchResult> FindAllInternal(List <word_t> words) { var ss = default(SortedSet <SearchResult>); var finder = Finder.Create(_Root); for (int index = 0, len = words.Count; index < len; index++) { if (finder.Find(words[index], out var node) && node.HasNgrams) { if (ss == null) { ss = new SortedSet <SearchResult>(SearchResult.Comparer.Instance); } foreach (var ngram in node.Ngrams) { ss.Add(new SearchResult(index - ngram.NerOutputTypes.Length + 1, ngram.NerOutputTypes.Length, ngram.ResultNerOutputType)); } } } return(ss); }