def lineSummary(self, line): base = [] top = [] height = [] left = None right = None chars = 0 for token in line.iter('TOKEN'): info = common.tokenExtract(token) base.append(info['base']) top.append(info['top']) height.append(info['height']) if (left == None): left = info['left'] else: if (info['left'] < left): left = info['left'] if (right == None): right = info['right'] else: if (info['right'] > right): right = info['right'] chars = chars + info['chars'] # apply summary if (len(base) <= 2): line.set('base', unicode(common.largest(base))) else: line.set('base', unicode(common.mostCommon(base))) if (len(top) <= 2): line.set('top', unicode(common.smallest(top))) else: line.set('top', unicode(common.mostCommon(top))) line.set('left', unicode(left)) line.set('right', unicode(right)) if (len(height) <= 2): line.set('height', unicode(common.largest(height))) else: line.set('height', unicode(common.mostCommon(height))) line.set('chars', unicode(chars))
def estimateJustify(self, paragraph, c): lines = paragraph.getchildren() right = [] for i in xrange(0, len(lines)): info = common.lineExtract(lines[i]) right.append(info['right']) if (len(right) <= 2): indent = common.largest(right) else: indent = common.mostCommon(right) return indent
def estimateJustify(self, paragraph, c): lines = paragraph.getchildren() right = [] for i in xrange(0,len(lines)): info = common.lineExtract(lines[i]) right.append(info['right']) if (len(right) <= 2): indent = common.largest(right) else: indent = common.mostCommon(right) return indent