Esempio n. 1
0
        /*
         * private void WordSenseDisambiguation(ParseTree parsetree)
         * {
         *   int j = 0;
         *   ArrayList arr = new ArrayList();
         *   if (parsetree.Root.Children != null)
         *   {
         *      words= wsd2(parsetree);
         *      foreach (string str in words)
         *      {
         *          string s = "";
         *          if (str == "NPP" || str == "PPJ")
         *          {
         *              s = str + ":" + parsetree.ResolvedAnaphora[j];
         *
         *          }
         *          else
         *          {
         *              s = str + ":" + parsetree.Words[j];
         *          }
         *          WordInfoArr.Add(s);
         *          j++;
         *      }
         *
         *      words = new ArrayList();
         *   }
         *   else
         *   {
         *
         *       //string str = parsetree.Words[j] + ":" + parsetree.Root.Goal.ToString();
         *       foreach (string str in words)
         *       {
         *            string s=str+":"+parsetree.Words[j]  ;
         *           WordInfoArr.Add(s);
         *           j++;
         *       }
         *
         *       words = new ArrayList();
         *
         *   }
         * }
         * private ArrayList wsd2(ParseTree parsetree)
         * {
         *
         *   ArrayList arr = new ArrayList();
         *   if (parsetree.Root.Children != null)
         *   {
         *       for (int i = 0; i < parsetree.Root.Children.Count; i++)
         *       {
         *           ParseNode pn = new ParseNode();
         *           pn = (ParseNode)parsetree.Root.Children[i];
         *           ParseTree p = new ParseTree(pn, parsetree.Words);
         *          words= wsd2(p);
         *       }
         *   }
         *   else
         *   {
         *       string goal = parsetree.Root.Goal;
         *       words.Add(goal);
         *
         *
         *   }
         *
         *   return words;
         * }
         */
        private void btnDiscourse_Click(object sender, EventArgs e)
        {
            ArrayList NewSParseTrees = new ArrayList();
            Discourse d        = new Discourse(SParseTrees);
            bool      modified = d.PrepareParseTrees();

            if (modified)
            {
                NewSParseTrees = d.NewSParseTrees;
                d.Begin(NewSParseTrees);
                Form2 f = new Form2();
                f.DisClasses = d.DistinctClasses;
                f.ParseTrees = NewSParseTrees;
                f.ShowDialog(this);
                d.ReturnSParseTrees();
                SParseTrees = d.SParseTrees;
            }
            else
            {
                d.Begin(SParseTrees);
                Form2 f = new Form2();
                f.DisClasses = d.DistinctClasses;
                f.ParseTrees = SParseTrees;
                f.ShowDialog(this);
            }
        }
Esempio n. 2
0
        private void DiscourseAnalysis()
        {
            ArrayList NewSParseTrees = new ArrayList();
            Discourse d        = new Discourse(SParseTrees);
            bool      modified = d.PrepareParseTrees();

            if (modified)
            {
                NewSParseTrees = d.NewSParseTrees;
                d.Begin(NewSParseTrees);
                Form2 f = new Form2();
                f.DisClasses = d.DistinctClasses;
                f.ParseTrees = NewSParseTrees;
                f.assigndiscoursedata();

                //f.ShowDialog(this);

                d.ReturnSParseTrees();
                SParseTrees = d.SParseTrees;
            }
            else
            {
                d.Begin(SParseTrees);
                Form2 f = new Form2();
                f.DisClasses = d.DistinctClasses;
                f.ParseTrees = SParseTrees;
                f.assigndiscoursedata();
                //f.ShowDialog(this);
            }
        }
Esempio n. 3
0
        //this methos discribes how to consume discourse
        private void UseDisCourse(object sender, System.EventArgs e)
        {
            Discourse d           = new Discourse();
            ArrayList SParseTrees = null;

            d.Begin(SParseTrees);//Here pass the parse trees array list
            ArrayList DisClasses = d.DistinctClasses;
            //Note:-you may not understand this paragragh accurately if so do not
            //care and read the example below
            //
            //this dictionary is an arraylist of array lists
            //each word being refered to has an outer arraylist.the inner array list contains DiscourseEntery
            //objects the first one represents the noun that is being refered to and the others represent the pronounsnoun nodes referencing
            //the original noun

            //Example:-
            //for sentences like this:
            //The boy plays football.He is happy.He is not crying.The Red planet is small.It is not soo far
            //in this example the DistinctClasses will contain two arraylist objects 1 For "The boy"
            //and the other for the "Red Planet".
            //the First array list for the "The boy" will contain 3 Dictionary enteries
            //1.Dictionary entery that contain the tree node for the "The boy"
            //2.Dictionary entery that contain the tree node for the first "HE"
            //3.Dictionary entery that contain the tree node for the Second "HE"
            //
            //the First array list for the "The Red Planet" will contain 2 Dictionary enteries
            //1.Dictionary entery that contain the tree node for the "The Red Planet"
            //3.Dictionary entery that contain the tree node for the Second "it"
            //
            //Note:- that the noun being refered to is always the first Dictionary entery in its arraylist


            //this loop generates a string that contain every referenced noun and the pronouns that refer to it
            string actualword = "";

            foreach (ArrayList arr in DisClasses)
            {
                foreach (DiscourseEntry de in arr)
                {
                    // here we get the acual text string that represents the node
                    string str = GetWordString((ParseTree)SParseTrees[de.TreeNum], de.Node) +
                                 " (" + ((int)(de.TreeNum + 1)).ToString() + "." + ((int)(de.Node.Start + 1)).ToString() + ")";
                    actualword += str + "\r\n";
                }
                actualword += "***************************************************\r\n";
            }
        }
Esempio n. 4
0
        private void DiscourseAnalysis()
        {
            ArrayList NewSParseTrees = new ArrayList();
            Discourse d        = new Discourse(SParseTrees);
            bool      modified = d.PrepareParseTrees();

            if (modified)
            {
                NewSParseTrees = d.NewSParseTrees;
                d.Begin(NewSParseTrees);
                DisplayDiscourseRes(d.DistinctClasses, NewSParseTrees);
                d.assigndiscoursedata(d.DistinctClasses, NewSParseTrees);
                d.ReturnSParseTrees();
                SParseTrees = d.SParseTrees;
            }
            else
            {
                d.Begin(SParseTrees);
                DisplayDiscourseRes(d.DistinctClasses, SParseTrees);
                d.assigndiscoursedata(d.DistinctClasses, SParseTrees);
            }
        }