예제 #1
0
 /**
  * @return a list of constituent words. The list holds the logical reading-order if a
  *     ReadingOrderResolver was run on the original document.
  */
 public List<BxWord> asWords() {
   List<BxWord> ret = new ArrayList<BxWord>();
   for (BxLine line : asLines()) {
     ret.addAll(line.getWords());
   }
   return ret;
 }
 private void appendLine(Document doc, Element parent, BxLine line, Object... hints) {
   Element node = doc.createElement("Line");
   appendPropertyIfNotNull(doc, node, "LineID", line.getId());
   appendBounds(doc, node, "LineCorners", line.getBounds(), hints);
   appendPropertyIfNotNull(doc, node, "LineNext", line.getNextId());
   appendProperty(doc, node, "LineNumChars", "");
   for (BxWord word : line.getWords()) {
     appendWord(doc, node, word, hints);
   }
   parent.appendChild(node);
 }
 @Override
 public double calculateFeatureValue(BxZone zone, BxPage page) {
   double charSpace = 0.0;
   for (BxLine line : zone.getLines()) {
     for (BxWord word : line.getWords()) {
       for (BxChunk chunk : word.getChunks()) {
         charSpace += chunk.getArea();
       }
     }
   }
   double ret = zone.getArea() - charSpace;
   if (ret < 0) {
     return 0.0;
   } else {
     return ret;
   }
 }