001package org.maltparser.core.feature; 002 003import java.net.URL; 004 005import org.maltparser.core.exception.MaltChainedException; 006import org.maltparser.core.feature.spec.SpecificationModel; 007import org.maltparser.core.feature.spec.SpecificationModels; 008import org.maltparser.core.feature.system.FeatureEngine; 009 010/** 011* 012* 013* @author Johan Hall 014*/ 015public class FeatureModelManager { 016 private final SpecificationModels specModels; 017 private final FeatureEngine featureEngine; 018 019 020 public FeatureModelManager(FeatureEngine engine) throws MaltChainedException { 021 specModels = new SpecificationModels(); 022 this.featureEngine = engine; 023 } 024 025 public void loadSpecification(URL specModelURL) throws MaltChainedException { 026 specModels.load(specModelURL); 027 } 028 029 public void loadParSpecification(URL specModelURL, String markingStrategy, String coveredRoot) throws MaltChainedException { 030 specModels.loadParReader(specModelURL, markingStrategy, coveredRoot); 031 } 032 033 034 public FeatureModel getFeatureModel(URL specModelURL, int specModelUrlIndex, FeatureRegistry registry, String dataSplitColumn, String dataSplitStructure) throws MaltChainedException { 035 return new FeatureModel(specModels.getSpecificationModel(specModelURL, specModelUrlIndex), registry, featureEngine, dataSplitColumn, dataSplitStructure); 036 } 037 038 public FeatureModel getFeatureModel(URL specModelURL, FeatureRegistry registry, String dataSplitColumn, String dataSplitStructure) throws MaltChainedException { 039 return new FeatureModel(specModels.getSpecificationModel(specModelURL, 0), registry, featureEngine, dataSplitColumn, dataSplitStructure); 040 } 041 042 public FeatureModel getFeatureModel(SpecificationModel specModel, FeatureRegistry registry, String dataSplitColumn, String dataSplitStructure) throws MaltChainedException { 043 return new FeatureModel(specModel, registry, featureEngine, dataSplitColumn, dataSplitStructure); 044 } 045 046 public SpecificationModels getSpecModels() { 047 return specModels; 048 } 049 050 public FeatureEngine getFeatureEngine() { 051 return featureEngine; 052 } 053 054 055 public String toString() { 056 return specModels.toString(); 057 } 058}