コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void load(java.net.URL specModelURL) throws org.maltparser.core.exception.MaltChainedException
        public virtual void load(URL specModelURL)
        {
            if (specModelURL == null)
            {
                throw new FeatureException("The URL to the feature specification model is missing or not well-formed. ");
            }
            FeatureSpecReader specReader = null;
            string            urlSuffix  = specModelURL.ToString().Substring(specModelURL.ToString().Length - 3);

            urlSuffix = char.ToUpper(urlSuffix[0]) + urlSuffix.Substring(1);
            try
            {
                Type clazz = Type.GetType("org.maltparser.core.feature.spec.reader." + urlSuffix + "Reader");
                specReader = (FeatureSpecReader)global::System.Activator.CreateInstance(clazz);
            }
            catch (InstantiationException e)
            {
                throw new FeatureException("Could not initialize the feature specification reader to read the specification file: " + specModelURL.ToString(), e);
            }
            catch (IllegalAccessException e)
            {
                throw new FeatureException("Could not initialize the feature specification reader to read the specification file: " + specModelURL.ToString(), e);
            }
            catch (ClassNotFoundException e)
            {
                throw new FeatureException("Could not find the feature specification reader to read the specification file: " + specModelURL.ToString(), e);
            }
            specReaderMap[specModelURL] = specReader;

            specModelKeyMap.put(specModelURL, currentSpecModelURL);
            specReader.load(specModelURL, this);
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void loadParReader(java.net.URL specModelURL, String markingStrategy, String coveredRoot) throws org.maltparser.core.exception.MaltChainedException
        public virtual void loadParReader(URL specModelURL, string markingStrategy, string coveredRoot)
        {
            if (specModelURL == null)
            {
                throw new FeatureException("The URL to the feature specification model is missing or not well-formed. ");
            }
            FeatureSpecReader specReader = null;
            string            urlSuffix  = specModelURL.ToString().Substring(specModelURL.ToString().Length - 3);

            urlSuffix = char.ToUpper(urlSuffix[0]) + urlSuffix.Substring(1);
            try
            {
                Type clazz = Type.GetType("org.maltparser.core.feature.spec.reader." + urlSuffix + "Reader");
                specReader = (FeatureSpecReader)global::System.Activator.CreateInstance(clazz);
            }
            catch (InstantiationException e)
            {
                throw new FeatureException("Could not initialize the feature specification reader to read the specification file: " + specModelURL.ToString(), e);
            }
            catch (IllegalAccessException e)
            {
                throw new FeatureException("Could not initialize the feature specification reader to read the specification file: " + specModelURL.ToString(), e);
            }
            catch (ClassNotFoundException e)
            {
                throw new FeatureException("Could not find the feature specification reader to read the specification file: " + specModelURL.ToString(), e);
            }
            specReaderMap[specModelURL] = specReader;

            if (specReader is ParReader)
            {
                if (markingStrategy.Equals("head", StringComparison.OrdinalIgnoreCase) || markingStrategy.Equals("path", StringComparison.OrdinalIgnoreCase) || markingStrategy.Equals("head+path", StringComparison.OrdinalIgnoreCase))
                {
                    ((ParReader)specReader).Pplifted = true;
                }
                if (markingStrategy.Equals("path", StringComparison.OrdinalIgnoreCase) || markingStrategy.Equals("head+path", StringComparison.OrdinalIgnoreCase))
                {
                    ((ParReader)specReader).Pppath = true;
                }
                if (!coveredRoot.Equals("none", StringComparison.OrdinalIgnoreCase))
                {
                    ((ParReader)specReader).PpcoveredRoot = true;
                }
            }

            specModelKeyMap.put(specModelURL, currentSpecModelURL);
            specReader.load(specModelURL, this);
        }