Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(Object[] arguments) throws org.maltparser.core.exception.MaltChainedException
        public void initialize(object[] arguments)
        {
            if (arguments.Length != 2)
            {
                throw new FeatureException("Could not initialize PrefixFeature: number of arguments are not correct. ");
            }
            if (!(arguments[0] is FeatureFunction))
            {
                throw new FeatureException("Could not initialize PrefixFeature: the first argument is not a feature. ");
            }
            if (!(arguments[1] is int?))
            {
                throw new FeatureException("Could not initialize PrefixFeature: the second argument is not a string. ");
            }
            ParentFeature = (FeatureFunction)arguments[0];
            PrefixLength  = ((int?)arguments[1]).Value;
            ColumnDescription parentColumn = dataFormatInstance.getColumnDescriptionByName(parentFeature.SymbolTable.Name);

            if (parentColumn.Type != ColumnDescription.STRING)
            {
                throw new FeatureException("Could not initialize PrefixFeature: the first argument must be a string. ");
            }
            Column      = dataFormatInstance.addInternalColumnDescription(tableHandler, "PREFIX_" + prefixLength + "_" + parentFeature.SymbolTable.Name, parentColumn);
            SymbolTable = tableHandler.getSymbolTable(column.Name);
            //		setSymbolTable(tableHandler.addSymbolTable("PREFIX_"+prefixLength+"_"+parentFeature.getSymbolTable().getName(), parentFeature.getSymbolTable()));
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(Object[] arguments) throws org.maltparser.core.exception.MaltChainedException
        public void initialize(object[] arguments)
        {
            if (arguments.Length != 3)
            {
                throw new FeatureException("Could not initialize InputArcFeature: number of arguments are not correct. ");
            }
            // Checks that the two arguments are address functions

            if (!(arguments[0] is string))
            {
                throw new FeatureException("Could not initialize InputArcFeature: the first argument is not a string. ");
            }
            if (!(arguments[1] is AddressFunction))
            {
                throw new SyntaxGraphException("Could not initialize InputArcFeature: the second argument is not an address function. ");
            }
            if (!(arguments[2] is AddressFunction))
            {
                throw new SyntaxGraphException("Could not initialize InputArcFeature: the third argument is not an address function. ");
            }
            AddressFunction1 = (AddressFunction)arguments[1];
            AddressFunction2 = (AddressFunction)arguments[2];

            Column      = dataFormatInstance.getColumnDescriptionByName((string)arguments[0]);
            SymbolTable = tableHandler.addSymbolTable("ARC_" + column.Name, ColumnDescription.INPUT, ColumnDescription.STRING, "one");
            table.addSymbol("LEFT");
            table.addSymbol("RIGHT");
        }
Пример #3
0
        /// <summary>
        /// Creates a propagation object based on the propagation specification
        /// </summary>
        /// <param name="spec"> a propagation specification </param>
        /// <param name="dataFormatInstance"> a data format instance </param>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Propagation(org.maltparser.core.propagation.spec.PropagationSpec spec, org.maltparser.core.io.dataformat.DataFormatInstance dataFormatInstance, org.maltparser.core.symbol.SymbolTableHandler tableHandler) throws org.maltparser.core.exception.MaltChainedException
        public Propagation(PropagationSpec spec, DataFormatInstance dataFormatInstance, SymbolTableHandler tableHandler)
        {
            ColumnDescription fromColumn = dataFormatInstance.getColumnDescriptionByName(spec.From);

            if (fromColumn == null)
            {
                throw new PropagationException("The symbol table '" + spec.From + " does not exists.");
            }
            fromTable = tableHandler.getSymbolTable(spec.From);

            ColumnDescription toColumn = dataFormatInstance.getColumnDescriptionByName(spec.To);

            if (toColumn == null)
            {
                toColumn = dataFormatInstance.addInternalColumnDescription(tableHandler, spec.To, fromColumn);
                toTable  = tableHandler.getSymbolTable(spec.To);
            }


            forSet = new SortedSet <string>();
            if (!ReferenceEquals(spec.For, null) && spec.For.Length > 0)
            {
                string[] items = spec.For.Split("\\|", true);

                foreach (string item in items)
                {
                    forSet.Add(item);
                }
            }

            overSet = new SortedSet <string>();
            if (!ReferenceEquals(spec.Over, null) && spec.Over.Length > 0)
            {
                string[] items = spec.Over.Split("\\|", true);

                foreach (string item in items)
                {
                    overSet.Add(item);
                }
            }

            //		ColumnDescription deprelColumn = dataFormatInstance.getColumnDescriptionByName("DEPREL");
            deprelTable     = tableHandler.getSymbolTable("DEPREL");
            symbolSeparator = Pattern.compile("\\|");
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(Object[] arguments) throws org.maltparser.core.exception.MaltChainedException
        public void initialize(object[] arguments)
        {
            if (arguments.Length != 2)
            {
                throw new FeatureException("Could not initialize InputArcDirFeature: number of arguments are not correct. ");
            }
            if (!(arguments[0] is string))
            {
                throw new FeatureException("Could not initialize InputArcDirFeature: the first argument is not a string. ");
            }
            if (!(arguments[1] is AddressFunction))
            {
                throw new FeatureException("Could not initialize InputArcDirFeature: the second argument is not an address function. ");
            }
            Column      = dataFormatInstance.getColumnDescriptionByName((string)arguments[0]);
            SymbolTable = tableHandler.addSymbolTable("ARCDIR_" + column.Name, ColumnDescription.INPUT, ColumnDescription.STRING, "one");
            table.addSymbol("LEFT");
            table.addSymbol("RIGHT");
            table.addSymbol("ROOT");
            AddressFunction = (AddressFunction)arguments[1];
        }
Пример #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(Object[] arguments) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(object[] arguments)
        {
            if (arguments.Length != 2)
            {
                throw new SyntaxGraphException("Could not initialize InputColumnFeature: number of arguments are not correct. ");
            }
            if (!(arguments[0] is string))
            {
                throw new SyntaxGraphException("Could not initialize InputColumnFeature: the first argument is not a string. ");
            }
            if (!(arguments[1] is AddressFunction))
            {
                throw new SyntaxGraphException("Could not initialize InputColumnFeature: the second argument is not an address function. ");
            }
            ColumnDescription column = dataFormatInstance.getColumnDescriptionByName((string)arguments[0]);

            if (column == null)
            {
                throw new SyntaxGraphException("Could not initialize InputColumnFeature: the input column type '" + (string)arguments[0] + "' could not be found in the data format specification. ' ");
            }
            Column          = column;
            SymbolTable     = tableHandler.getSymbolTable(column.Name);
            AddressFunction = (AddressFunction)arguments[1];
        }
Пример #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(String markingStrategyString, String coveredRoot, String liftingOrder, org.apache.log4j.Logger configLogger, org.maltparser.core.io.dataformat.DataFormatInstance dataFormatInstance, org.maltparser.core.symbol.SymbolTableHandler symbolTables) throws org.maltparser.core.exception.MaltChainedException
        public virtual void initialize(string markingStrategyString, string coveredRoot, string liftingOrder, Logger configLogger, DataFormatInstance dataFormatInstance, SymbolTableHandler symbolTables)
        {
            nodeLifted            = new List <bool>();
            nodeTrace             = new List <List <DependencyNode> >();
            headDeprel            = new List <DependencyNode>();
            nodePath              = new List <bool>();
            isCoveredRoot_Renamed = new List <bool>();
            nodeRelationLength    = new List <int>();
            synacticHeadDeprel    = new List <string>();

            this.configLogger = configLogger;
            if (markingStrategyString.Equals("none", StringComparison.OrdinalIgnoreCase))
            {
                markingStrategy = PseudoProjectiveEncoding.NONE;
            }
            else if (markingStrategyString.Equals("baseline", StringComparison.OrdinalIgnoreCase))
            {
                markingStrategy = PseudoProjectiveEncoding.BASELINE;
            }
            else if (markingStrategyString.Equals("head", StringComparison.OrdinalIgnoreCase))
            {
                markingStrategy = PseudoProjectiveEncoding.HEAD;
            }
            else if (markingStrategyString.Equals("path", StringComparison.OrdinalIgnoreCase))
            {
                markingStrategy = PseudoProjectiveEncoding.PATH;
            }
            else if (markingStrategyString.Equals("head+path", StringComparison.OrdinalIgnoreCase))
            {
                markingStrategy = PseudoProjectiveEncoding.HEADPATH;
            }
            else if (markingStrategyString.Equals("trace", StringComparison.OrdinalIgnoreCase))
            {
                markingStrategy = PseudoProjectiveEncoding.TRACE;
            }
            deprelColumn      = dataFormatInstance.getColumnDescriptionByName("DEPREL");
            deprelSymbolTable = symbolTables.getSymbolTable(deprelColumn.Name);
            if (markingStrategy == PseudoProjectiveEncoding.HEAD || markingStrategy == PseudoProjectiveEncoding.PATH || markingStrategy == PseudoProjectiveEncoding.HEADPATH)
            {
                ppliftedColumn      = dataFormatInstance.addInternalColumnDescription(symbolTables, "PPLIFTED", "DEPENDENCY_EDGE_LABEL", "BOOLEAN", "", deprelColumn.NullValueStrategy);
                ppliftedSymbolTable = symbolTables.getSymbolTable(ppliftedColumn.Name);
                if (markingStrategy == PseudoProjectiveEncoding.PATH)
                {
                    ppliftedSymbolTable.addSymbol("#true#");
                    ppliftedSymbolTable.addSymbol("#false#");
                }
                else
                {
                    ppliftedSymbolTable.addSymbol("#false#");
                }
            }

            if (markingStrategy == PseudoProjectiveEncoding.PATH || markingStrategy == PseudoProjectiveEncoding.HEADPATH)
            {
                pppathColumn      = dataFormatInstance.addInternalColumnDescription(symbolTables, "PPPATH", "DEPENDENCY_EDGE_LABEL", "BOOLEAN", "", deprelColumn.NullValueStrategy);
                pppathSymbolTable = symbolTables.getSymbolTable(pppathColumn.Name);
                pppathSymbolTable.addSymbol("#true#");
                pppathSymbolTable.addSymbol("#false#");
            }

            if (coveredRoot.Equals("none", StringComparison.OrdinalIgnoreCase))
            {
                rootAttachment = CoveredRootAttachment.NONE;
            }
            else if (coveredRoot.Equals("ignore", StringComparison.OrdinalIgnoreCase))
            {
                rootAttachment = CoveredRootAttachment.IGNORE;
            }
            else if (coveredRoot.Equals("left", StringComparison.OrdinalIgnoreCase))
            {
                rootAttachment = CoveredRootAttachment.LEFT;
            }
            else if (coveredRoot.Equals("right", StringComparison.OrdinalIgnoreCase))
            {
                rootAttachment = CoveredRootAttachment.RIGHT;
            }
            else if (coveredRoot.Equals("head", StringComparison.OrdinalIgnoreCase))
            {
                rootAttachment = CoveredRootAttachment.HEAD;
            }

            if (rootAttachment != CoveredRootAttachment.NONE)
            {
                ppcoveredRootColumn      = dataFormatInstance.addInternalColumnDescription(symbolTables, "PPCOVERED", "DEPENDENCY_EDGE_LABEL", "BOOLEAN", "", deprelColumn.NullValueStrategy);
                ppcoveredRootSymbolTable = symbolTables.getSymbolTable(ppcoveredRootColumn.Name);
                ppcoveredRootSymbolTable.addSymbol("#true#");
                ppcoveredRootSymbolTable.addSymbol("#false#");
            }
            if (liftingOrder.Equals("shortest", StringComparison.OrdinalIgnoreCase))
            {
                this.liftingOrder = LiftingOrder.SHORTEST;
            }
            else if (liftingOrder.Equals("deepest", StringComparison.OrdinalIgnoreCase))
            {
                this.liftingOrder = LiftingOrder.DEEPEST;
            }
        }