public InvertedIndex CreateIndex( params string[] documents ) { var result = new InvertedIndex(documents.Length); for (var i = 0; i < documents.Length; i++) { using (var reader = new StringReader(documents[i])) { var tokenSource = new TokenSource(reader); while (tokenSource.Next()) { if (_analyzer.Process(tokenSource)) { result.Append( new CharArraySegmentKey(tokenSource.Buffer, tokenSource.Size), i, tokenSource.Position); } } } } return(result); }
public IEnumerable <string> Analyze(string source) { using (var reader = new StringReader(source)) { var tokenSource = new TokenSource(reader); return(tokenSource.ReadAll(Process).ToArray()); } }
public string AnalyzeOnlyTheFirstToken(string source) { using (var reader = new StringReader(source)) { var tokenSource = new TokenSource(reader); tokenSource.Next(); Process(tokenSource); return(tokenSource.ToString()); } }
public bool Process(TokenSource source) { for (var i = 0; i < _filters.Length; i++) { if (!_filters[i].Process(source)) { return(false); } } return(true); }
private void ProcessDocument( InvertedIndex result, int documentIndex, TextReader reader ) { var tokenSource = new TokenSource(reader); while (tokenSource.Next()) { if (_analyzer.Process(tokenSource)) { result.Append( new CharArraySegmentKey(tokenSource.Buffer, tokenSource.Size), documentIndex, tokenSource.Position); } } }