Package opennlp.tools.parser

Examples of opennlp.tools.parser.Parser


    ChunkerME chunker = new ChunkerME(chunkerModel);
    FileInputStream posStream = new FileInputStream(
        new File(modelDir,"en-pos-maxent.bin"));
    POSModel posModel = new POSModel(posStream);
    POSTaggerME tagger =  new POSTaggerME(posModel);
    Parser parser = new ChunkParser(chunker, tagger);
    Parse[] results = ParserTool.parseLine("Who is the president of egypt ?", parser, 1);
    String[] context = atcg.getContext(results[0]);
    List<String> features = Arrays.asList(context);
    assertTrue(features.contains("qw=who"));
    assertTrue(features.contains("hw=president"));
View Full Code Here


    ChunkerME chunker = new ChunkerME(chunkerModel);
    InputStream posStream = new FileInputStream(
            new File(modelDir,"en-pos-maxent.bin"));
    POSModel posModel = new POSModel(posStream);
    POSTaggerME tagger =  new POSTaggerME(posModel);
    Parser parser = new ChunkParser(chunker, tagger);
    //<start id="att.answerTypeDemo"/>
    AnswerTypeContextGenerator atcg =
            new AnswerTypeContextGenerator(
                    new File(getWordNetDictionary().getAbsolutePath()));
    InputStream is = Thread.currentThread().getContextClassLoader()
View Full Code Here

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

    Parse[] results = ParserTool.parseLine("The Minnesota Twins , " +
View Full Code Here

    ChunkerME chunker = new ChunkerME(chunkerModel);
    FileInputStream posStream = new FileInputStream(
        new File(modelDir,"en-pos-maxent.bin"));
    POSModel posModel = new POSModel(posStream);
    POSTaggerME tagger =  new POSTaggerME(posModel);
    Parser parser = new ChunkParser(chunker, tagger);
    Parse[] results = ParserTool.parseLine("The Minnesota Twins , " +
            "the 1991 World Series Champions , are currently in third place .",
            parser, 1);
    Parse p = results[0];
    Parse[] chunks = p.getChildren();
View Full Code Here

    QParser qParser;
    if (params.getBool(QAParams.COMPONENT_NAME, false) == true //<co id="qqpp.explainif"/>
            && qStr.equals("*:*") == false) {
      AnswerTypeClassifier atc =
              new AnswerTypeClassifier(model, probs, atcg);//<co id="qqpp.atc"/>
      Parser parser = new ChunkParser(chunker, tagger);//<co id="qqpp.parser"/>
      qParser = new QuestionQParser(qStr, localParams, //<co id="qqpp.construct"/>
              params, req, parser, atc, answerTypeMap);
    } else {
      //just do a regular query if qa is turned off
      qParser = req.getCore().getQueryPlugin("edismax")
View Full Code Here

    ChunkerME chunker = new ChunkerME(chunkerModel);
    InputStream posStream = new FileInputStream(
        new File(modelsDir,"en-pos-maxent.bin"));
    POSModel posModel = new POSModel(posStream);
    POSTaggerME tagger =  new POSTaggerME(posModel);
    Parser parser = new ChunkParser(chunker, tagger);
    AnswerTypeContextGenerator actg = new AnswerTypeContextGenerator(new File(wordnetDir));
    //<start id="atc.train"/>
    AnswerTypeEventStream es = new AnswerTypeEventStream(trainFile,
            actg, parser);
    GISModel model = GIS.trainModel(100, new TwoPassDataIndexer(es, 3));//<co id="atc.train.do"/>
View Full Code Here

    ChunkerME chunker = new ChunkerME(chunkerModel);
    InputStream posStream = new FileInputStream(
        new File(modelsDir,"en-pos-maxent.bin"));
    POSModel posModel = new POSModel(posStream);
    POSTaggerME tagger =  new POSTaggerME(posModel);
    Parser parser = new ChunkParser(chunker, tagger);
    AnswerTypeContextGenerator actg = new AnswerTypeContextGenerator(wordnetDir);
    EventStream es = new AnswerTypeEventStream(eventFile,actg,parser);
    while(es.hasNext()) {
      System.out.println(es.next().toString());
    }
View Full Code Here

   * @return the parse sentence
   */
  public String getParsing(ParserModel model){
   
    String par = null;
    Parser parser = ParserFactory.create(model);
    Parse topParses[] = ParserTool.parseLine(sentence, parser, 1);

    StringBuffer buffer = new StringBuffer();
    topParses[0].show(buffer);
    par = buffer.toString();
View Full Code Here

  public ObjectStream<CorefSample> create(String[] args) {
   
    Parameters params = ArgumentParser.parse(args, Parameters.class);
   
    ParserModel parserModel = new ParserModelLoader().load(params.getParserModel());
    Parser parser =  ParserFactory.create(parserModel);
   
    TokenizerModel tokenizerModel = new TokenizerModelLoader().load(params.getTokenizerModel());
    Tokenizer tokenizer = new TokenizerME(tokenizerModel);
   
    ObjectStream<String> mucDocStream = new FileToStringSampleStream(
View Full Code Here

    super.run(format, args);

    ParserModel model = new ParserModelLoader().load(params.getModel());

    Parser parser = ParserFactory.create(model);

    ParserEvaluator evaluator = new ParserEvaluator(parser);

    System.out.print("Evaluating ... ");
    try {
View Full Code Here

TOP

Related Classes of opennlp.tools.parser.Parser

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.