def CountErrors(ocr_text, truth_text):
 counts = collections.Counter(truth_text)
 counts.subtract(ocr_text)
 drops = sum((c for c in counts.values() if (c > 0)))
 adds = sum(((- c) for c in counts.values() if (c < 0)))
 return ErrorCounts(drops, adds, len(truth_text), len(ocr_text))

def CountErrors ( ocr_text , truth_text ) : counts = collections . Counter ( truth_text ) counts . subtract ( ocr_text ) drops = sum ( ( c for c in counts . values ( ) if ( c > 0 ) ) ) adds = sum ( ( ( - c ) for c in counts . values ( ) if ( c < 0 ) ) ) return ErrorCounts ( drops , adds , len ( truth_text ) , len ( ocr_text ) )
counts the drops and adds between 2 bags of iterables .