@Override protected ParserModel loadModel(InputStream modelIn) throws IOException, InvalidFormatException { return new ParserModel(modelIn); }
public ParserModel updateBuildModel(MaxentModel buildModel) { return new ParserModel(getLanguage(), buildModel, getCheckModel(), getAttachModel(), getParserTaggerModel(), getParserChunkerModel(), getHeadRules(), getParserType()); }
public ParserModel updateCheckModel(MaxentModel checkModel) { return new ParserModel(getLanguage(), getBuildModel(), checkModel, getAttachModel(), getParserTaggerModel(), getParserChunkerModel(), getHeadRules(), getParserType()); }
@Test public void evalParserModel() throws Exception { ParserModel model = new ParserModel( new File(getOpennlpDataDir(), "models-sf/en-parser-chunking.bin")); MessageDigest digest = MessageDigest.getInstance(HASH_ALGORITHM); Parser parser = ParserFactory.create(model); try (ObjectStream<LeipzigTestSample> lines = createLineWiseStream()) { LeipzigTestSample line; while ((line = lines.read()) != null) { Parse[] parse = ParserTool.parseLine(String.join(" ", line.getText()), parser, 1); if (parse.length > 0) { StringBuffer sb = new StringBuffer(); parse[0].show(sb); digest.update(sb.toString().getBytes(StandardCharsets.UTF_8)); } else { digest.update("empty".getBytes(StandardCharsets.UTF_8)); } } } Assert.assertEquals(new BigInteger("312218841713337505306598301082074515847"), new BigInteger(1, digest.digest())); } }
public ParserModel updateTaggerModel(POSModel taggerModel) { return new ParserModel(getLanguage(), getBuildModel(), getCheckModel(), getAttachModel(), taggerModel, getParserChunkerModel(), getHeadRules(), getParserType()); }
public ParserModel updateChunkerModel(ChunkerModel chunkModel) { return new ParserModel(getLanguage(), getBuildModel(), getCheckModel(), getAttachModel(), getParserTaggerModel(), chunkModel, getHeadRules(), getParserType()); }
outArray.close(); ParserModel outputModel = new ParserModel(new ByteArrayInputStream(outArray.toByteArray()));
/** * Verify that training and tagging does not cause * runtime problems. */ @Test public void testTreeInsertParserTraining() throws Exception { ObjectStream<Parse> parseSamples = ParserTestUtil.openTestTrainingData(); HeadRules headRules = ParserTestUtil.createTestHeadRules(); ParserModel model = Parser.train("eng", parseSamples, headRules, 100, 0); opennlp.tools.parser.Parser parser = ParserFactory.create(model); // Tests parsing to make sure the code does not has // a bug which fails always with a runtime exception parser.parse(Parse.parseParse("She was just another freighter from the " + "States and she seemed as commonplace as her name .")); // Test serializing and de-serializing model ByteArrayOutputStream outArray = new ByteArrayOutputStream(); model.serialize(outArray); outArray.close(); new ParserModel(new ByteArrayInputStream(outArray.toByteArray())); // TODO: compare both models } }
@Override protected ParserModel loadModel(InputStream modelIn) throws IOException, InvalidFormatException { return new ParserModel(modelIn); }
@Override protected ParserModel loadModel(InputStream in) throws IOException { return new ParserModel(in); } }
@Override protected ParserModel loadModel(InputStream modelIn) throws IOException, InvalidFormatException { return new ParserModel(modelIn); }
@Override protected ParserModel loadModel(InputStream in) throws IOException { return new ParserModel(in); } }
return new ParserModel(languageCode, buildModel, checkModel, posModel, chunkModel, rules, ParserType.CHUNKING, manifestInfoEntries);
return new ParserModel(languageCode, buildModel, checkModel, attachModel, posModel, chunkModel, rules, ParserType.TREEINSERT, manifestInfoEntries);
public static Parser getOpenNLPParser(final String parserDataURL) { try (final InputStream isParser = new FileInputStream(parserDataURL);) { // Get model for the parser and initialize it final ParserModel parserModel = new ParserModel(isParser); return ParserFactory.create(parserModel); } catch (final IOException e) { e.printStackTrace(); return null; } }
public MaxentParserWrapper(InputStream is){ try { if (is!=null) { ParserModel model = new ParserModel(is); parser = new Parser(model, AbstractBottomUpParser.defaultBeamSize, AbstractBottomUpParser.defaultAdvancePercentage); } } catch (IOException e) { e.printStackTrace(); } }
public ParserModel updateCheckModel(MaxentModel checkModel) { return new ParserModel(getLanguage(), getBuildModel(), checkModel, getAttachModel(), getParserTaggerModel(), getParserChunkerModel(), getHeadRules(), getParserType()); }
public ParserModel updateBuildModel(MaxentModel buildModel) { return new ParserModel(getLanguage(), buildModel, getCheckModel(), getAttachModel(), getParserTaggerModel(), getParserChunkerModel(), getHeadRules(), getParserType()); }
public ParserModel updateBuildModel(MaxentModel buildModel) { return new ParserModel(getLanguage(), buildModel, getCheckModel(), getAttachModel(), getParserTaggerModel(), getParserChunkerModel(), getHeadRules(), getParserType()); }
public ParserModel updateCheckModel(MaxentModel checkModel) { return new ParserModel(getLanguage(), getBuildModel(), checkModel, getAttachModel(), getParserTaggerModel(), getParserChunkerModel(), getHeadRules(), getParserType()); }