|
|
@ -366,10 +366,10 @@ class TextDownloadAPI(APIView): |
|
|
|
project = get_object_or_404(Project, pk=self.kwargs['project_id']) |
|
|
|
documents = project.documents.all() |
|
|
|
painter = self.select_painter(format) |
|
|
|
# json1 format prints text labels while json format prints annotations with label ids |
|
|
|
# json1 format - "labels": [[0, 15, "PERSON"], ..] |
|
|
|
# json format - "annotations": [{"label": 5, "start_offset": 0, "end_offset": 2, "user": 1},..] |
|
|
|
if format == "json1": |
|
|
|
# jsonl-textlabel format prints text labels while jsonl format prints annotations with label ids |
|
|
|
# jsonl-textlabel format - "labels": [[0, 15, "PERSON"], ..] |
|
|
|
# jsonl format - "annotations": [{"label": 5, "start_offset": 0, "end_offset": 2, "user": 1},..] |
|
|
|
if format == 'jsonl': |
|
|
|
labels = project.labels.all() |
|
|
|
data = JSONPainter.paint_labels(documents, labels) |
|
|
|
else: |
|
|
@ -379,7 +379,7 @@ class TextDownloadAPI(APIView): |
|
|
|
def select_painter(self, format): |
|
|
|
if format == 'csv': |
|
|
|
return CSVPainter() |
|
|
|
elif format == 'json' or format == "json1": |
|
|
|
elif format == 'jsonl' or format == 'json': |
|
|
|
return JSONPainter() |
|
|
|
else: |
|
|
|
raise ValidationError('format {} is invalid.'.format(format)) |
|
|
|