Package opennlp.tools.util

Examples of opennlp.tools.util.HashSumEventStream


      // TODO: Fix the EventStream to throw exceptions when training goes wrong
      EventStream eventStream = new SDEventStream(samples,
          factory.createSentenceContextGenerator(languageCode),
          factory.createEndOfSentenceScanner(languageCode));
     
      HashSumEventStream hses = new HashSumEventStream(eventStream);
      GISModel sentModel = GIS.trainModel(hses, iterations, cutoff);

      manifestInfoEntries.put(BaseModel.TRAINING_EVENTHASH_PROPERTY,
          hses.calculateHashSum().toString(16));
     
      return new SentenceModel(languageCode, sentModel,
          useTokenEnd, abbreviations, manifestInfoEntries);
    }
View Full Code Here


    ModelUtil.addCutoffAndIterations(manifestInfoEntries, cut, iterations);
   
    // build
    System.err.println("Training builder");
    opennlp.model.EventStream bes = new ParserEventStream(parseSamples, rules, ParserEventTypeEnum.BUILD, mdict);
    HashSumEventStream hsbes = new HashSumEventStream(bes);
    AbstractModel buildModel = train(hsbes, iterations, cut);
    manifestInfoEntries.put("Training-Builder-Eventhash",
        hsbes.calculateHashSum().toString(16));
   
    parseSamples.reset();
   
    // tag
    POSModel posModel = POSTaggerME.train(languageCode, new PosSampleStream(parseSamples),
        ModelType.MAXENT, null, null, cut, iterations);
   
    parseSamples.reset();
   
    // chunk
    ChunkerModel chunkModel = ChunkerME.train(languageCode,
        new ChunkSampleStream(parseSamples), cut, iterations,
        new ChunkContextGenerator());
   
    parseSamples.reset();
   
    // check
    System.err.println("Training checker");
    opennlp.model.EventStream kes = new ParserEventStream(parseSamples, rules, ParserEventTypeEnum.CHECK);
    HashSumEventStream hskes = new HashSumEventStream(kes);
    AbstractModel checkModel = train(hskes, iterations, cut);
    manifestInfoEntries.put("Training-Checker-Eventhash",
        hskes.calculateHashSum().toString(16));
   
    // TODO: Remove cast for HeadRules
    return new ParserModel(languageCode, buildModel, checkModel,
        posModel, chunkModel, (opennlp.tools.parser.lang.en.HeadRules) rules,
        ParserType.CHUNKING, manifestInfoEntries);
View Full Code Here

   
    Map<String, String> manifestInfoEntries = new HashMap<String, String>();
    ModelUtil.addCutoffAndIterations(manifestInfoEntries, cutoff, iterations);
   
    EventStream es = new ChunkerEventStream(in, contextGenerator);
    HashSumEventStream hses = new HashSumEventStream(es);
   
    AbstractModel maxentModel = opennlp.maxent.GIS.trainModel(iterations,
        new TwoPassDataIndexer(hses, cutoff));
   
    manifestInfoEntries.put(BaseModel.TRAINING_EVENTHASH_PROPERTY,
        hses.calculateHashSum().toString(16));
   
    return new ChunkerModel(lang, maxentModel, manifestInfoEntries);
  }
View Full Code Here

     else
       featureGenerator = createFeatureGenerator();
    
     EventStream eventStream = new NameFinderEventStream(samples, type,
         new DefaultNameContextGenerator(featureGenerator));
     HashSumEventStream hses = new HashSumEventStream(eventStream);
     AbstractModel nameFinderModel = GIS.trainModel(iterations, new TwoPassDataIndexer(hses, cutoff));
    
     manifestInfoEntries.put(BaseModel.TRAINING_EVENTHASH_PROPERTY,
         hses.calculateHashSum().toString(16));
    
     return new TokenNameFinderModel(languageCode, nameFinderModel,
         resources, manifestInfoEntries);
   }
View Full Code Here

TOP

Related Classes of opennlp.tools.util.HashSumEventStream

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.