Package opennlp.tools.ml.model

Examples of opennlp.tools.ml.model.GenericModelReader


public class GenericModelSerializer implements ArtifactSerializer<AbstractModel> {

  public AbstractModel create(InputStream in) throws IOException,
      InvalidFormatException {
    return new GenericModelReader(new BinaryFileDataReader(in)).getModel();
  }
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

      modelFileName = args[ai++];
      dataFileName = args[ai++];

      ModelApplier predictor = null;
      try {
        MaxentModel m = new GenericModelReader(new File(modelFileName)).getModel();
        predictor = new ModelApplier(m);
      } catch (Exception e) {
        e.printStackTrace();
        System.exit(0);
      }
View Full Code Here

    String languageCode = args[ai++];
    String packageName = args[ai++];
    String modelName = args[ai];

    AbstractModel model = new GenericModelReader(new File(modelName)).getModel();
    SentenceModel packageModel = new SentenceModel(languageCode, model,
        useTokenEnd, abbreviations, (char[]) null);
    packageModel.serialize(new FileOutputStream(packageName));
  }
View Full Code Here

      GenericModelWriter modelWriter = new GenericModelWriter(trainedModel,
          new DataOutputStream(modelBytes));
      modelWriter.persist();
      modelWriter.close();
     
      GenericModelReader modelReader = new GenericModelReader(new BinaryFileDataReader(
          new ByteArrayInputStream(modelBytes.toByteArray())));
      AbstractModel readModel = modelReader.getModel();
      QNModel deserModel = (QNModel) readModel;
     
      assertTrue(trainedModel.equals(deserModel));
     
      String[] features2Classify = new String[] {
View Full Code Here

TOP

Related Classes of opennlp.tools.ml.model.GenericModelReader

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.