diff --git a/app/api/views/upload/dataset.py b/app/api/views/upload/dataset.py index bed273db..26d6735f 100644 --- a/app/api/views/upload/dataset.py +++ b/app/api/views/upload/dataset.py @@ -21,6 +21,18 @@ class Record: def __str__(self): return f'{self.data}\t{self.label}' + def dict(self): + label_names = [ + { + 'text': label.name + } for label in self.label if label.has_name() + ] + return { + 'data': self.data.dict(), + 'annotation': [label.dict() for label in self.label], + 'label': label_names + } + class Dataset: