Example #1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            CovingtonConfig that = (CovingtonConfig)obj;

            if (input.Count != that.Input.Count)
            {
                return(false);
            }
            if (dependencyGraph.NEdges() != that.DependencyGraph.NEdges())
            {
                return(false);
            }
            for (int i = 0; i < input.Count; i++)
            {
                if (input[i].Index != that.Input[i].Index)
                {
                    return(false);
                }
            }
            return(dependencyGraph.Edges.Equals(that.DependencyGraph.Edges));
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void apply(org.maltparser.parser.history.action.GuideUserAction currentAction, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override void apply(GuideUserAction currentAction, ParserConfiguration config)
        {
            CovingtonConfig covingtonConfig = (CovingtonConfig)config;

            currentAction.getAction(actionContainers);

            Edge e = null;

            switch (transActionContainer.ActionCode)
            {
            case LEFTARC:
                e = covingtonConfig.DependencyGraph.AddDependencyEdge(covingtonConfig.RightTarget.Index, covingtonConfig.LeftTarget.Index);
                addEdgeLabels(e);
                //			config.setArcParent(covingtonConfig.getRightTarget());
                //			config.setArcChild(covingtonConfig.getLeftTarget());
                break;

            case RIGHTARC:
                e = covingtonConfig.DependencyGraph.AddDependencyEdge(covingtonConfig.LeftTarget.Index, covingtonConfig.RightTarget.Index);
                addEdgeLabels(e);
                //			config.setArcParent(covingtonConfig.getLeftTarget());
                //			config.setArcChild(covingtonConfig.getRightTarget());
                break;

            default:
                //			config.setArcParent(null);
                //			config.setArcChild(null);
                break;
            }
            update(covingtonConfig, transActionContainer.ActionCode);
        }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean permissible(org.maltparser.parser.history.action.GuideUserAction currentAction, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override bool permissible(GuideUserAction currentAction, ParserConfiguration config)
        {
            CovingtonConfig      covingtonConfig = (CovingtonConfig)config;
            DependencyNode       leftTarget      = covingtonConfig.LeftTarget;
            DependencyNode       rightTarget     = covingtonConfig.RightTarget;
            IDependencyStructure dg = covingtonConfig.DependencyGraph;

            currentAction.getAction(actionContainers);
            int trans = transActionContainer.ActionCode;

            if (trans == SHIFT && covingtonConfig.AllowShift == false)
            {
                return(false);
            }
            if ((trans == LEFTARC || trans == RIGHTARC) && !ActionContainersLabeled)
            {
                return(false);
            }
            if (trans == LEFTARC && leftTarget.Root)
            {
                return(false);
            }
            if (trans == LEFTARC && dg.HasLabeledDependency(leftTarget.Index))
            {
                return(false);
            }
            if (trans == RIGHTARC && dg.HasLabeledDependency(rightTarget.Index))
            {
                return(false);
            }
            return(true);
        }
Example #4
0
 private void update(CovingtonConfig covingtonConfig, int trans)
 {
     if (trans == SHIFT)
     {
         covingtonConfig.Right = covingtonConfig.Right + 1;
         covingtonConfig.Left  = covingtonConfig.Right - 1;
     }
     else
     {
         DependencyNode rightNode = covingtonConfig.RightTarget;
         int            leftstop  = covingtonConfig.Leftstop;
         int            left      = covingtonConfig.Left;
         left--;
         DependencyNode leftNode = null;
         while (left >= leftstop)
         {
             leftNode = covingtonConfig.Input[left];
             if (rightNode.findComponent().Index != leftNode.findComponent().Index&& !(leftNode.hasHead() && rightNode.hasHead()))
             {
                 break;
             }
             left--;
         }
         if (left < leftstop)
         {
             covingtonConfig.Right = covingtonConfig.Right + 1;
             covingtonConfig.Left  = covingtonConfig.Right - 1;
         }
         else
         {
             covingtonConfig.Left = left;
         }
     }
 }
Example #5
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)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CovingtonConfig covingtonConfig = (CovingtonConfig)config;
            CovingtonConfig covingtonConfig = (CovingtonConfig)config;

            if (!covingtonConfig.AllowRoot && covingtonConfig.LeftTarget.Root)
            {
                return(updateActionContainers(history, NOARC, null));
            }
            return(null);
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.ParserConfiguration makeParserConfiguration() throws org.maltparser.core.exception.MaltChainedException
        public virtual ParserConfiguration makeParserConfiguration()
        {
            bool allowRoot  = (bool?)manager.getOptionValue("covington", "allow_root").Value;
            bool allowShift = (bool?)manager.getOptionValue("covington", "allow_shift").Value;

            if (manager.LoggerInfoEnabled)
            {
                manager.logInfoMessage("  Parser configuration : Covington with allow_root=" + allowRoot + " and allow_shift=" + allowShift + "\n");
            }
            CovingtonConfig config = new CovingtonConfig(allowRoot, allowShift);

            return(config);
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void update(CovingtonConfig covingtonConfig, int trans) throws org.maltparser.core.exception.MaltChainedException
        private void update(CovingtonConfig covingtonConfig, int trans)
        {
            if (trans == SHIFT || trans == RIGHTARC)
            {
                covingtonConfig.Right = covingtonConfig.Right + 1;
                covingtonConfig.Left  = covingtonConfig.Right - 1;
            }
            else
            {
                int leftstop = covingtonConfig.Leftstop;
                int left     = covingtonConfig.Left;
                if (trans == NOARC)
                {
                    IDependencyStructure dg       = covingtonConfig.DependencyStructure;
                    DependencyNode       leftNode = covingtonConfig.Input[covingtonConfig.Left];
                    if (dg.GetTokenNode(leftNode.Index) != null && dg.GetTokenNode(leftNode.Index).hasHead())
                    {
                        left = dg.GetTokenNode(leftNode.Index).Head.Index;
                    }
                    else
                    {
                        left = leftstop - 1;
                    }
                }
                else
                {
                    DependencyNode rightNode = covingtonConfig.RightTarget;
                    left--;
                    DependencyNode leftNode = null;
                    while (left >= leftstop)
                    {
                        leftNode = covingtonConfig.Input[left];
                        if (rightNode.findComponent().Index != leftNode.findComponent().Index)
                        {
                            break;
                        }
                        left--;
                    }
                }

                if (left < leftstop)
                {
                    covingtonConfig.Right = covingtonConfig.Right + 1;
                    covingtonConfig.Left  = covingtonConfig.Right - 1;
                }
                else
                {
                    covingtonConfig.Left = left;
                }
            }
        }
Example #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.parser.ParserConfiguration parserConfiguration) throws org.maltparser.core.exception.MaltChainedException
        public virtual void initialize(ParserConfiguration parserConfiguration)
        {
            if (parserConfiguration != null)
            {
                CovingtonConfig       covingtonConfig = (CovingtonConfig)parserConfiguration;
                List <DependencyNode> sourceInput     = covingtonConfig.Input;
                DependencyGraph = covingtonConfig.DependencyGraph;
                for (int i = 0, n = sourceInput.Count; i < n; i++)
                {
                    input.Add(dependencyGraph.GetDependencyNode(sourceInput[i].Index));
                }
                left      = covingtonConfig.Left;
                right     = covingtonConfig.Right;
                rightstop = covingtonConfig.Rightstop;
                leftstop  = covingtonConfig.Leftstop;
            }
            else
            {
                for (int i = 0, n = dependencyGraph.HighestTokenIndex; i <= n; i++)
                {
                    DependencyNode node = dependencyGraph.GetDependencyNode(i);
                    if (node != null)
                    {
                        input.Add(node);
                    }
                }
                if (allowRoot == true)
                {
                    leftstop = 0;
                }
                else
                {
                    leftstop = 1;
                }
                rightstop = dependencyGraph.HighestTokenIndex;
                left      = leftstop;
                right     = left + 1;
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void update(CovingtonConfig config) throws org.maltparser.core.exception.MaltChainedException
        private void update(CovingtonConfig config)
        {
            if (subFunction == CovingtonSubFunction.LEFT)
            {
                address.Address = config.getLeftNode(index);
            }
            else if (subFunction == CovingtonSubFunction.RIGHT)
            {
                address.Address = config.getRightNode(index);
            }
            else if (subFunction == CovingtonSubFunction.LEFTCONTEXT)
            {
                address.Address = config.getLeftContextNode(index);
            }
            else if (subFunction == CovingtonSubFunction.RIGHTCONTEXT)
            {
                address.Address = config.getRightContextNode(index);
            }
            else
            {
                address.Address = null;
            }
        }
Example #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.history.action.GuideUserAction predict(org.maltparser.core.syntaxgraph.DependencyStructure gold, org.maltparser.parser.ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException
        public override GuideUserAction predict(IDependencyStructure gold, ParserConfiguration config)
        {
            CovingtonConfig covingtonConfig  = (CovingtonConfig)config;
            DependencyNode  leftTarget       = covingtonConfig.LeftTarget;
            int             leftTargetIndex  = leftTarget.Index;
            int             rightTargetIndex = covingtonConfig.RightTarget.Index;

            if (!leftTarget.Root && gold.GetTokenNode(leftTargetIndex).Head.Index == rightTargetIndex)
            {
                return(updateActionContainers(NonProjective.LEFTARC, gold.GetTokenNode(leftTargetIndex).HeadEdge.LabelSet));
            }
            else if (gold.GetTokenNode(rightTargetIndex).Head.Index == leftTargetIndex)
            {
                return(updateActionContainers(NonProjective.RIGHTARC, gold.GetTokenNode(rightTargetIndex).HeadEdge.LabelSet));
            }
            else if (covingtonConfig.AllowShift == true && (!(gold.GetTokenNode(rightTargetIndex).hasLeftDependent() && gold.GetTokenNode(rightTargetIndex).LeftmostDependent.Index < leftTargetIndex) && !(gold.GetTokenNode(rightTargetIndex).Head.Index < leftTargetIndex && (!gold.GetTokenNode(rightTargetIndex).Head.Root || covingtonConfig.Leftstop == 0))))
            {
                return(updateActionContainers(NonProjective.SHIFT, null));
            }
            else
            {
                return(updateActionContainers(NonProjective.NOARC, null));
            }
        }