Package opennlp.model

Examples of opennlp.model.EventStream


      return new Event(obs.substring(lastSpace+1),contexts,values);
    }
  }

  public static void main(String[] args) throws java.io.IOException {
    EventStream es = new RealBasicEventStream(new PlainTextByLineDataStream(new java.io.FileReader(args[0])));
    while (es.hasNext()) {
      System.out.println(es.next());
    }
  }
View Full Code Here


      throws IOException {
    Factory factory = new Factory();

    Map<String, String> manifestInfoEntries = new HashMap<String, String>();

    EventStream eventStream = new TokSpanEventStream(samples,
        useAlphaNumericOptimization, factory.getAlphanumeric(languageCode),
        factory.createTokenContextGenerator(languageCode,
            getAbbreviations(abbreviations)));

    AbstractModel maxentModel = TrainUtil.train(eventStream,
View Full Code Here

      String modelFileName =
        dataFileName.substring(0,dataFileName.lastIndexOf('.'))
        + "Model.txt";
      try {
        FileReader datafr = new FileReader(new File(dataFileName));
        EventStream es;
        if (!real) {
          es = new BasicEventStream(new PlainTextByLineDataStream(datafr));
        }
        else {
          es = new RealBasicEventStream(new PlainTextByLineDataStream(datafr));
View Full Code Here

       featureGenerator = createFeatureGenerator();
    
     AbstractModel nameFinderModel;
    
     if (!TrainUtil.isSequenceTraining(trainParams.getSettings())) {
       EventStream eventStream = new NameFinderEventStream(samples, type,
           new DefaultNameContextGenerator(featureGenerator));
      
       nameFinderModel = TrainUtil.train(eventStream, trainParams.getSettings(), manifestInfoEntries);
     }
     else {
View Full Code Here

  public static final void main(String[] args) throws java.io.IOException {
    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

   
    AbstractModel posModel;
   
    if (!TrainUtil.isSequenceTraining(trainParams.getSettings())) {
     
      EventStream es = new POSSampleEventStream(samples, contextGenerator);
     
      posModel = TrainUtil.train(es, trainParams.getSettings(), manifestInfoEntries);
    }
    else {
      POSSampleSequenceStream ss = new POSSampleSequenceStream(samples, contextGenerator);
View Full Code Here

      ChunkerContextGenerator contextGenerator, TrainingParameters mlParams)
  throws IOException {
   
    Map<String, String> manifestInfoEntries = new HashMap<String, String>();
   
    EventStream es = new ChunkerEventStream(in, contextGenerator);
   
    AbstractModel maxentModel = TrainUtil.train(es, mlParams.getSettings(), manifestInfoEntries);
   
    return new ChunkerModel(lang, maxentModel, manifestInfoEntries);
  }
View Full Code Here

  public static ChunkerModel train(String lang, ObjectStream<ChunkSample> in,
      TrainingParameters mlParams, ChunkerFactory factory) throws IOException {

    Map<String, String> manifestInfoEntries = new HashMap<String, String>();

    EventStream es = new ChunkerEventStream(in, factory.getContextGenerator());

    AbstractModel maxentModel = TrainUtil.train(es, mlParams.getSettings(),
        manifestInfoEntries);

    return new ChunkerModel(lang, maxentModel, manifestInfoEntries, factory);
View Full Code Here

      ChunkerContextGenerator contextGenerator, TrainingParameters mlParams)
  throws IOException {
   
    Map<String, String> manifestInfoEntries = new HashMap<String, String>();
   
    EventStream es = new ChunkerEventStream(in, contextGenerator);
   
    AbstractModel maxentModel = TrainUtil.train(es, mlParams.getSettings(), manifestInfoEntries);
   
    return new ChunkerModel(lang, maxentModel, manifestInfoEntries);
  }
View Full Code Here

        + "Model.txt";
      File outputFile = new File(modelFileName);
      AbstractModelWriter writer = null;
      try {
        FileReader datafr = new FileReader(new File(dataFileName));
        EventStream es;
        if (!real) {
          es = new BasicEventStream(new PlainTextByLineDataStream(datafr));
        }
        else {
          es = new RealBasicEventStream(new PlainTextByLineDataStream(datafr));
View Full Code Here

TOP

Related Classes of opennlp.model.EventStream

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.