Exemplo n.º 1
0
        public static void Test(StemmerBase stemmer, string language)
        {
            string dataPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "snowball"));

            string langPath = Path.Combine(dataPath, language);

            string inputFile  = Path.Combine(langPath, "voc.txt");
            string outputFile = Path.Combine(langPath, "output.txt");

            string input  = File.ReadAllText(inputFile);
            string output = File.ReadAllText(outputFile);

            Test(stemmer, input, output);
        }
Exemplo n.º 2
0
        public static void Test(StemmerBase stemmer, string input, string output)
        {
            var newline     = new[] { Environment.NewLine };
            var inputLines  = input.Split(newline, StringSplitOptions.None);
            var outputLines = output.Split(newline, StringSplitOptions.None);

            for (int i = 0; i < inputLines.Length; i++)
            {
                string word     = inputLines[i];
                string expected = outputLines[i];
                string actual   = stemmer.Stem(word);

                Assert.AreEqual(expected, actual);
            }
        }
Exemplo n.º 3
0
        public static void Test(StemmerBase stemmer, string language)
        {
            string snowballPath = Path.GetFullPath(Environment.CurrentDirectory);

            for (int i = 0; i < 5; i++)
            {
                snowballPath = Directory.GetParent(snowballPath).FullName;
            }

            string dataPath = Path.GetFullPath("Resources\\snowball\\");

            string langPath = Path.Combine(dataPath, language);

            string inputFile  = Path.Combine(langPath, "voc.txt");
            string outputFile = Path.Combine(langPath, "output.txt");

            string input  = File.ReadAllText(inputFile);
            string output = File.ReadAllText(outputFile);

            Test(stemmer, input, output);
        }
Exemplo n.º 4
0
 public TextPreprocessor(StemmerBase stemmer)
 {
     _stemmer  = stemmer;
     StopWords = new List <string>();
 }