Package opennlp.model

Examples of opennlp.model.GenericModelReader


      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);
    packageModel.serialize(new FileOutputStream(packageName));
  }
View Full Code Here

      dataFileName = "";
      modelFileName = "weatherModel.txt";
  }
  Predict predictor = null;
  try {
      MaxentModel m = new GenericModelReader(new File(modelFileName)).getModel();
    predictor = new Predict(m);
  } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
  }
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

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

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 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

      ByteArrayOutputStream modelBytes = new ByteArrayOutputStream();
      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[] {"feature2","feature3", "feature3", "feature3","feature3", "feature3", "feature3","feature3", "feature3", "feature3","feature3", "feature3"};
View Full Code Here

    return new ParserModel(getLanguage(), getBuildModel(), getCheckModel(), getAttachModel(),
        getParserTaggerModel(), chunkModel, getHeadRules(), getParserType());
  }
 
  private static AbstractModel readModel(String fileName) throws FileNotFoundException, IOException {
    return new GenericModelReader(new BinaryFileDataReader(new FileInputStream(fileName))).
        getModel();
  }
View Full Code Here

TOP

Related Classes of opennlp.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.