001 package org.maltparser.parser.algorithm.covington; 002 003 import org.maltparser.core.exception.MaltChainedException; 004 import org.maltparser.core.feature.function.Function; 005 import org.maltparser.parser.AbstractParserFactory; 006 import org.maltparser.parser.Algorithm; 007 import org.maltparser.parser.DependencyParserConfig; 008 import org.maltparser.parser.ParserConfiguration; 009 /** 010 * @author Johan Hall 011 * 012 */ 013 public abstract class CovingtonFactory implements AbstractParserFactory { 014 protected Algorithm algorithm; 015 protected DependencyParserConfig manager; 016 017 public CovingtonFactory(Algorithm algorithm) { 018 setAlgorithm(algorithm); 019 setManager(algorithm.getManager()); 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.getConfigLogger().isInfoEnabled()) { 026 manager.getConfigLogger().info(" Parser configuration : Covington with allow_root="+allowRoot+" and allow_shift="+allowShift+"\n"); 027 } 028 CovingtonConfig config = new CovingtonConfig(manager.getSymbolTables(), allowRoot, allowShift); 029 return config; 030 } 031 032 public Function makeFunction(String subFunctionName) throws MaltChainedException { 033 return new CovingtonAddressFunction(subFunctionName, algorithm); 034 } 035 036 public Algorithm getAlgorithm() { 037 return algorithm; 038 } 039 040 public void setAlgorithm(Algorithm algorithm) { 041 this.algorithm = algorithm; 042 } 043 044 public DependencyParserConfig getManager() { 045 return manager; 046 } 047 048 public void setManager(DependencyParserConfig manager) { 049 this.manager = manager; 050 } 051 }