private void NavigateSaveToBasicXML(SimpleGraphNode parent, RSTNode node, List <SimpleGraphNode> nodes, List <SimpleGraphRelation> relations) { foreach (var item in node.children) { if (item.children.Count == 0) { SimpleGraphNode child = new SimpleGraphNode() { Id = nodes.Count + 1, Label = string.Format("{0} ({1})", item.relation == "textualorganization" ? "same-unit": item.relation, item.weight) }; nodes.Add(child); relations.Add(new SimpleGraphRelation() { Start = parent.Id, End = child.Id, Label = "-" }); NavigateSaveToBasicXMLTokens(child, item.edu, nodes, relations); } else { SimpleGraphNode child = new SimpleGraphNode() { Id = nodes.Count + 1, Label = string.Format("{1}-{2} ({0})", item.weight, item.form, item.relation == "textualorganization" ? "same-unit" : item.relation) }; nodes.Add(child); relations.Add(new SimpleGraphRelation() { Start = parent.Id, End = child.Id, Label = item.relation == "textualorganization" ? "same-unit" : item.relation }); NavigateSaveToBasicXML(child, item, nodes, relations); } } }
private void EvaluateODonell(RSTNode Current) { if (Current.edu != null) { Current.edu.weight = Current.weight; return; } //evaluate children var Weight = this.Relations[Current.relation]; foreach (var child in Current.children) { if (child.nucleus) { child.weight = Current.weight; } else { child.weight = Current.weight * Weight; } } foreach (var item in Current.children) { EvaluateODonell(item); } }
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); } } }
private void TransformList(RSTNode node, List <RSTNode> state) { state.Add(node); foreach (var item in node.children) { TransformList(item, state); } }
private void DummyODonell(RSTNode current, double value) { if (current.edu != null) { current.edu.weight = value; return; } foreach (var item in current.children) { item.weight = value; DummyODonell(item, value); } }