Esempio n. 1
0
        static ArrayList GetPrepositions(ParseTree ps, ParseNode PRPLNode)
        {
            ArrayList Prepositions = new ArrayList();

            if (PRPLNode.Children != null)
            {
                foreach (ParseNode Child in PRPLNode.Children)
                {
                    if (Child.Goal == "PRP")
                    {
                        ParseNode prs = (ParseNode)Child.Children[0];
                        string    str = (string)ps.Words[prs.Start];
                        for (int i = prs.Start + 1; i < prs.End; i++)
                        {
                            str += "_" + ps.Words[i];
                        }
                        Prepositions.Add(str);
                    }
                    else
                    {
                        Prepositions.AddRange(VerbSense.GetPrepositions(ps, Child));
                    }
                }
            }
            return(Prepositions);
        }
Esempio n. 2
0
 static bool CheckForm29(string Input, ParseTree ps, ParseNode vnode, ParseNode pn)
 {
     if (pn == null)
     {
         return(false);
     }
     //SBJ ----s WETHER+VINF
     return(VerbSense.CheckForm26(Input, ps, vnode, pn));
 }
Esempio n. 3
0
        private bool FillVerbSenses(ParseTree ps, int percent, int threshold)
        {
            ArrayList CMPnodes = GetCMPNodes(ps.Root);

            CMPnodes.AddRange(GetSingleNodes(ps.Root));
            foreach (ParseNode pn in CMPnodes)
            {
                ParseNode vnode = GetVerbNode(pn);
                if (vnode == null)
                {
                    continue;
                }
                vnode.Senses = new ArrayList();
                string v = (string)ps.Words[vnode.Start];
                for (int i = vnode.Start + 1; i < vnode.End; i++)
                {
                    v += "_" + (string)ps.Words[i];
                }
                ArrayList verbs   = GetINFOfVerb(v);
                ParseNode cmpnode = (ParseNode)pn.Children[pn.Children.Count - 1];
                foreach (string vb in verbs)
                {
                    ArrayList senses = VerbSense.GetVerbSenses(vb, percent, threshold);
                    for (int i = 0; i < senses.Count; i++)
                    {
                        if (cmpnode.Goal == "CMPS")
                        {
                            if (((VerbSense)senses[i]).CheckValidity(ps, vnode, cmpnode))
                            {
                                vnode.Senses.Add(senses[i]);
                            }
                        }
                        else
                        {
                            if (((VerbSense)senses[i]).CheckValidity(ps, vnode, null))
                            {
                                vnode.Senses.Add(senses[i]);
                            }
                        }
                    }
                }
                if (vnode.Senses.Count == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 4
0
        private bool IsCorrectTree(ParseTree ps)
        {
            ParseNode first = (ParseNode)ps.Root.Children[0];

            if (first.Goal == "ADVS")
            {
                ParseNode advc = (ParseNode)((ParseNode)first.Children[0]).Children[0];
                if (advc.Goal == "ADVC")
                {
                    return(false);
                }
            }
            ArrayList CMPnodes = GetCMPNodes(ps.Root);

            foreach (ParseNode pn in CMPnodes)
            {
                ArrayList cmps = VerbSense.GetCMPList(pn);
                int       no   = 0;
                bool      verb = false;
                foreach (ParseNode cmp in cmps)
                {
                    ParseNode fch = (ParseNode)cmp.Children[0];
                    if (fch.Goal == "OBJ" || fch.Goal == "ADJ")
                    {
                        no++;
                    }
                    if (no > 2 || verb)
                    {
                        return(false);
                    }
                    if (ContainVerbs(fch))
                    {
                        verb = true;
                    }
                }
            }
            return(true);
        }
Esempio n. 5
0
        static bool GetNPs(ParseTree ps, ParseNode objNode)
        {
            bool np = true;

            if (objNode.Children != null)
            {
                foreach (ParseNode Child in objNode.Children)
                {
                    if (Child.Goal == "SOBJ")
                    {
                        ParseNode temp = (ParseNode)Child.Children[0];
                        if (temp.Goal != "NP" || !IsValidNP(temp))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        np &= VerbSense.GetNPs(ps, Child);
                    }
                }
            }
            return(np);
        }
Esempio n. 6
0
        public static ArrayList GetVerbSenses(string verb, int percent, int threshold)
        {
            WordNetClasses.WN wnc = new WordNetClasses.WN(Wnlib.WNCommon.path);
            bool      b           = false;
            SearchSet boj         = null;
            ArrayList list        = new ArrayList();

            wnc.OverviewFor(verb, "verb", ref b, ref boj, list);
            Search    vs     = (Search)list[0];
            ArrayList senses = new ArrayList();
            int       cut    = (int)Math.Ceiling(vs.senses.Count * percent / 100.0);

            if (cut < threshold)
            {
                cut = threshold;
            }
            foreach (SynSet ss in vs.senses)
            {
                /*
                 * if(--cut<0)
                 *      break;
                 */
                VerbSense vsense = new VerbSense();
                vsense.Sense   = verb + "#v#" + (ss.sense + 1).ToString();
                vsense.Structs = new ArrayList();
                foreach (SynSetFrame frame in ss.frames)
                {
                    SyntaxStruct st = new SyntaxStruct();
                    switch (frame.fr.str)
                    {
                    case "1":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm1);
                        break;

                    case "2":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm1);
                        break;

                    case "3":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm1);
                        break;

                    case "4":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm4);
                        break;

                    case "5":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm5);
                        break;

                    case "6":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm6);
                        break;

                    case "7":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm7);
                        break;

                    case "8":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm8);
                        break;

                    case "9":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm8);
                        break;

                    case "10":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm8);
                        break;

                    case "11":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm8);
                        break;

                    case "12":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm12);
                        st.Input = "TO";
                        break;

                    case "13":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm12);
                        st.Input = "ON";
                        break;

                    case "14":
                        st.Check = new SyntaxChecker(CheckForm14);
                        break;

                    case "15":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm15);
                        st.Input = "TO";
                        break;

                    case "16":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm15);
                        st.Input = "FROM";
                        break;

                    case "17":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm15);
                        st.Input = "WITH";
                        break;

                    case "18":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm15);
                        st.Input = "OF";
                        break;

                    case "19":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm15);
                        st.Input = "ON";
                        break;

                    case "20":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm20);
                        break;

                    case "21":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm20);
                        break;

                    case "22":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm22);
                        break;

                    case "23":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm1);
                        break;

                    case "24":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm24);
                        break;

                    case "25":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm25);
                        break;

                    case "26":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm26);
                        break;

                    case "27":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm12);
                        break;

                    case "28":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm28);
                        break;

                    case "29":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm29);
                        break;

                    case "30":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm30);
                        break;

                    case "31":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm15);
                        st.Input = "WITH";
                        break;

                    case "32":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm32);
                        break;

                    case "33":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm33);
                        break;

                    case "34":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm26);
                        break;

                    case "35":
                        st.Check = new SyntaxChecker(VerbSense.CheckForm32);
                        break;
                    }
                    vsense.Structs.Add(st);
                }
                senses.Add(vsense);
            }
            return(senses);
        }