Package edu.stanford.nlp.parser.common

Examples of edu.stanford.nlp.parser.common.ParserQuery


        goldTrees.add(goldTree);

        pwErr.println("Parsing [len. " + sentence.size() + "]: " + Sentence.listToString(sentence));
        wrapper.put(sentence);
        while (wrapper.peek()) {
          ParserQuery pq = wrapper.poll();
          goldTree = goldTrees.poll();
          processResults(pq, goldTree, pwErr, pwOut, pwFileOut, pwStats, treePrint);
        }
      } // for tree iterator
      wrapper.join();
      while (wrapper.peek()) {
        ParserQuery pq = wrapper.poll();
        Tree goldTree = goldTrees.poll();
        processResults(pq, goldTree, pwErr, pwOut, pwFileOut, pwStats, treePrint);
      }
    } else {
      ParserQuery pq = pqFactory.parserQuery();

      for (Tree goldTree : testTreebank) {
        final List<CoreLabel> sentence = getInputSentence(goldTree);

        pwErr.println("Parsing [len. " + sentence.size() + "]: " + Sentence.listToString(sentence));

        pq.parseAndReport(sentence, pwErr);

        processResults(pq, goldTree, pwErr, pwOut, pwFileOut, pwStats, treePrint);
      } // for tree iterator
    }

    //Done parsing...print the results of the evaluations
    treebankTotalTimer.done("Testing on treebank");
    if (op.testOptions.quietEvaluation) {
      pwErr = tlpParams.pw(System.err);
    }
    if (saidMemMessage) {
      ParserUtils.printOutOfMemory(pwErr);
    }
    if (op.testOptions.evalb) {
      EvalbFormatWriter.closeEVALBfiles();
    }
    if(numSkippedEvals != 0) {
      pwErr.printf("Unable to evaluate %d parser hypotheses due to yield mismatch\n",numSkippedEvals);
    }
    // only created here so we know what parser types are supported...
    ParserQuery pq = pqFactory.parserQuery();
    if (summary) {
      if (pcfgLB != null) pcfgLB.display(false, pwErr);
      if (pcfgChildSpecific != null) pcfgChildSpecific.display(false, pwErr);
      if (pcfgLA != null) pcfgLA.display(false, pwErr);
      if (pcfgCB != null) pcfgCB.display(false, pwErr);
      if (pcfgDA != null) pcfgDA.display(false, pwErr);
      if (pcfgTA != null) pcfgTA.display(false, pwErr);
      if (pcfgLL != null && pq.getPCFGParser() != null) pcfgLL.display(false, pwErr);
      if (depDA != null) depDA.display(false, pwErr);
      if (depTA != null) depTA.display(false, pwErr);
      if (depLL != null && pq.getDependencyParser() != null) depLL.display(false, pwErr);
      if (factLB != null) factLB.display(false, pwErr);
      if (factChildSpecific != null) factChildSpecific.display(false, pwErr);
      if (factLA != null) factLA.display(false, pwErr);
      if (factCB != null) factCB.display(false, pwErr);
      if (factDA != null) factDA.display(false, pwErr);
      if (factTA != null) factTA.display(false, pwErr);
      if (factLL != null && pq.getFactoredParser() != null) factLL.display(false, pwErr);
      if (pcfgCatE != null) pcfgCatE.display(false, pwErr);
      for (Eval eval : evals) {
        eval.display(false, pwErr);
      }
      for (BestOfTopKEval eval : topKEvals) {
        eval.display(false, pwErr);
      }
    }
    // these ones only have a display mode, so display if turned on!!
    if (pcfgRUO != null) pcfgRUO.display(true, pwErr);
    if (pcfgCUO != null) pcfgCUO.display(true, pwErr);
    if (tsv) {
      NumberFormat nf = new DecimalFormat("0.00");
      pwErr.println("factF1\tfactDA\tfactEx\tpcfgF1\tdepDA\tfactTA\tnum");
      if (factLB != null) pwErr.print(nf.format(factLB.getEvalbF1Percent()));
      pwErr.print("\t");
      if (pq.getDependencyParser() != null && factDA != null) pwErr.print(nf.format(factDA.getEvalbF1Percent()));
      pwErr.print("\t");
      if (factLB != null) pwErr.print(nf.format(factLB.getExactPercent()));
      pwErr.print("\t");
      if (pcfgLB != null) pwErr.print(nf.format(pcfgLB.getEvalbF1Percent()));
      pwErr.print("\t");
      if (pq.getDependencyParser() != null && depDA != null) pwErr.print(nf.format(depDA.getEvalbF1Percent()));
      pwErr.print("\t");
      if (pq.getPCFGParser() != null && factTA != null) pwErr.print(nf.format(factTA.getEvalbF1Percent()));
      pwErr.print("\t");
      if (factLB != null) pwErr.print(factLB.getNum());
      pwErr.println();
    }
View Full Code Here


  /**
   * Similar to parse(), but instead of returning an X tree on failure, returns null.
   */
  public Tree parseTree(List<? extends HasWord> sentence) {
    ParserQuery pq = parserQuery();
    if (pq.parse(sentence)) {
      return pq.getBestParse();
    } else {
      return null;
    }
  }
View Full Code Here

      evaluator.testOnTreebank(testTreebank);
    } else if (argIndex >= args.length) {
      // no more arguments, so we just parse our own test sentence
      PrintWriter pwOut = op.tlpParams.pw();
      PrintWriter pwErr = op.tlpParams.pw(System.err);
      ParserQuery pq = lp.parserQuery();
      if (pq.parse(op.tlpParams.defaultTestSentence())) {
        lp.getTreePrint().printTree(pq.getBestParse(), pwOut);
      } else {
        pwErr.println("Error. Can't parse test sentence: " +
                      op.tlpParams.defaultTestSentence());
      }
    } else {
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.parser.common.ParserQuery

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.