001 package org.maltparser.parser.algorithm.nivre; 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 NivreFactory implements AbstractParserFactory { 014 protected Algorithm algorithm; 015 protected DependencyParserConfig manager; 016 017 public NivreFactory(Algorithm algorithm) { 018 setAlgorithm(algorithm); 019 setManager(algorithm.getManager()); 020 } 021 022 public ParserConfiguration makeParserConfiguration() throws MaltChainedException { 023 if (manager.getConfigLogger().isInfoEnabled()) { 024 manager.getConfigLogger().info(" Parser configuration : Nivre with "+manager.getOptionValue("nivre", "root_handling").toString().toUpperCase()+" root handling\n"); 025 } 026 return new NivreConfig(manager.getSymbolTables(), manager.getOptionValue("nivre", "root_handling").toString()); 027 } 028 029 public Function makeFunction(String subFunctionName) throws MaltChainedException { 030 return new NivreAddressFunction(subFunctionName, algorithm); 031 } 032 033 public Algorithm getAlgorithm() { 034 return algorithm; 035 } 036 037 public void setAlgorithm(Algorithm algorithm) { 038 this.algorithm = algorithm; 039 } 040 041 public DependencyParserConfig getManager() { 042 return manager; 043 } 044 045 public void setManager(DependencyParserConfig manager) { 046 this.manager = manager; 047 } 048 }