Exemple #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)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final NivreConfig nivreConfig = (NivreConfig)config;
            NivreConfig nivreConfig = (NivreConfig)config;

            if (!nivreConfig.EnforceTree)
            {
                if (!nivreConfig.AllowRoot && nivreConfig.Stack.Peek().Root)
                {
                    return(updateActionContainers(history, SHIFT, null));
                }
            }
            else
            {
                //Added
                if (!nivreConfig.AllowRoot && nivreConfig.Stack.Peek().Root&& !nivreConfig.End)
                {
                    return(updateActionContainers(history, SHIFT, null));
                }

                if (nivreConfig.Input.Count == 0 && nivreConfig.Stack.Peek().hasHead())
                {
                    return(updateActionContainers(history, REDUCE, null));
                }

                if (nivreConfig.Input.Count == 0 && !nivreConfig.Stack.Peek().hasHead())
                {
                    return(updateActionContainers(history, UNSHIFT, null));
                }
            }
            return(null);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initTransitionSystem(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public virtual void initTransitionSystem(GuideUserHistory history)
        {
            actionContainers = history.ActionContainerArray;
            if (actionContainers.Length < 1)
            {
                throw new ParsingException("Problem when initialize the history (sequence of actions). There are no action containers. ");
            }
            int nLabels = 0;

            for (int i = 0; i < actionContainers.Length; i++)
            {
                if (actionContainers[i].TableContainerName.StartsWith("A.", StringComparison.Ordinal))
                {
                    nLabels++;
                }
            }
            int j = 0;

            for (int i = 0; i < actionContainers.Length; i++)
            {
                if (actionContainers[i].TableContainerName.Equals("T.TRANS"))
                {
                    transActionContainer = actionContainers[i];
                }
                else if (actionContainers[i].TableContainerName.StartsWith("A.", StringComparison.Ordinal))
                {
                    if (arcLabelActionContainers == null)
                    {
                        arcLabelActionContainers = new ActionContainer[nLabels];
                    }
                    arcLabelActionContainers[j++] = actionContainers[i];
                }
            }
            initWithDefaultTransitions(history);
        }
Exemple #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Oracle(DependencyParserConfig manager, org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public Oracle(IDependencyParserConfig manager, GuideUserHistory history)
        {
            this.manager     = manager;
            this.history     = history;
            actionContainers = history.ActionContainerArray;

            if (actionContainers.Length < 1)
            {
                throw new ParsingException("Problem when initialize the history (sequence of actions). There are no action containers. ");
            }
            int nLabels = 0;

            for (int i = 0; i < actionContainers.Length; i++)
            {
                if (actionContainers[i].TableContainerName.StartsWith("A.", StringComparison.Ordinal))
                {
                    nLabels++;
                }
            }
            int j = 0;

            arcLabelActionContainers = new ActionContainer[nLabels];
            for (int i = 0; i < actionContainers.Length; i++)
            {
                if (actionContainers[i].TableContainerName.Equals("T.TRANS"))
                {
                    transActionContainer = actionContainers[i];
                }
                else if (actionContainers[i].TableContainerName.StartsWith("A.", StringComparison.Ordinal))
                {
                    arcLabelActionContainers[j++] = actionContainers[i];
                }
            }
        }
Exemple #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.history.action.GuideUserAction defaultAction(org.maltparser.parser.history.GuideUserHistory history, org.maltparser.parser.ParserConfiguration configuration) throws org.maltparser.core.exception.MaltChainedException
        public override GuideUserAction defaultAction(GuideUserHistory history, ParserConfiguration configuration)
        {
            if (((StackConfig)configuration).Input.Count == 0)
            {
                return(updateActionContainers(history, RIGHTARC, ((StackConfig)configuration).DependencyGraph.DefaultRootEdgeLabels));
            }
            return(updateActionContainers(history, SHIFT, null));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.guide.OracleGuide makeOracleGuide(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public override OracleGuide makeOracleGuide(GuideUserHistory history)
        {
            if (manager.LoggerInfoEnabled)
            {
                manager.logInfoMessage("  Oracle               : Covington\n");
            }
            return(new CovingtonOracle(manager, history));
        }
Exemple #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.guide.OracleGuide makeOracleGuide(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public override OracleGuide makeOracleGuide(GuideUserHistory history)
        {
            if (manager.LoggerInfoEnabled)
            {
                manager.logInfoMessage("  Oracle               : Projective\n");
            }
            return(new ProjectiveOracle(manager, history));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.guide.OracleGuide makeOracleGuide(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public override OracleGuide makeOracleGuide(GuideUserHistory history)
        {
            if (manager.LoggerInfoEnabled)
            {
                manager.logInfoMessage("  Oracle               : Planar Arc-Eager\n");
            }
            return(new PlanarArcEagerOracle(manager, history));
        }
Exemple #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.guide.OracleGuide makeOracleGuide(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public override OracleGuide makeOracleGuide(GuideUserHistory history)
        {
            if (manager.LoggerInfoEnabled)
            {
                manager.logInfoMessage("  Oracle               : Swap-Lazy\n");
            }
            return(new SwapLazyOracle(manager, history));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.guide.OracleGuide makeOracleGuide(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public override OracleGuide makeOracleGuide(GuideUserHistory history)
        {
            if (manager.LoggerInfoEnabled)
            {
                manager.logInfoMessage("  Oracle               : Arc-Standard\n");
            }
            return(new ArcStandardOracle(manager, history));
        }
Exemple #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ComplexDecisionAction(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public ComplexDecisionAction(GuideUserHistory history)
        {
            this.history = history;
            decisions    = new List <SimpleDecisionAction>(history.DecisionTables.Count);
            for (int i = 0, n = history.DecisionTables.Count; i < n; i++)
            {
                decisions.Add(new SimpleDecisionAction(history.KBestSize, history.DecisionTables[i]));
            }
        }
Exemple #11
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)
        {
            NivreConfig nivreConfig = (NivreConfig)config;

            if (!nivreConfig.AllowRoot && nivreConfig.Stack.Peek().Root)
            {
                return(updateActionContainers(history, SHIFT, null));
            }
            return(null);
        }
Exemple #12
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);
        }
Exemple #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void initWithDefaultTransitions(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        protected internal override void initWithDefaultTransitions(GuideUserHistory history)
        {
            GuideUserAction currentAction = new ComplexDecisionAction(history);

            transActionContainer.Action = SHIFT;
            for (int i = 0; i < arcLabelActionContainers.Length; i++)
            {
                arcLabelActionContainers[i].Action = -1;
            }
            currentAction.addAction(actionContainers);
        }
Exemple #14
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);
        }
Exemple #15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void initWithDefaultTransitions(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        protected internal override void initWithDefaultTransitions(GuideUserHistory history)
        {
            GuideUserAction currentAction = new ComplexDecisionAction(history);

            transActionContainer.Action = SHIFT;
            transActionContainer.Action = REDUCE;
            transActionContainer.Action = SWITCH;             //TODO it seems like a good idea to do this, but I don't know what it actually does
            transActionContainer.Action = REDUCEBOTH;         //TODO same as above
            for (int i = 0; i < arcLabelActionContainers.Length; i++)
            {
                arcLabelActionContainers[i].Action = -1;
            }
            currentAction.addAction(actionContainers);
        }
Exemple #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ParserState(DependencyParserConfig manager, org.maltparser.core.symbol.SymbolTableHandler symbolTableHandler, AbstractParserFactory factory) throws org.maltparser.core.exception.MaltChainedException
        public ParserState(IDependencyParserConfig manager, SymbolTableHandler symbolTableHandler, AbstractParserFactory factory)
        {
            this.factory     = factory;
            historyStructure = new HistoryList();
            transitionSystem = factory.makeTransitionSystem();
            string decisionSettings = manager.getOptionValue("guide", "decision_settings").ToString().Trim();

            TransitionSystem.initTableHandlers(decisionSettings, symbolTableHandler);
            int    kBestSize           = ((int?)manager.getOptionValue("guide", "kbest")).Value;
            string classitem_separator = manager.getOptionValue("guide", "classitem_separator").ToString();

            history = new History.History(decisionSettings, classitem_separator, TransitionSystem.TableHandlers, kBestSize);
            TransitionSystem.initTransitionSystem(history);
            config = factory.makeParserConfiguration();
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.maltparser.parser.history.action.GuideUserAction updateActionContainers(org.maltparser.parser.history.GuideUserHistory history, int transition, org.maltparser.core.syntaxgraph.LabelSet arcLabels) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual GuideUserAction updateActionContainers(GuideUserHistory history, int transition, LabelSet arcLabels)
        {
            transActionContainer.Action = transition;

            if (arcLabels == null)
            {
                for (int i = 0; i < arcLabelActionContainers.Length; i++)
                {
                    arcLabelActionContainers[i].Action = -1;
                }
            }
            else
            {
                for (int i = 0; i < arcLabelActionContainers.Length; i++)
                {
                    if (arcLabelActionContainers[i] == null)
                    {
                        throw new MaltChainedException("arcLabelActionContainer " + i + " is null when doing transition " + transition);
                    }

                    int?code = arcLabels.get(arcLabelActionContainers[i].Table);
                    if (code != null)
                    {
                        arcLabelActionContainers[i].Action = code.Value;
                    }
                    else
                    {
                        arcLabelActionContainers[i].Action = -1;
                    }
                }
            }
            GuideUserAction oracleAction = history.EmptyGuideUserAction;

            oracleAction.addAction(actionContainers);
            return(oracleAction);
        }
Exemple #18
0
 public abstract OracleGuide makeOracleGuide(GuideUserHistory history);
Exemple #19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public SwapLazyOracle(org.maltparser.parser.DependencyParserConfig manager, org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public SwapLazyOracle(IDependencyParserConfig manager, GuideUserHistory history) : base(manager, history)
        {
            GuideName = "swaplazy";
            swapArray = new List <int>();
        }
Exemple #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.parser.history.action.GuideUserAction defaultAction(org.maltparser.parser.history.GuideUserHistory history, org.maltparser.parser.ParserConfiguration configuration) throws org.maltparser.core.exception.MaltChainedException
        public override GuideUserAction defaultAction(GuideUserHistory history, ParserConfiguration configuration)
        {
            return(updateActionContainers(history, SHIFT, null));
        }
Exemple #21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public CovingtonOracle(org.maltparser.parser.DependencyParserConfig manager, org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public CovingtonOracle(IDependencyParserConfig manager, GuideUserHistory history) : base(manager, history)
        {
            GuideName = "NonProjective";
        }
Exemple #22
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ArcEagerOracle(org.maltparser.parser.DependencyParserConfig manager, org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public ArcEagerOracle(IDependencyParserConfig manager, GuideUserHistory history) : base(manager, history)
        {
            GuideName = "ArcEager";
        }
Exemple #23
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)
        {
            return(null);
        }
Exemple #24
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ProjectiveOracle(org.maltparser.parser.DependencyParserConfig manager, org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException
        public ProjectiveOracle(IDependencyParserConfig manager, GuideUserHistory history) : base(manager, history)
        {
            GuideName = "projective";
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public abstract org.maltparser.parser.history.action.GuideUserAction getDeterministicAction(org.maltparser.parser.history.GuideUserHistory history, ParserConfiguration config) throws org.maltparser.core.exception.MaltChainedException;
        public abstract GuideUserAction getDeterministicAction(GuideUserHistory history, ParserConfiguration config);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected abstract void initWithDefaultTransitions(org.maltparser.parser.history.GuideUserHistory history) throws org.maltparser.core.exception.MaltChainedException;
        protected internal abstract void initWithDefaultTransitions(GuideUserHistory history);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public abstract org.maltparser.parser.history.action.GuideUserAction defaultAction(org.maltparser.parser.history.GuideUserHistory history, ParserConfiguration configuration) throws org.maltparser.core.exception.MaltChainedException;
        public abstract GuideUserAction defaultAction(GuideUserHistory history, ParserConfiguration configuration);