public virtual void TestExtraDependencies()
        {
            CoNLLUDocumentReader reader    = new CoNLLUDocumentReader();
            Reader stringReader            = new StringReader(ExtraDepsTestInput);
            IEnumerator <SemanticGraph> it = reader.GetIterator(stringReader);
            SemanticGraph sg = it.Current;

            NUnit.Framework.Assert.IsNotNull(sg);
            NUnit.Framework.Assert.IsFalse("The input only contains one dependency tree.", it.MoveNext());
            NUnit.Framework.Assert.IsTrue(sg.ContainsEdge(sg.GetNodeByIndex(4), sg.GetNodeByIndex(1)));
            NUnit.Framework.Assert.IsTrue(sg.ContainsEdge(sg.GetNodeByIndex(2), sg.GetNodeByIndex(7)));
            NUnit.Framework.Assert.IsTrue(sg.ContainsEdge(sg.GetNodeByIndex(4), sg.GetNodeByIndex(7)));
        }
Exemplo n.º 2
0
        public override void Evaluate(SemanticGraph sg, SemgrexMatcher sm)
        {
            bool        govWild = govName.Equals(WildcardNode);
            bool        depWild = depName.Equals(WildcardNode);
            IndexedWord govNode = GetNamedNode(govName, sm);
            IndexedWord depNode = GetNamedNode(depName, sm);

            if (govNode != null && depNode != null)
            {
                SemanticGraphEdge edge = sg.GetEdge(govNode, depNode, relation);
                if (edge != null)
                {
                    bool successFlag = sg.RemoveEdge(edge);
                }
            }
            else
            {
                if (depNode != null && govWild)
                {
                    // dep known, wildcard gov
                    foreach (SemanticGraphEdge edge in sg.IncomingEdgeIterable(depNode))
                    {
                        if (edge.GetRelation().Equals(relation) && sg.ContainsEdge(edge))
                        {
                            sg.RemoveEdge(edge);
                        }
                    }
                }
                else
                {
                    if (govNode != null && depWild)
                    {
                        // gov known, wildcard dep
                        foreach (SemanticGraphEdge edge in sg.OutgoingEdgeIterable(govNode))
                        {
                            if (edge.GetRelation().Equals(relation) && sg.ContainsEdge(edge))
                            {
                                sg.RemoveEdge(edge);
                            }
                        }
                    }
                }
            }
        }