コード例 #1
0
        public void WordIsCachedAndWordIsInListAtMiddleShouldMatch()
        {
            var words = new List <string> {
                "foo"
            };
            var stopwordManager = new StopwordManager(words);

            stopwordManager.CacheIfStopword("foo").ShouldBe(true);
            stopwordManager.ShouldCheck().ShouldBe(true);
            stopwordManager.MatchAllStopwords("one bar foo two three").ShouldBe(true);
        }
コード例 #2
0
        public void WordIsCachedAndWordIsInListAtStartShouldMatch()
        {
            var words = new List <string> {
                "foo"
            };
            var stopwordManager = new StopwordManager(words);

            stopwordManager.CacheIfStopword("foo").ShouldBe(true);
            stopwordManager.ShouldCheck().ShouldBe(true);
            stopwordManager.MatchAllStopwords("foo bar one two").ShouldBe(true);
        }
コード例 #3
0
        public void WordIsCachedButWordNotInListShouldNotMatch()
        {
            var words = new List <string> {
                "foo"
            };
            var stopwordManager = new StopwordManager(words);

            stopwordManager.CacheIfStopword("foo").ShouldBe(true);
            stopwordManager.ShouldCheck().ShouldBe(true);
            stopwordManager.MatchAllStopwords("foolish").ShouldBe(false);
        }
コード例 #4
0
        public void MultipleWordsAreCachedAndOnlySomeWordsIsInListShouldNotMatch2()
        {
            var words = new List <string> {
                "foo", "doo", "coo"
            };
            var stopwordManager = new StopwordManager(words);

            stopwordManager.CacheIfStopword("foo").ShouldBe(true);
            stopwordManager.CacheIfStopword("doo fout").ShouldBe(true);
            stopwordManager.ShouldCheck().ShouldBe(true);
            stopwordManager.MatchAllStopwords("one bar foo two doo three").ShouldBe(false);
        }
コード例 #5
0
        public void WordNotInListIsNotCachedWithShouldCheckBeFalse()
        {
            var words = new List <string> {
                "foo", "doo", "coo"
            };
            var stopwordManager = new StopwordManager(words);

            stopwordManager.CacheIfStopword("bar").ShouldBe(false);
            stopwordManager.ShouldCheck().ShouldBe(false);
            // Don't be confused. This is returning true NOT because all stop words are matching,
            // but because we need to tell the caller the this case is not applicable since cache list is empty.
            stopwordManager.MatchAllStopwords("one bar foo two doo three").ShouldBe(true);
        }