Ejemplo n.º 1
0
        public void AnalyzeStrings_TryParse_False()
        {
            var analyze = new NgramAnalyzer.DiacriticMarksRestorer(_diacriticAdderMock.Object, _dictionaryMock.Object, null, null, null);

            analyze.SetData(_dataMock.Object);
            analyze.SetQueryProvider(_queryProviderMock.Object);
            analyze.SetNgram(NgramType.Bigram);
            var result = analyze.AnalyzeText("za przyjeciem");

            Assert.Equal(new List <string> {
                "za", " ", "przyjêciem"
            }, result);
        }
Ejemplo n.º 2
0
        public void AnalyzeStrings_Fourgrams_Only5Words()
        {
            var analyze = new NgramAnalyzer.DiacriticMarksRestorer(_diacriticAdderMock.Object, _dictionaryMock.Object, null, null, null);

            analyze.SetData(_dataMock.Object);
            analyze.SetQueryProvider(_queryProviderMock.Object);
            analyze.SetNgram(NgramType.Quadrigram);
            var result = analyze.AnalyzeText("za przyjeciem nowej uchwaly z");

            Assert.Equal(new List <string> {
                "za", " ", "przyjêciem", " ", "nowej", " ", "uchwa³y", " ", "z"
            }, result);
        }
Ejemplo n.º 3
0
        public void AnalyzeStrings_ToShortText()
        {
            var queryProviderMock  = new Mock <IQueryProvider>();
            var diacriticAdderMock = new Mock <ILetterChanger>();

            var analyze = new NgramAnalyzer.DiacriticMarksRestorer(diacriticAdderMock.Object, _dictionaryMock.Object, null, null, null);

            analyze.SetData(_dataMock.Object);
            analyze.SetQueryProvider(queryProviderMock.Object);
            analyze.SetNgram(NgramType.Bigram);
            var result = analyze.AnalyzeText("za");

            Assert.Equal(new List <string> {
                "za"
            }, result);
        }
Ejemplo n.º 4
0
        public void AnalyzeStrings_NgramVariantsCount0()
        {
            var tab2 = new DataTable();

            tab2.Columns.Add("ID", typeof(int));
            tab2.Columns.Add("Value", typeof(int));
            tab2.Columns.Add("Word1", typeof(string));
            var ds2 = new DataSet();

            ds2.Tables.Add(tab2);

            var tab1 = new DataTable();

            tab1.Columns.Add("ID", typeof(int));
            tab1.Columns.Add("Value", typeof(int));
            tab1.Columns.Add("Word1", typeof(string));
            tab1.Columns.Add("Word2", typeof(string));
            var ds1 = new DataSet();

            ds1.Tables.Add(tab1);

            var dataMock = new Mock <IDataAccess>();

            dataMock.Setup(m => m.ExecuteSqlCommand("uni1")).Returns(ds2);
            dataMock.Setup(m => m.ExecuteSqlCommand("di1")).Returns(ds1);
            dataMock.Setup(m => m.ExecuteSqlCommand("di2")).Returns(ds1);
            dataMock.Setup(m => m.ExecuteSqlCommand("di3")).Returns(ds1);
            dataMock.Setup(m => m.ExecuteSqlCommand("di4")).Returns(ds1);

            var analyze = new NgramAnalyzer.DiacriticMarksRestorer(_diacriticAdderMock.Object, _dictionaryMock.Object, null, null, null);

            analyze.SetData(dataMock.Object);
            analyze.SetQueryProvider(_queryProviderMock.Object);
            analyze.SetNgram(NgramType.Bigram);
            var result = analyze.AnalyzeText("za przyjeciem uchwaly");

            Assert.Equal(new List <string> {
                "za", " ", "przyjeciem", " ", "uchwaly"
            }, result);
        }