/** * Annotate parse trees * * @param properties Properties that control the behavior of the parser. It use "parse.x" properties. * @return A ParserAnnotator */ public Annotator parse(Properties properties) { String parserType = properties.getProperty("parse.type", "stanford"); String maxLenStr = properties.getProperty("parse.maxlen"); if (parserType.equalsIgnoreCase("stanford")) { return new ParserAnnotator("parse", properties); } else if (parserType.equalsIgnoreCase("charniak")) { String model = properties.getProperty("parse.model"); String parserExecutable = properties.getProperty("parse.executable"); if (model == null || parserExecutable == null) { throw new RuntimeException("Both parse.model and parse.executable properties must be specified if parse.type=charniak"); } int maxLen = 399; if (maxLenStr != null) { maxLen = Integer.parseInt(maxLenStr); } return new CharniakParserAnnotator(model, parserExecutable, false, maxLen); } else { throw new RuntimeException("Unknown parser type: " + parserType + " (currently supported: stanford and charniak)"); } }
@Override public Annotator create() { String parserType = properties.getProperty("parse.type", "stanford"); String maxLenStr = properties.getProperty("parse.maxlen"); if (parserType.equalsIgnoreCase("stanford")) { ParserAnnotator anno = new ParserAnnotator("parse", properties); return anno; } else if (parserType.equalsIgnoreCase("charniak")) { String model = properties.getProperty("parse.model"); String parserExecutable = properties.getProperty("parse.executable"); if (model == null || parserExecutable == null) { throw new RuntimeException("Both parse.model and parse.executable properties must be specified if parse.type=charniak"); } int maxLen = 399; if (maxLenStr != null) { maxLen = Integer.parseInt(maxLenStr); } CharniakParserAnnotator anno = new CharniakParserAnnotator(model, parserExecutable, false, maxLen); return anno; } else { throw new RuntimeException("Unknown parser type: " + parserType + " (currently supported: stanford and charniak)"); } }
/** * Annotate parse trees * * @param properties Properties that control the behavior of the parser. It use "parse.x" properties. * @return A ParserAnnotator */ public Annotator parse(Properties properties) { String parserType = properties.getProperty("parse.type", "stanford"); String maxLenStr = properties.getProperty("parse.maxlen"); if (parserType.equalsIgnoreCase("stanford")) { return new ParserAnnotator("parse", properties); } else if (parserType.equalsIgnoreCase("charniak")) { String model = properties.getProperty("parse.model"); String parserExecutable = properties.getProperty("parse.executable"); if (model == null || parserExecutable == null) { throw new RuntimeException("Both parse.model and parse.executable properties must be specified if parse.type=charniak"); } int maxLen = 399; if (maxLenStr != null) { maxLen = Integer.parseInt(maxLenStr); } return new CharniakParserAnnotator(model, parserExecutable, false, maxLen); } else { throw new RuntimeException("Unknown parser type: " + parserType + " (currently supported: stanford and charniak)"); } }
CharniakParserAnnotator anno = new CharniakParserAnnotator(model, parserExecutable, false, maxLen);