예제 #1
0
        private static IIndex BuildIndex(NotebooksFileDataSource storage)
        {
            Console.WriteLine($"Start indexing");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var indexBuilder = new InvertedIndexBuilder();
            var index        = indexBuilder.BuildIndex(storage);

            stopWatch.Stop();
            Console.WriteLine($"Indexing is finished in {stopWatch.ElapsedMilliseconds} ms");

            Console.WriteLine();
            Console.WriteLine($"Notebooks: {storage.GetAllNotebook().Count}.");
            Console.WriteLine($"Inverted index terms size: {index.Size()}.");
            Console.WriteLine($"Inverted index memory size: {GetObjectSize(index)}.");
            Console.WriteLine();

            return(index);
        }
 public void Test(Document[] documents, Dictionary <string, List <int> > expectedInvertedIndex)
 {
     Assert.That(InvertedIndexBuilder.BuildInvertedIndex(documents), Is.EqualTo(expectedInvertedIndex));
     Assert.That(InvertedIndexBuilder.BuildInvertedIndexSecondVersion(documents), Is.EqualTo(expectedInvertedIndex));
 }