private static ObjectStream<Parse> createParseSampleStream() throws IOException { InputStreamFactory in = new ResourceAsStreamFactory( ParseSampleStreamTest.class, "/opennlp/tools/parser/test.parse"); return new ParseSampleStream(new PlainTextByLineStream(in, StandardCharsets.UTF_8)); }
public Parse read() throws IOException { String parse = samples.read(); if (parse != null) { if (!parse.trim().isEmpty()) { return Parse.parseParse(parse); } else { return read(); } } else { return null; } } }
public void reset() throws IOException { try { if (samples != null) { samples.close(); } InputStreamFactory in = new ResourceAsStreamFactory(getClass(), "/opennlp/tools/parser/parser.train"); samples = new ParseSampleStream(new PlainTextByLineStream(in, StandardCharsets.UTF_8)); } catch (UnsupportedEncodingException e) { // Should never happen Assert.fail(e.getMessage()); } } };
public Parse read() throws IOException { String parse = samples.read(); if (parse != null) { if (!parse.trim().isEmpty()) { return Parse.parseParse(parse); } else { return read(); } } else { return null; } } }
public ObjectStream<Parse> create(String[] args) { Parameters params = ArgumentParser.parse(args, Parameters.class); CmdLineUtil.checkInputFile("Data", params.getData()); InputStreamFactory sampleDataIn = CmdLineUtil.createInputStreamFactory(params.getData()); ObjectStream<String> lineStream = null; try { lineStream = new PlainTextByLineStream(sampleDataIn, params.getEncoding()); } catch (IOException ex) { CmdLineUtil.handleCreateObjectStreamError(ex); } return new ParseSampleStream(lineStream); } }
public Parse read() throws IOException { String parse = samples.read(); if (parse != null) { if (!parse.trim().isEmpty()) { return Parse.parseParse(parse); } else { return read(); } } else { return null; } } }
public ObjectStream<Parse> create(String[] args) { Parameters params = ArgumentParser.parse(args, Parameters.class); CmdLineUtil.checkInputFile("Data", params.getData()); InputStreamFactory sampleDataIn = CmdLineUtil.createInputStreamFactory(params.getData()); ObjectStream<String> lineStream = null; try { lineStream = new PlainTextByLineStream(sampleDataIn, params.getEncoding()); } catch (IOException ex) { CmdLineUtil.handleCreateObjectStreamError(ex); } return new ParseSampleStream(lineStream); } }
public ObjectStream<Parse> create(String[] args) { Parameters params = ArgumentParser.parse(args, Parameters.class); CmdLineUtil.checkInputFile("Data", params.getData()); InputStreamFactory sampleDataIn = CmdLineUtil.createInputStreamFactory(params.getData()); ObjectStream<String> lineStream = null; try { lineStream = new PlainTextByLineStream(sampleDataIn, params.getEncoding()); } catch (IOException ex) { CmdLineUtil.handleCreateObjectStreamError(ex); } return new ParseSampleStream(lineStream); } }
@Test public void testConvertParseToPosSample() throws IOException { try (ObjectStream<POSSample> posSampleStream = new PosSampleStream(new ParseSampleStream( ObjectStreamUtils.createObjectStream(ParseTest.PARSE_STRING)))) {
@Test public void testConvertParseToPosSample() throws IOException { try (ObjectStream<ChunkSample> chunkSampleStream = new ChunkSampleStream(new ParseSampleStream( ObjectStreamUtils.createObjectStream(ParseTest.PARSE_STRING)))) {