001package org.maltparser.parser.algorithm.covington; 002 003import org.maltparser.core.exception.MaltChainedException; 004import org.maltparser.core.feature.FeatureRegistry; 005import org.maltparser.core.feature.function.Function; 006import org.maltparser.parser.AbstractParserFactory; 007import org.maltparser.parser.AlgoritmInterface; 008import org.maltparser.parser.DependencyParserConfig; 009import org.maltparser.parser.ParserConfiguration; 010import org.maltparser.parser.ParserRegistry; 011/** 012 * @author Johan Hall 013 * 014 */ 015public abstract class CovingtonFactory implements AbstractParserFactory { 016 protected final DependencyParserConfig manager; 017 018 public CovingtonFactory(DependencyParserConfig _manager) { 019 this.manager = _manager; 020 } 021 022 public ParserConfiguration makeParserConfiguration() throws MaltChainedException { 023 boolean allowRoot = (Boolean)manager.getOptionValue("covington", "allow_root"); 024 boolean allowShift = (Boolean)manager.getOptionValue("covington", "allow_shift"); 025 if (manager.isLoggerInfoEnabled()) { 026 manager.logInfoMessage(" Parser configuration : Covington with allow_root="+allowRoot+" and allow_shift="+allowShift+"\n"); 027 } 028 CovingtonConfig config = new CovingtonConfig(allowRoot, allowShift); 029 return config; 030 } 031 032 public Function makeFunction(String subFunctionName, FeatureRegistry registry) throws MaltChainedException { 033 AlgoritmInterface algorithm = ((ParserRegistry)registry).getAlgorithm(); 034 return new CovingtonAddressFunction(subFunctionName, algorithm); 035 } 036}