Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public DataFormatSpecification loadDataFormat(java.net.URL dataFormatUrl) throws org.maltparser.core.exception.MaltChainedException
        public virtual DataFormatSpecification loadDataFormat(URL dataFormatUrl)
        {
            if (dataFormatUrl == null)
            {
                return(null);
            }
            DataFormatSpecification dataFormat = fileNameDataFormatSpecs[dataFormatUrl.ToString()];

            if (dataFormat == null)
            {
                dataFormat = new DataFormatSpecification();
                dataFormat.parseDataFormatXMLfile(dataFormatUrl);
                fileNameDataFormatSpecs[dataFormatUrl.ToString()] = dataFormat;
                nameDataFormatSpecs[dataFormat.DataFormatName]    = dataFormat;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.helper.URLFinder f = new org.maltparser.core.helper.URLFinder();
                UrlFinder f = new UrlFinder();

                foreach (Dependency dep in dataFormat.Dependencies)
                {
                    loadDataFormat(f.FindUrLinJars(dep.UrlString));
                }
            }
            return(dataFormat);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void checkOptionDependency() throws org.maltparser.core.exception.MaltChainedException
        public virtual void checkOptionDependency()
        {
            try
            {
                if (configDir.InfoFileWriter != null)
                {
                    configDir.InfoFileWriter.Write("\nDEPENDENCIES\n");
                }

                // Copy the feature model file into the configuration directory
                string featureModelFileName = getOptionValue("guide", "features").ToString().Trim();
                if (featureModelFileName.Equals(""))
                {
                    // use default feature model depending on the selected parser algorithm
                    OptionManager.instance().overloadOptionValue(optionContainerIndex, "guide", "features", getOptionValueString("singlemalt", "parsing_algorithm"));
                    featureModelFileName = getOptionValue("guide", "features").ToString().Trim();

                    /* START: Temp fix during development of new liblinear and libsvm interface */
                    string learner = getOptionValueString("guide", "learner");
                    if (!learner.StartsWith("lib", StringComparison.Ordinal))
                    {
                        learner = "lib" + learner;
                    }
                    /* END: Temp fix during development of new liblinear and libsvm interface */
                    featureModelFileName = featureModelFileName.Replace("{learner}", learner);
                    featureModelFileName = featureModelFileName.Replace("{dataformat}", getOptionValue("input", "format").ToString().Trim().Replace(".xml", ""));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.core.helper.URLFinder f = new org.maltparser.core.helper.URLFinder();
                    UrlFinder f = new UrlFinder();
                    featureModelFileName = configDir.copyToConfig(f.FindUrLinJars(featureModelFileName));
                }
                else
                {
                    featureModelFileName = configDir.copyToConfig(featureModelFileName);
                }
                OptionManager.instance().overloadOptionValue(optionContainerIndex, "guide", "features", featureModelFileName);
                if (configDir.InfoFileWriter != null)
                {
                    configDir.InfoFileWriter.Write("--guide-features (  -F)                 " + getOptionValue("guide", "features").ToString() + "\n");
                }

                if (getOptionValue("guide", "data_split_column").ToString().Equals("") && !getOptionValue("guide", "data_split_structure").ToString().Equals(""))
                {
                    configLogger.warn("Option --guide-data_split_column = '' and --guide-data_split_structure != ''. Option --guide-data_split_structure is overloaded with '', this will cause the parser to induce a single model.\n ");
                    OptionManager.instance().overloadOptionValue(optionContainerIndex, "guide", "data_split_structure", "");
                    if (configDir.InfoFileWriter != null)
                    {
                        configDir.InfoFileWriter.Write("--guide-data_split_structure (  -s)\n");
                    }
                }
                if (!getOptionValue("guide", "data_split_column").ToString().Equals("") && getOptionValue("guide", "data_split_structure").ToString().Equals(""))
                {
                    configLogger.warn("Option --guide-data_split_column != '' and --guide-data_split_structure = ''. Option --guide-data_split_column is overloaded with '', this will cause the parser to induce a single model.\n");
                    OptionManager.instance().overloadOptionValue(optionContainerIndex, "guide", "data_split_column", "");
                    if (configDir.InfoFileWriter != null)
                    {
                        configDir.InfoFileWriter.Write("--guide-data_split_column (  -d)\n");
                    }
                }

                string        decisionSettings    = getOptionValue("guide", "decision_settings").ToString().Trim();
                string        markingStrategy     = getOptionValue("pproj", "marking_strategy").ToString().Trim();
                string        coveredRoot         = getOptionValue("pproj", "covered_root").ToString().Trim();
                StringBuilder newDecisionSettings = new StringBuilder();

                if (ReferenceEquals(decisionSettings, null) || decisionSettings.Length < 1 || decisionSettings.Equals("default"))
                {
                    decisionSettings = "T.TRANS+A.DEPREL";
                }
                else
                {
                    decisionSettings = decisionSettings.ToUpper();
                }

                if (markingStrategy.Equals("head", StringComparison.OrdinalIgnoreCase) || markingStrategy.Equals("path", StringComparison.OrdinalIgnoreCase) || markingStrategy.Equals("head+path", StringComparison.OrdinalIgnoreCase))
                {
                    if (!Pattern.matches(".*A\\.PPLIFTED.*", decisionSettings))
                    {
                        newDecisionSettings.Append("+A.PPLIFTED");
                    }
                }
                if (markingStrategy.Equals("path", StringComparison.OrdinalIgnoreCase) || markingStrategy.Equals("head+path", StringComparison.OrdinalIgnoreCase))
                {
                    if (!Pattern.matches(".*A\\.PPPATH.*", decisionSettings))
                    {
                        newDecisionSettings.Append("+A.PPPATH");
                    }
                }
                if (!coveredRoot.Equals("none", StringComparison.OrdinalIgnoreCase) && !Pattern.matches(".*A\\.PPCOVERED.*", decisionSettings))
                {
                    newDecisionSettings.Append("+A.PPCOVERED");
                }
                if (!getOptionValue("guide", "decision_settings").ToString().Equals(decisionSettings) || newDecisionSettings.Length > 0)
                {
                    OptionManager.instance().overloadOptionValue(optionContainerIndex, "guide", "decision_settings", decisionSettings + newDecisionSettings.ToString());
                    if (configDir.InfoFileWriter != null)
                    {
                        configDir.InfoFileWriter.Write("--guide-decision_settings (  -gds)                 " + getOptionValue("guide", "decision_settings").ToString() + "\n");
                    }
                }
                if (configDir.InfoFileWriter != null)
                {
                    configDir.InfoFileWriter.Flush();
                }
            }
            catch (IOException e)
            {
                throw new ConfigurationException("Could not write to the configuration information file. ", e);
            }
        }