001 package org.maltparser.core.feature; 002 003 import java.net.URL; 004 005 import org.maltparser.core.config.ConfigurationDir; 006 import org.maltparser.core.config.ConfigurationRegistry; 007 import org.maltparser.core.exception.MaltChainedException; 008 import org.maltparser.core.feature.spec.SpecificationModel; 009 import org.maltparser.core.feature.spec.SpecificationModels; 010 import org.maltparser.core.feature.system.FeatureEngine; 011 012 /** 013 * 014 * 015 * @author Johan Hall 016 */ 017 public class FeatureModelManager { 018 protected SpecificationModels specModels; 019 protected FeatureEngine featureEngine; 020 021 public FeatureModelManager(FeatureEngine engine, ConfigurationDir configDirectory) throws MaltChainedException { 022 specModels = new SpecificationModels(configDirectory); 023 setFeatureEngine(engine); 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 void loadParSpecification(String specModelFileName, boolean malt04, String markingStrategy, String coveredRoot) throws MaltChainedException { 035 specModels.loadParReader(specModelFileName, malt04, markingStrategy, coveredRoot); 036 } 037 038 public void loadParSpecification(URL specModelURL, boolean malt04, String markingStrategy, String coveredRoot) throws MaltChainedException { 039 specModels.loadParReader(specModelURL, malt04, markingStrategy, coveredRoot); 040 } 041 042 public FeatureModel getFeatureModel(String specModelURL, int specModelUrlIndex, ConfigurationRegistry registry) throws MaltChainedException { 043 return new FeatureModel(specModels.getSpecificationModel(specModelURL, specModelUrlIndex), registry, featureEngine); 044 } 045 046 public FeatureModel getFeatureModel(String specModelURL, ConfigurationRegistry registry) throws MaltChainedException { 047 return new FeatureModel(specModels.getSpecificationModel(specModelURL, 0), registry, featureEngine); 048 } 049 050 public FeatureModel getFeatureModel(SpecificationModel specModel, ConfigurationRegistry registry) throws MaltChainedException { 051 return new FeatureModel(specModel, registry, featureEngine); 052 } 053 054 public SpecificationModels getSpecModels() { 055 return specModels; 056 } 057 058 protected void setSpecModels(SpecificationModels specModel) { 059 this.specModels = specModel; 060 } 061 062 public FeatureEngine getFeatureEngine() { 063 return featureEngine; 064 } 065 066 public void setFeatureEngine(FeatureEngine featureEngine) { 067 this.featureEngine = featureEngine; 068 } 069 070 public String toString() { 071 return specModels.toString(); 072 } 073 }