Esempio n. 1
0
        public void Load(edu.stanford.nlp.trees.Tree treenode, List <Common.Token> Tokens)
        {
            //leaf node
            if (treenode.value() == "EDU")
            {
                this.edu          = new RSTEdu();
                this.edu.name     = int.Parse(treenode.firstChild().value());
                this.edu.tokens   = Tokens.Where(c => c.eduid == this.edu.name).ToList();
                this.edu.sentence = this.edu.tokens.Select(c => c.sentence).Distinct().Single();
            }
            else
            {
                var      str   = treenode.nodeString();
                string[] parts = str.Split('-');
                this.relation = parts[1];
                this.form     = parts[0];
                string ids      = parts[0];
                var    children = treenode.children();
                if (children.Count() > 2)
                {
                    throw new ApplicationException("error not supported scenario");
                }
                for (int i = 0; i < ids.Length; i++)
                {
                    var child   = children[i];
                    var rstnode = new RSTNode();

                    rstnode.Load(child, Tokens);
                    rstnode.nucleus = ids[i] == 'N';
                    this.children.Add(rstnode);
                }
            }
        }
Esempio n. 2
0
        public void Load(edu.stanford.nlp.trees.Tree treenode, List <RSTWord> Tokens)
        {
            //leaf node
            if (treenode.value() == "EDU")
            {
                this.leaf  = true;
                this.edu   = int.Parse(treenode.firstChild().value());
                this.Words = Tokens.Where(c => c.eduid == this.edu).ToList();
            }
            else
            {
                var      str   = treenode.nodeString();
                string[] parts = str.Split('-');
                this.relation = parts[1];
                this.form     = parts[0];
                string ids      = parts[0];
                var    children = treenode.children();
                if (children.Count() > 2)
                {
                    throw new ApplicationException("error not supported scenario");
                }
                for (int i = 0; i < ids.Length; i++)
                {
                    var child   = children[i];
                    var rstnode = new RSTNode();

                    rstnode.Load(child, Tokens);

                    if (ids[i] == 'N')
                    {
                        rstnode.type = RSTNodeType.Nucleus;
                    }
                    else
                    {
                        rstnode.type = RSTNodeType.Satellite;
                    }
                    this.Children.Add(rstnode);
                }
                this.Words = new List <RSTWord>(this.Children.SelectMany(c => c.Words).ToArray());
            }
        }