Ejemplo n.º 1
0
        private void AddDocument(Document document, IAnalyzer analyzer)
        {
            if (document.Key == Guid.Empty)
                document.Key = Guid.NewGuid();

            DocumentStorage.Add(document);

            System.Diagnostics.Debug.Assert(document.Value.CanSeek);
            document.Value.Seek(0, SeekOrigin.Begin);
            var termPositions = analyzer.GetTermPositions(document.Value);
            foreach(var termPositionsGroup in termPositions.GroupBy(a=>a.Term))
            {
                var term = new Term(
                    termPositionsGroup.Key,
                    termPositionsGroup.Select(a => new DocumentLocation { Document = document.Key, Span = a.Span }));

                TermStorage.Add(term);
            }
        }