Exemplo n.º 1
0
        /// <summary>
        /// Generates a tree kernel from the specified expanded text.
        /// </summary>
        /// <param name="expandedText">The expanded text.</param>
        /// <returns>A tree kernel based on the expanded text</returns>
        public static TreeKernel Generate(List <string> expandedText, string pathToStopWords, string targetId, string stopwordId,
                                          string exclamationId, string capsId, string normalWordId)
        {
            //TODO Remember to tell Ope to add targetId and the rest to the constructor for the tree kernel
            var tree         = new TreeKernel("Root");
            var textanalyzer = new TextAnalyzer.TextAnalyzer(pathToStopWords);

            foreach (var word in expandedText)
            {
                if (word.StartsWith("@"))
                {
                    tree.AddNode(new TreeKernel(targetId));
                }
                else if (textanalyzer.IsStopWord(word))
                {
                    tree.AddNode(new TreeKernel(stopwordId));
                }
                else if (word.Equals("NOT"))
                {
                    tree.AddNode(new TreeKernel("NOT"));
                }
                else if (word.EndsWith("!"))
                {
                    tree.AddNode(new TreeKernel(exclamationId));
                }
                else
                {
                    tree.AddNode(new TreeKernel(normalWordId));
                    //TODO Tell Ope to create an indexer for the children of the tree kernel in order to
                    //TODO Explain the problem better
                    var item = tree.Children[(tree.Children.Length - 1)];
                    if (textanalyzer.IsCaps(word))
                    {
                        item.AddNode(new TreeKernel(capsId));
                    }
                    item.AddNode(new TreeKernel(word));
                    item.AddNode(new TreeKernel("POS"));
                }
            }
            return(tree);
        }
Exemplo n.º 2
0
 public void StopwordTest()
 {
     TextAnalyzer.TextAnalyzer TA = new Sentimantha.TextAnalyzer.TextAnalyzer(@"C:\Users\Opsi Jay\Documents\Visual Studio 2017\Projects\Sentimantha\Sentimantha\stopwords.txt");
     Assert.AreEqual("isn't", Maxxer.Expand("is not"));
 }