Package opennlp.model

Examples of opennlp.model.AbstractModel


    // build
    System.err.println("Training builder");
    opennlp.model.EventStream bes = new ParserEventStream(parseSamples, rules,
        ParserEventTypeEnum.BUILD, mdict);
    AbstractModel buildModel = train(bes, iterations, cut);

    parseSamples.reset();

    // check
    System.err.println("Training checker");
    opennlp.model.EventStream kes = new ParserEventStream(parseSamples, rules,
        ParserEventTypeEnum.CHECK);
    AbstractModel checkModel = train(kes, iterations, cut);

    parseSamples.reset();
   
    // attach
    System.err.println("Training attacher");
    opennlp.model.EventStream attachEvents = new ParserEventStream(parseSamples, rules,
        ParserEventTypeEnum.ATTACH);
    AbstractModel attachModel = train(attachEvents, iterations, cut);
   
    // TODO: Remove cast for HeadRules
    return new ParserModel(languageCode, buildModel, checkModel,
        attachModel, posModel, chunkModel,
        (opennlp.tools.parser.lang.en.HeadRules) rules, ParserType.TREEINSERT);
View Full Code Here


      Parse.useFunctionTags(true);
    }
    if (tag || all) {
      System.err.println("Training tagger");
      opennlp.model.EventStream tes = new ParserEventStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))), rules, ParserEventTypeEnum.TAG);
      AbstractModel tagModel = train(tes, iterations, cutoff);
      System.out.println("Saving the tagger model as: " + tagFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(tagModel, tagFile).persist();
    }

    if (chunk || all) {
      System.err.println("Training chunker");
      opennlp.model.EventStream ces = new ParserEventStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))), rules, ParserEventTypeEnum.CHUNK);
      AbstractModel chunkModel = train(ces, iterations, cutoff);
      System.out.println("Saving the chunker model as: " + chunkFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(chunkModel, chunkFile).persist();
    }

    if (build || all) {
      System.err.println("Training builder");
      opennlp.model.EventStream bes = new ParserEventStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))), rules, ParserEventTypeEnum.BUILD,null);
      AbstractModel buildModel = train(bes, iterations, cutoff);
      System.out.println("Saving the build model as: " + buildFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(buildModel, buildFile).persist();
    }

    if (attach || all) {
      System.err.println("Training attacher");
      opennlp.model.EventStream kes = new ParserEventStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))), rules, ParserEventTypeEnum.ATTACH);
      AbstractModel attachModel = train(kes, iterations, cutoff);
      System.out.println("Saving the attach model as: " + attachFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(attachModel, attachFile).persist();
    }

    if (check || all) {
      System.err.println("Training checker");
      opennlp.model.EventStream ces = new ParserEventStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))), rules, ParserEventTypeEnum.CHECK);
      AbstractModel checkModel = train(ces, iterations, cutoff);
      System.out.println("Saving the check model as: " + checkFile);
      new opennlp.maxent.io.SuffixSensitiveGISModelWriter(checkModel, checkFile).persist();
    }
  }
View Full Code Here

      // TODO: Maybe that should be part of the ChunkingParser ...
      // Training build
      System.out.println("Training check model");
      opennlp.model.EventStream bes = new ParserEventStream(parseSamples,
          originalModel.getHeadRules(), ParserEventTypeEnum.CHECK, mdict);
      AbstractModel checkModel = Parser.train(bes,
          parameters.getNumberOfIterations(), parameters.getCutoff());
     
      parseSamples.close();
     
      return originalModel.updateCheckModel(checkModel);
View Full Code Here

    String lang = args[1];
    String packageName = args[2];
    String modelName = args[3];

    AbstractModel chunkerModel = new GenericModelReader(
        new BinaryFileDataReader(new FileInputStream(modelName))).getModel();

    ChunkerModel packageModel = new ChunkerModel(lang, chunkerModel);
    packageModel.serialize(new FileOutputStream(packageName));
  }
View Full Code Here

    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));
   
View Full Code Here

       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,
View Full Code Here

        es = new BasicEventStream(new PlainTextByLineDataStream(datafr), ",");
      } else {
        es = new RealBasicEventStream(new PlainTextByLineDataStream(datafr));
      }
      GIS.SMOOTHING_OBSERVATION = SMOOTHING_OBSERVATION;
      AbstractModel model;
      if (type.equals("maxent")) {

        if (!real) {
          model = GIS.trainModel(es, maxit, cutoff, sigma);
        } else {
View Full Code Here

      // TODO: training individual models should be in the chunking parser, not here
      // Training build
      System.out.println("Training builder");
      opennlp.model.EventStream bes = new ParserEventStream(parseSamples,
          originalModel.getHeadRules(), ParserEventTypeEnum.BUILD, mdict);
      AbstractModel buildModel = Parser.train(bes,
          parameters.getNumberOfIterations(), parameters.getCutoff());
     
      parseSamples.close();
     
      return originalModel.updateBuildModel(buildModel);
View Full Code Here

      throws IOException {
   
    Map<String, String> manifestInfoEntries = new HashMap<String, String>();
    ModelUtil.addCutoffAndIterations(manifestInfoEntries, cutoff, iterations);
   
    AbstractModel model = GIS.trainModel(iterations, new TwoPassDataIndexer(
        new DocumentCategorizerEventStream(samples, featureGenerators), cutoff));
   
    return new DoccatModel(languageCode, model, manifestInfoEntries);
  }
View Full Code Here

TOP

Related Classes of opennlp.model.AbstractModel

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.