Browse Source

Add dict method to Record

pull/1310/head
Hironsan 3 years ago
parent
commit
4248596696
1 changed files with 12 additions and 0 deletions
  1. 12
      app/api/views/upload/dataset.py

12
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:

Loading…
Cancel
Save