Beispiel #1
0
        public void ParseToSoundexTest(string name, string expected)
        {
            DiskSoundEx soundEx = new DiskSoundEx("./");
            var         actual  = soundEx.ParseToSoundex(name);

            actual.Should().Be(expected);
            soundEx.Clear();
        }
Beispiel #2
0
        public void SoundexIndexTest()
        {
            IDocumentCorpus corpus     = DirectoryCorpus.LoadTextDirectory(directory);
            DiskSoundEx     soundIndex = new DiskSoundEx("./");

            soundIndex.BuildSoundexIndex(corpus);
            soundIndex.GetCount().Should().Be(5);
            soundIndex.Clear();
        }
Beispiel #3
0
        public void GetPostingsTest_MultipleNames()
        {
            //Arrange
            IDocumentCorpus corpus      = DirectoryCorpus.LoadTextDirectory(directory);
            DiskSoundEx     authorIndex = new DiskSoundEx("./");

            authorIndex.BuildSoundexIndex(corpus);
            //Act
            var actual = authorIndex.GetPostings("yashua ovando");

            //Assert
            actual.Should().HaveCount(2);
            authorIndex.Clear();
        }
Beispiel #4
0
        public void GetPostingsTest_NotExistingName_ReturnsEmpty()
        {
            //Arrange
            IDocumentCorpus corpus      = DirectoryCorpus.LoadTextDirectory(directory);
            DiskSoundEx     authorIndex = new DiskSoundEx("./");

            authorIndex.BuildSoundexIndex(corpus);
            //Act
            var actual = authorIndex.GetPostings("hella");

            //Assert
            actual.Should().BeEmpty();
            authorIndex.Clear();
        }
Beispiel #5
0
        public void AddDocIDByAuthorTest_InputExceptionWithSpace()
        {
            //Arrange
            DiskSoundEx authorIndex = new DiskSoundEx("./");

            //Act
            authorIndex.AddDocIdByAuthor(" sella", 1);
            authorIndex.AddDocIdByAuthor("sella  ", 2);
            authorIndex.AddDocIdByAuthor("yashua  ovando", 2);
            authorIndex.AddDocIdByAuthor(" yashua     ovando     ", 3);
            authorIndex.Save();
            //Assert
            authorIndex.GetSoundexVocab().Should().HaveCount(3);
            authorIndex.Clear();
        }
Beispiel #6
0
        public void GetPostingsTest_SimilarSoundingName()
        {
            //Arrange
            IDocumentCorpus corpus      = DirectoryCorpus.LoadTextDirectory(directory);
            DiskSoundEx     authorIndex = new DiskSoundEx("./");

            authorIndex.BuildSoundexIndex(corpus);
            //Act
            var result1 = authorIndex.GetPostings("bloclic");
            var result2 = authorIndex.GetPostings("blacklock");

            //Assert
            result1.Should().BeEquivalentTo(result2);
            authorIndex.Clear();
        }
Beispiel #7
0
        public void AddDocIDByAuthorTest()
        {
            //Arrange
            DiskSoundEx authorIndex = new DiskSoundEx("./");

            //Act
            authorIndex.AddDocIdByAuthor("sella", 1);
            authorIndex.AddDocIdByAuthor("selly", 2);
            authorIndex.AddDocIdByAuthor("yashua", 3);
            authorIndex.AddDocIdByAuthor("yoshi", 4);
            authorIndex.AddDocIdByAuthor("yesh", 5);
            authorIndex.Save();

            //Assert
            authorIndex.GetSoundexVocab().Should().HaveCount(2);
            authorIndex.Get("S440").Should().HaveCount(2);
            authorIndex.Get("Y200").Should().HaveCount(3);

            authorIndex.Clear();
        }