Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.maltparser.core.syntaxgraph.edge.Edge addDependencyEdge(org.maltparser.core.syntaxgraph.node.DependencyNode head, org.maltparser.core.syntaxgraph.node.DependencyNode dependent) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual Edge.Edge addDependencyEdge(DependencyNode head, DependencyNode dependent)
        {
            if (head == null || dependent == null)
            {
                throw new SyntaxGraphException("Head or dependent node is missing.");
            }
            else if (!dependent.Root)
            {
                if (singleHeadedConstraint && dependent.hasHead())
                {
                    return(moveDependencyEdge(head, dependent));
                }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.syntaxgraph.node.DependencyNode hc = ((org.maltparser.core.syntaxgraph.node.DependencyNode)head).findComponent();
                DependencyNode hc = ((DependencyNode)head).findComponent();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.syntaxgraph.node.DependencyNode dc = ((org.maltparser.core.syntaxgraph.node.DependencyNode)dependent).findComponent();
                DependencyNode dc = ((DependencyNode)dependent).findComponent();
                if (hc != dc)
                {
                    link(hc, dc);
                    numberOfComponents--;
                }
                Edge.Edge e = edgePool.checkOut();
                e.BelongsToGraph = this;
                e.setEdge((Node.Node)head, (Node.Node)dependent, Edge_Fields.DEPENDENCY_EDGE);
                graphEdges.Add(e);
                return(e);
            }
            else
            {
                throw new SyntaxGraphException("Head node is not a root node or a terminal node.");
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.syntaxgraph.edge.Edge addPhraseStructureEdge(org.maltparser.core.syntaxgraph.node.PhraseStructureNode parent, org.maltparser.core.syntaxgraph.node.PhraseStructureNode child) throws org.maltparser.core.exception.MaltChainedException
        public virtual Edge.Edge addPhraseStructureEdge(PhraseStructureNode parent, PhraseStructureNode child)
        {
            if (parent == null || child == null)
            {
                throw new MaltChainedException("Parent or child node is missing in sentence " + SentenceID);
            }
            else if (parent.BelongsToGraph != this || child.BelongsToGraph != this)
            {
                throw new MaltChainedException("Parent or child node is not a member of the graph in sentence " + SentenceID);
            }
            else if (parent == child)
            {
                throw new MaltChainedException("It is not allowed to add a phrase structure edge connecting the same node in sentence " + SentenceID);
            }
            else if (parent is NonTerminalNode && !child.Root)
            {
                Edge.Edge e = edgePool.checkOut();
                e.BelongsToGraph = this;
                e.setEdge((Node.Node)parent, (Node.Node)child, Edge_Fields.PHRASE_STRUCTURE_EDGE);
                graphEdges.Add(e);
                return(e);
            }
            else
            {
                throw new MaltChainedException("Parent or child node is not of correct node type.");
            }
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.syntaxgraph.edge.Edge moveDependencyEdge(org.maltparser.core.syntaxgraph.node.DependencyNode newHead, org.maltparser.core.syntaxgraph.node.DependencyNode dependent) throws org.maltparser.core.exception.MaltChainedException
        public virtual Edge.Edge moveDependencyEdge(DependencyNode newHead, DependencyNode dependent)
        {
            if (dependent == null || !dependent.hasHead() || newHead.BelongsToGraph != this || dependent.BelongsToGraph != this)
            {
                return(null);
            }
            Edge.Edge headEdge = dependent.HeadEdge;

            LabelSet labels = null;

            if (headEdge.Labeled)
            {
                labels = CheckOutNewLabelSet();
                foreach (SymbolTable table in headEdge.LabelTypes)
                {
                    labels.put(table, headEdge.getLabelCode(table));
                }
            }
            headEdge.clear();
            headEdge.BelongsToGraph = this;
            headEdge.setEdge((Node.Node)newHead, (Node.Node)dependent, Edge_Fields.DEPENDENCY_EDGE);
            if (labels != null)
            {
                headEdge.addLabel(labels);
                labels.clear();
                CheckInLabelSet(labels);
            }
            return(headEdge);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.syntaxgraph.edge.Edge addDependencyEdge(org.maltparser.core.syntaxgraph.node.DependencyNode head, org.maltparser.core.syntaxgraph.node.DependencyNode dependent) throws org.maltparser.core.exception.MaltChainedException
        public virtual Edge.Edge addDependencyEdge(DependencyNode head, DependencyNode dependent)
        {
            if (head == null || dependent == null || head.BelongsToGraph != this || dependent.BelongsToGraph != this)
            {
                throw new SyntaxGraphException("Head or dependent node is missing.");
            }
            else if (!dependent.Root)
            {
                if (singleHeadedConstraint && dependent.hasHead())
                {
                    throw new SyntaxGraphException("The dependent already have a head. ");
                }
                DependencyNode hc = ((DependencyNode)head).findComponent();
                DependencyNode dc = ((DependencyNode)dependent).findComponent();
                if (hc != dc)
                {
                    link(hc, dc);
                    numberOfComponents--;
                }
                Edge.Edge e = edgePool.checkOut();
                e.BelongsToGraph = this;
                e.setEdge((Node.Node)head, (Node.Node)dependent, Edge_Fields.DEPENDENCY_EDGE);
                graphEdges.Add(e);
                return(e);
            }
            else
            {
                throw new SyntaxGraphException("Head node is not a root node or a terminal node.");
            }
        }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.syntaxgraph.edge.Edge addSecondaryEdge(org.maltparser.core.syntaxgraph.node.ComparableNode source, org.maltparser.core.syntaxgraph.node.ComparableNode target) throws org.maltparser.core.exception.MaltChainedException
        public virtual Edge.Edge addSecondaryEdge(ComparableNode source, ComparableNode target)
        {
            if (source == null || target == null)
            {
                throw new SyntaxGraphException("Head or dependent node is missing.");
            }
            else if (!target.Root)
            {
                Edge.Edge e = edgePool.checkOut();
                e.BelongsToGraph = this;
                e.setEdge((Node.Node)source, (Node.Node)target, Edge_Fields.SECONDARY_EDGE);
                graphEdges.Add(e);
                return(e);
            }
            return(null);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.syntaxgraph.edge.Edge addPhraseStructureEdge(org.maltparser.core.syntaxgraph.node.PhraseStructureNode parent, org.maltparser.core.syntaxgraph.node.PhraseStructureNode child) throws org.maltparser.core.exception.MaltChainedException
        public virtual Edge.Edge addPhraseStructureEdge(PhraseStructureNode parent, PhraseStructureNode child)
        {
            if (parent == null || child == null)
            {
                throw new MaltChainedException("Parent or child node is missing.");
            }
            else if (parent is NonTerminalNode && !child.Root)
            {
                Edge.Edge e = edgePool.checkOut();
                e.BelongsToGraph = this;
                e.setEdge((Node.Node)parent, (Node.Node)child, Edge_Fields.PHRASE_STRUCTURE_EDGE);
                graphEdges.Add(e);
                return(e);
            }
            else
            {
                throw new MaltChainedException("Parent or child node is not of correct node type.");
            }
        }
Beispiel #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.maltparser.core.syntaxgraph.edge.Edge moveDependencyEdge(org.maltparser.core.syntaxgraph.node.DependencyNode newHead, org.maltparser.core.syntaxgraph.node.DependencyNode dependent) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual Edge.Edge moveDependencyEdge(DependencyNode newHead, DependencyNode dependent)
        {
            if (dependent == null || !dependent.hasHead())
            {
                return(null);
            }
            Edge.Edge headEdge = dependent.HeadEdge;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LabelSet labels = checkOutNewLabelSet();
            LabelSet labels = CheckOutNewLabelSet();

            foreach (SymbolTable table in headEdge.LabelTypes)
            {
                labels.put(table, headEdge.getLabelCode(table));
            }
            headEdge.clear();
            headEdge.BelongsToGraph = this;
            headEdge.setEdge((Node.Node)newHead, (Node.Node)dependent, Edge_Fields.DEPENDENCY_EDGE);
            headEdge.addLabel(labels);
            labels.clear();
            CheckInLabelSet(labels);
            return(headEdge);
        }