List of usage examples for opennlp.tools.parser Parse getChildCount
public int getChildCount()
From source file:org.opentestsystem.airose.docprocessors.ConventionsQualityDocProcessor.java
private ConventionsDocumentQualityHolder evaluateSyntax(Parse parse) { double overallPunctScore = 0.0; double minSyntaxScore = 1.0; double overallSyntaxScore = 0.0; double numOfNoms = 0; double numLongNominals = 0; double syntaxCount = 0; int countPunct = 0; Queue<Parse> parseTree = new LinkedList<Parse>(); parseTree.add(parse);/*from ww w.j a v a 2s .c o m*/ double rootProb = parse.getProb(); while (parseTree.size() > 0) { Parse p = parseTree.remove(); if ((p.getChildCount() == 1) && (p.getProb() < 1)) { double prob = p.getProb(); String pType = p.getType(); if (StringUtils.equals(pType, ",") || StringUtils.equals(pType, ".") || StringUtils.equals(pType, "!") || StringUtils.equals(pType, "?") || StringUtils.equals(pType, ";") || StringUtils.equals(pType, ":")) { overallPunctScore += prob; countPunct++; } else { if (!StringUtils.equals(pType, "TOP") && !StringUtils.equals(pType, "S")) { // string s = sentText_; if ((pType.startsWith("NN")))// || p.Type.StartsWith("JJ")) { numOfNoms++; } else { if ((numOfNoms > 2) && (rootProb > -25.5)) numLongNominals++; // _numOfNoms = 0; } if (prob < minSyntaxScore) minSyntaxScore = prob; overallSyntaxScore += prob; syntaxCount++; } } } Parse[] children = p.getChildren(); for (Parse pc : children) parseTree.add(pc); } overallPunctScore = (countPunct == 0) ? 0.0 : overallPunctScore / countPunct; ConventionsDocumentQualityHolder values = new ConventionsDocumentQualityHolder(); values.setOverallPunctScore(overallPunctScore); values.setMinSyntaxScore(minSyntaxScore); values.setOverallSyntaxScore(overallSyntaxScore); values.setNumOfNoms(numOfNoms); values.setNumLongNominals(numLongNominals); values.setSyntaxCount(syntaxCount); return values; }