Return a list of CopyrightDetection, a list of HolderDetection and a list of AuthorDetection given a ``detections`` list of Detection. If ``to_dict`` is True, return lists of mappings instead of objects.
(cls, detections, to_dict=False)
| 456 | |
| 457 | @classmethod |
| 458 | def split(cls, detections, to_dict=False): |
| 459 | """ |
| 460 | Return a list of CopyrightDetection, a list of HolderDetection and a |
| 461 | list of AuthorDetection given a ``detections`` list of Detection. |
| 462 | If ``to_dict`` is True, return lists of mappings instead of objects. |
| 463 | """ |
| 464 | copyrights = [] |
| 465 | holders = [] |
| 466 | authors = [] |
| 467 | |
| 468 | for detection in detections: |
| 469 | det = detection.to_dict() if to_dict else detection |
| 470 | if isinstance(detection, CopyrightDetection): |
| 471 | copyrights.append(det) |
| 472 | elif isinstance(detection, HolderDetection): |
| 473 | holders.append(det) |
| 474 | elif isinstance(detection, AuthorDetection): |
| 475 | authors.append(det) |
| 476 | return copyrights, holders, authors |
| 477 | |
| 478 | @classmethod |
| 479 | def split_values(cls, detections): |