Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.history.action.GuideUserAction getDeterministicAction(org.maltparser.parser.history.GuideUserHistory history, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override GuideUserAction getDeterministicAction(GuideUserHistory history, ParserConfiguration config)
        {
            TwoPlanarConfig theConfig = (TwoPlanarConfig)config;

            if (theConfig.getRootHandling() != TwoPlanarConfig.NORMAL && theConfig.ActiveStack.Peek().Root)
            {
                return(updateActionContainers(history, SHIFT, null));
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// Gets the shortest pending link between (to or from) the input node and a node to the left of rightmostLimit, such that the link
        /// can be established on the given plane.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private org.maltparser.core.syntaxgraph.edge.Edge getFirstPendingLinkOnPlane(TwoPlanarConfig config, org.maltparser.core.syntaxgraph.DependencyStructure gold, int plane, int rightmostLimit) throws org.maltparser.core.exception.MaltChainedException
        private Edge getFirstPendingLinkOnPlane(TwoPlanarConfig config, IDependencyStructure gold, int plane, int rightmostLimit)
        {
            TwoPlanarConfig planarConfig = (TwoPlanarConfig)config;
            //DependencyStructure dg = planarConfig.getDependencyGraph(); -> no need, if rightmostLimit is well chosen, due to algorithm invariants
            int inputPeekIndex = planarConfig.Input.Peek().Index;

            Edge current = null;
            int  maxIndex;

            if (planarConfig.getRootHandling() == TwoPlanarConfig.NORMAL)
            {
                maxIndex = -1;                 //count links from dummy root
            }
            else
            {
                maxIndex = 0;                 //do not count links from dummy root
            }

            if (gold.GetTokenNode(inputPeekIndex).hasLeftDependent() && gold.GetTokenNode(inputPeekIndex).LeftmostDependent.Index < rightmostLimit)
            {
                SortedSet <DependencyNode> dependents = gold.GetTokenNode(inputPeekIndex).LeftDependents;
                for (IEnumerator <DependencyNode> iterator = dependents.GetEnumerator(); iterator.MoveNext();)
                {
                    DependencyNode dependent = (DependencyNode)iterator.Current;
                    if (dependent.Index > maxIndex && dependent.Index < rightmostLimit && getLinkDecision(dependent.HeadEdge, config) == plane)
                    {
                        maxIndex = dependent.Index;
                        current  = dependent.HeadEdge;
                    }
                }
            }

            //at this point, current is the first left-pointing link, but we have to check right-pointing link as well

            //System.out.println("in" + inputPeekIndex + " rl" + rightmostLimit);
            if (gold.GetTokenNode(inputPeekIndex).Head.Index < rightmostLimit)
            {
                //System.out.println(":");
                if (gold.GetTokenNode(inputPeekIndex).Head.Index > maxIndex && getLinkDecision(gold.GetTokenNode(inputPeekIndex).HeadEdge, config) == plane)
                {
                    //System.out.println("::");
                    current = gold.GetTokenNode(inputPeekIndex).HeadEdge;
                }
            }

            return(current);
        }