001    package org.maltparser.core.feature;
002    
003    import java.net.URL;
004    
005    import org.maltparser.core.config.ConfigurationRegistry;
006    import org.maltparser.core.exception.MaltChainedException;
007    import org.maltparser.core.feature.spec.SpecificationModels;
008    import org.maltparser.core.feature.system.FeatureEngine;
009    
010    /**
011    *
012    *
013    * @author Johan Hall
014    */
015    public class FeatureModelManager {
016            protected SpecificationModels specModels;
017            protected FeatureEngine featureEngine;
018            protected ConfigurationRegistry registry;
019            
020            public FeatureModelManager(FeatureEngine engine, ConfigurationRegistry registry) throws MaltChainedException {
021                    specModels = new SpecificationModels(engine.getConfiguration());
022                    setFeatureEngine(engine);
023                    setRegistry(registry);
024            }
025            
026            public void loadSpecification(String specModelFileName) throws MaltChainedException {
027                    specModels.load(specModelFileName);
028            }
029            
030            public void loadSpecification(URL specModelURL) throws MaltChainedException {
031                    specModels.load(specModelURL);
032            }
033            
034            public FeatureModel getFeatureModel(String specModelURL, int specModelUrlIndex) throws MaltChainedException {
035                    return new FeatureModel(specModels.getSpecificationModel(specModelURL, specModelUrlIndex), registry, featureEngine);
036            }
037            
038            public FeatureModel getFeatureModel(String specModelURL) throws MaltChainedException {
039                    return new FeatureModel(specModels.getSpecificationModel(specModelURL, 0), registry, featureEngine);
040            }
041            
042            public SpecificationModels getSpecModels() {
043                    return specModels;
044            }
045    
046            protected void setSpecModels(SpecificationModels specModel) {
047                    this.specModels = specModel;
048            }
049            
050            public FeatureEngine getFeatureEngine() {
051                    return featureEngine;
052            }
053    
054            public void setFeatureEngine(FeatureEngine featureEngine) {
055                    this.featureEngine = featureEngine;
056            }
057    
058            public ConfigurationRegistry getRegistry() {
059                    return registry;
060            }
061    
062            public void setRegistry(ConfigurationRegistry registry) {
063                    this.registry = registry;
064            }
065    
066            public String toString() {
067                    return specModels.toString();
068            }
069    }