Package opennlp.tools.parser

Examples of opennlp.tools.parser.ParserModel


    File modelDir = getModelDir();
    //<start id="openParse"/>
    File parserFile = new File(modelDir, "en-parser-chunking.bin");
    FileInputStream parserStream = new FileInputStream(parserFile);
    ParserModel model = new ParserModel(parserStream);
   
    Parser parser = ParserFactory.create(
            model,
            20, // beam size
            0.95); // advance percentage
View Full Code Here


    Map<String, String> attachReportMap = new HashMap<String, String>();
    AbstractModel attachModel = TrainUtil.train(attachEvents, mlParams.getSettings("attach"), attachReportMap);
    opennlp.tools.parser.chunking.Parser.mergeReportIntoManifest(manifestInfoEntries, attachReportMap, "attach");
   
    // TODO: Remove cast for HeadRules
    return new ParserModel(languageCode, buildModel, checkModel,
        attachModel, posModel, chunkModel,
        (opennlp.tools.parser.lang.en.HeadRules) rules, ParserType.TREEINSERT, manifestInfoEntries);
  }
View Full Code Here

    Map<String, String> checkReportMap = new HashMap<String, String>();
    AbstractModel checkModel = TrainUtil.train(kes, mlParams.getSettings("check"), checkReportMap);
    mergeReportIntoManifest(manifestInfoEntries, checkReportMap, "check");

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

    if (mLogger.isLoggable(Level.INFO)) {
      mLogger.log(Level.INFO, "Initializing the OpenNLP Parser.");
    }

    ParserModel model;

    try {
      ParserModelResource modelResource = (ParserModelResource) context
          .getResourceObject(UimaUtil.MODEL_PARAMETER);
View Full Code Here

    return model;
  }

  @Override
  protected ParserModel loadModel(InputStream in) throws IOException {
    return new ParserModel(in);
  }
View Full Code Here

  public void testTreeInsertParserTraining() throws Exception {
   
    ObjectStream<Parse> parseSamples = ParserTestUtil.openTestTrainingData();
    HeadRules headRules = ParserTestUtil.createTestHeadRules();
   
    ParserModel model = Parser.train("en", parseSamples, headRules, 100, 0);
   
    opennlp.tools.parser.Parser parser = ParserFactory.create(model);
   
    // Tests parsing to make sure the code does not has
    // a bug which fails always with a runtime exception
    parser.parse(Parse.parseParse("She was just another freighter from the " +
          "States and she seemed as commonplace as her name ."));
   
    // Test serializing and de-serializing model
    ByteArrayOutputStream outArray = new ByteArrayOutputStream();
    model.serialize(outArray);
    outArray.close();
   
    new ParserModel(new ByteArrayInputStream(outArray.toByteArray()));
   
    // TODO: compare both models
  }
View Full Code Here

  public void testChunkingParserTraining() throws Exception {
   
    ObjectStream<Parse> parseSamples = ParserTestUtil.openTestTrainingData();
    HeadRules headRules = ParserTestUtil.createTestHeadRules();
   
    ParserModel model = Parser.train("en", parseSamples, headRules, 100, 0);
   
    opennlp.tools.parser.Parser parser = ParserFactory.create(model);
   
    // TODO:
    // Tests parsing to make sure the code does not has
    // a bug which fails always with a runtime exception
//    parser.parse(Parse.parseParse("She was just another freighter from the " +
//        "States and she seemed as commonplace as her name ."));
   
    // Test serializing and de-serializing model
    ByteArrayOutputStream outArray = new ByteArrayOutputStream();
    model.serialize(outArray);
    outArray.close();
   
    new ParserModel(new ByteArrayInputStream(outArray.toByteArray()));
   
    // TODO: compare both models
  }
View Full Code Here

    ModelUpdaterParams params = ArgumentParser.parse(args,
        ModelUpdaterParams.class);
   
    // Load model to be updated
    File modelFile = params.getModel();
    ParserModel originalParserModel = new ParserModelLoader().load(modelFile);

    ObjectStream<Parse> parseSamples = ParserTrainerTool.openTrainingData(params.getData(),
        params.getEncoding());
   
    ParserModel updatedParserModel;
    try {
      updatedParserModel = trainAndUpdate(originalParserModel,
          parseSamples, params);
    }
    catch (IOException e) {
View Full Code Here

      System.out.println(getHelp());
      throw new TerminateToolException(1);
    }
   
    File parserModelInFile = new File(args[0]);
    ParserModel parserModel = new ParserModelLoader().load(parserModelInFile);
   
    File taggerModelInFile = new File(args[1]);
    POSModel taggerModel = new POSModelLoader().load(taggerModelInFile);
   
    ParserModel updatedParserModel = parserModel.updateTaggerModel(taggerModel);
   
    CmdLineUtil.writeModel("parser", parserModelInFile, updatedParserModel);
  }
View Full Code Here

    if (args.length < 1) {
      System.out.println(getHelp());
      throw new TerminateToolException(1);
    }
   
    ParserModel model = new ParserModelLoader().load(new File(args[args.length - 1]));
   
    Integer beamSize = CmdLineUtil.getIntParameter("-bs", args);
    if (beamSize == null)
        beamSize = AbstractBottomUpParser.defaultBeamSize;
   
View Full Code Here

TOP

Related Classes of opennlp.tools.parser.ParserModel

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.