Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void copyPartialDependencyStructure(DependencyStructure sourceGraph, DependencyStructure targetGraph) throws org.maltparser.core.exception.MaltChainedException
        public virtual void copyPartialDependencyStructure(IDependencyStructure sourceGraph, IDependencyStructure targetGraph)
        {
            SymbolTable partHead   = cachedSource.SymbolTables.getSymbolTable("PARTHEAD");
            SymbolTable partDeprel = cachedSource.SymbolTables.getSymbolTable("PARTDEPREL");

            if (partHead == null || partDeprel == null)
            {
                return;
            }
            SymbolTable deprel = cachedTarget.SymbolTables.getSymbolTable("DEPREL");

            foreach (int index in sourceGraph.TokenIndices)
            {
                DependencyNode snode = sourceGraph.GetTokenNode(index);
                DependencyNode tnode = targetGraph.GetTokenNode(index);
                if (snode != null && tnode != null)
                {
                    int    spartheadindex = int.Parse(snode.getLabelSymbol(partHead));
                    string spartdeprel    = snode.getLabelSymbol(partDeprel);
                    if (spartheadindex > 0)
                    {
                        Edge.Edge tedge = targetGraph.AddDependencyEdge(spartheadindex, snode.Index);
                        tedge.addLabel(deprel, spartdeprel);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Copies the edges of the source dependency structure to the target dependency structure
        /// </summary>
        /// <param name="source"> a source dependency structure </param>
        /// <param name="target"> a target dependency structure </param>
        /// <exception cref="MaltChainedException"> </exception>
        protected internal virtual void CopyEdges(IDependencyStructure source, IDependencyStructure target)
        {
            foreach (int index in source.TokenIndices)
            {
                DependencyNode sNode = source.GetDependencyNode(index);

                if (sNode.hasHead())
                {
                    Edge s = sNode.HeadEdge;

                    Edge t = target.AddDependencyEdge(s.Source.Index, s.Target.Index);

                    foreach (SymbolTable table in s.LabelTypes)
                    {
                        t.addLabel(table, s.getLabelSymbol(table));
                    }
                }
            }
        }