Package opennlp.tools.util

Examples of opennlp.tools.util.PlainTextByLineStream


  }

  ObjectStream<POSSample> create(Parameters params) {
    ObjectStream<String> lineStream;
    try {
      lineStream = new PlainTextByLineStream(new InputStreamReader(
          CmdLineUtil.openInFile(new File(params.getData())), params.getEncoding()));
     
      return new WordTagSampleStream(lineStream);
    } catch (UnsupportedEncodingException e) {
      System.err.println("Encoding not supported: " + params.getEncoding());
View Full Code Here


      File sampleDataFile, Charset encoding) {
    CmdLineUtil.checkInputFile(sampleDataName + " Data", sampleDataFile);

    FileInputStream sampleDataIn = CmdLineUtil.openInFile(sampleDataFile);

    ObjectStream<String> lineStream = new PlainTextByLineStream(sampleDataIn
        .getChannel(), encoding);

    return new DocumentSampleStream(lineStream);
  }
View Full Code Here

   
    ChunkerME chunker = new ChunkerME(model, ChunkerME.DEFAULT_BEAM_SIZE,
        new DefaultChunkerSequenceValidator());
   
    ObjectStream<String> lineStream =
      new PlainTextByLineStream(new InputStreamReader(System.in));
   
    PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
    perfMon.start();
   
    try {
      String line;
      while ((line = lineStream.read()) != null) {
       
        POSSample posSample;
        try {
          posSample = POSSample.parse(line);
        } catch (InvalidFormatException e) {
View Full Code Here

    DoccatModel model = new DoccatModelLoader().load(new File(args[0]));
   
    DocumentCategorizerME doccat = new DocumentCategorizerME(model);
   
    ObjectStream<String> documentStream = new ParagraphStream(
        new PlainTextByLineStream(new InputStreamReader(System.in)));
   
    PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "doc");
    perfMon.start();
   
    try {
View Full Code Here

       public void reset() throws IOException {
         try {
           if (samples != null)
             samples.close();
          
          samples = new ParseSampleStream(new PlainTextByLineStream(
               new InputStreamReader(
               ParserTestUtil.class.getResourceAsStream("/opennlp/tools/parser/parser.train"), "UTF-8")));
        } catch (UnsupportedEncodingException e) {
          // Should never happen
          Assert.fail(e.getMessage());
View Full Code Here

  static ObjectStream<Parse> createParseSampleStream() throws IOException {
   
    InputStream in = ParseSampleStreamTest.class.getResourceAsStream(
    "/opennlp/tools/parser/test.parse");
   
    return new ParseSampleStream(new PlainTextByLineStream(new InputStreamReader(in, "UTF-8")));
  }
View Full Code Here

  public void setup() throws IOException {
    InputStream in = ADParagraphStreamTest.class
        .getResourceAsStream("/opennlp/tools/formats/ad.sample");

    ADNameSampleStream stream = new ADNameSampleStream(
        new PlainTextByLineStream(in, "UTF-8"));

    NameSample sample = stream.read();

    while (sample != null) {
      samples.add(sample);
View Full Code Here

  }
 
  private static ADSentenceStream openData() throws IOException {
    InputStream in = ADParagraphStreamTest.class.getResourceAsStream("/opennlp/tools/formats/ad.sample");
   
    return new ADSentenceStream(new PlainTextByLineStream(in, "UTF-8"));
  }
View Full Code Here

  public void setup() throws IOException {
    InputStream in = ADParagraphStreamTest.class
  .getResourceAsStream("/opennlp/tools/formats/ad.sample");

    ADChunkSampleStream stream = new ADChunkSampleStream(
  new PlainTextByLineStream(in, "UTF-8"));

    ChunkSample sample = stream.read();

    while (sample != null) {
      samples.add(sample);
View Full Code Here

    if (args.length != 0) {
      System.err.println("Usage: NameFinderEventStream < training files");
      System.exit(1);
    }
    EventStream es = new NameFinderEventStream(new NameSampleDataStream(
        new PlainTextByLineStream(new java.io.InputStreamReader(System.in))));
    while (es.hasNext()) {
      System.out.println(es.next());
    }
  }
View Full Code Here

TOP

Related Classes of opennlp.tools.util.PlainTextByLineStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.