Ejemplo n.º 1
0
        public void Load(string Path)
        {
            var reader      = XElement.Load(Path);
            var tokensquery = from c in reader.Elements("tokens").Elements("token")
                              select c;
            var tokens = new List <RSTWord>();

            foreach (var item in tokensquery)
            {
                var tk = new RSTWord();
                tk.id         = int.Parse(item.Attribute("id").Value);
                tk.Text       = item.Attribute("word").Value;
                tk.eduid      = int.Parse(item.Attribute("eduidx").Value);
                tk.sentenceid = int.Parse(item.Attribute("sidx").Value);
                tokens.Add(tk);
            }
            var query = from c in reader.Elements("rsttree").Elements("node")
                        select c;
            var treebankstr = (from c in reader.Elements("rstview") select c).First().Value;
            var input       = new java.io.StringReader(treebankstr);
            var treeReader  = new edu.stanford.nlp.trees.PennTreeReader(input);

            this.Root = new RSTNode();
            Root.Load(treeReader.readTree(), tokens);
        }
Ejemplo n.º 2
0
        public void EvaluateODonell(RSTNode Parent)
        {
            if (Parent.leaf)
            {
                return;
            }
            //evaluate children
            var Weight = this.Relations[Parent.relation];

            foreach (var child in Parent.Children)
            {
                if (child.type == RSTNodeType.Nucleus)
                {
                    child.Weight = Parent.Weight;
                }
                else
                {
                    child.Weight = Parent.Weight * Weight;
                }
            }
            foreach (var item in Parent.Children)
            {
                EvaluateODonell(item);
            }
        }
Ejemplo n.º 3
0
 private void TransformList(RSTNode node, List <RSTNode> state)
 {
     state.Add(node);
     foreach (var item in node.Children)
     {
         TransformList(item, state);
     }
 }
Ejemplo n.º 4
0
 public void CreateRelationEDUSentence(RSTNode Node, IGraphClient client)
 {
     //client.Cypher
     //    .Match("(a:RSTNode)", "(b:EduSentence)")
     //    .Where((RSTNode a) => a.name == Node.name)
     //    .AndWhere((EduSentence b) => b.Id == Node.EduSentence)
     //    .CreateUnique(string.Format("(a)-[:HAS]->(b)"))
     //    .ExecuteWithoutResults();
 }
Ejemplo n.º 5
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());
            }
        }