Return a mapping of {value: count} given a list of Text objects (representing either copyrights, holders or authors).
(summary_texts)
| 249 | |
| 250 | |
| 251 | def tally(summary_texts): |
| 252 | """ |
| 253 | Return a mapping of {value: count} given a list of Text objects |
| 254 | (representing either copyrights, holders or authors). |
| 255 | """ |
| 256 | |
| 257 | if TRACE: |
| 258 | logger_debug('summarize: INITIAL texts:') |
| 259 | for s in summary_texts: |
| 260 | logger_debug(' ', s) |
| 261 | |
| 262 | for text in summary_texts: |
| 263 | text.normalize() |
| 264 | |
| 265 | if TRACE_DEEP: |
| 266 | logger_debug('summarize: NORMALIZED 1 texts:') |
| 267 | for s in summary_texts: |
| 268 | logger_debug(' ', s) |
| 269 | |
| 270 | texts = list(filter_junk(summary_texts)) |
| 271 | |
| 272 | if TRACE_DEEP: |
| 273 | logger_debug('summarize: DEJUNKED texts:') |
| 274 | for s in summary_texts: |
| 275 | logger_debug(' ', s) |
| 276 | |
| 277 | for t in texts: |
| 278 | t.normalize() |
| 279 | |
| 280 | if TRACE_DEEP: |
| 281 | logger_debug('summarize: NORMALIZED 2 texts:') |
| 282 | for s in summary_texts: |
| 283 | logger_debug(' ', s) |
| 284 | |
| 285 | # keep non-empties |
| 286 | texts = list(t for t in texts if t.key) |
| 287 | |
| 288 | if TRACE_DEEP: |
| 289 | logger_debug('summarize: NON-EMPTY 1 texts:') |
| 290 | for s in summary_texts: |
| 291 | logger_debug(' ', s) |
| 292 | |
| 293 | # convert to plain ASCII, then fingerprint |
| 294 | for t in texts: |
| 295 | t.transliterate() |
| 296 | |
| 297 | if TRACE_DEEP: |
| 298 | logger_debug('summarize: ASCII texts:') |
| 299 | for s in summary_texts: |
| 300 | logger_debug(' ', s) |
| 301 | |
| 302 | for t in texts: |
| 303 | t.fingerprint() |
| 304 | |
| 305 | if TRACE_DEEP or TRACE_FP: |
| 306 | logger_debug('summarize: FINGERPRINTED texts:') |
| 307 | for s in summary_texts: |
| 308 | logger_debug(' ', s) |
no test coverage detected