Package opennlp.model

Examples of opennlp.model.MaxentModel


      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


    try {
      //parser = TreebankParser.getParser(dataDir, useTagDictionary, useCaseSensitiveTagDictionary, AbstractBottomUpParser.defaultBeamSize, AbstractBottomUpParser.defaultAdvancePercentage);
     
      File d = new File(dataDir);
     
      MaxentModel buildModel = null;
      MaxentModel checkModel = null;
      POSTagger posTagger = null;
      Chunker chunker = null;
      HeadRules headRules = null;

      if (!d.isDirectory()) {
        FileInputStream fis = new FileInputStream(d);
        ParserModel model = new ParserModel(fis);
        parser = new Parser(model, AbstractBottomUpParser.defaultBeamSize, AbstractBottomUpParser.defaultAdvancePercentage);
      } else {
        // This branch is for handling models built with OpenNLp 1.4
        // Once the models are rebuilt using OpenNLP 1.5 this code should be removed
        // @see TreebankParser.java in OpenNLP 1.4
        {
          File f = new File(d, "build.bin.gz"); // TODO consider moving these literals to an XML file or properties file
          buildModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
        }
       
        {
          File f = new File(d, "check.bin.gz");
          checkModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
        }
       
        {
          File f = new File(d, "pos.model.bin");
          //File f = new File(d, "tag.bin.gz");
          MaxentModel posModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
          if (useTagDictionary) {
            File td = new File(d, "tagdict");
            TagDictionary tagDictionary = new POSDictionary(td.getAbsolutePath()); //null;
            posTagger = new POSTaggerME((AbstractModel) posModel, tagDictionary);
          } else {
            // f = new File(d, "dict.bin.gz");
            Dictionary dictionary = null; // new Dictionary();
            posTagger = new POSTaggerME((AbstractModel) posModel, dictionary);

          }
        }
       
       
        {
          File f = new File(d, "chunk.bin.gz");
          MaxentModel chunkModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
          chunker = new ChunkerME(chunkModel);
        }
     
        {
          FileReader fr = new FileReader(new File(d, "head_rules"));
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

TOP

Related Classes of opennlp.model.MaxentModel

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.