From a053ae5bfb3ded9306ada82d3525c277ae02ab6d Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 7 Jan 2022 15:00:54 +0900 Subject: [PATCH] Update intent writer --- backend/api/views/download/writer.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/api/views/download/writer.py b/backend/api/views/download/writer.py index d148cd1e..c05d200d 100644 --- a/backend/api/views/download/writer.py +++ b/backend/api/views/download/writer.py @@ -154,10 +154,19 @@ class IntentAndSlotWriter(LineWriter): extension = 'jsonl' def create_line(self, record): - return json.dumps({ - 'id': record.id, - 'text': record.data, - 'cats': record.label.get('cats', []), - 'entities': record.label.get('entities', []), - **record.metadata - }, ensure_ascii=False) + if isinstance(record.label, dict): + return json.dumps({ + 'id': record.id, + 'text': record.data, + 'cats': record.label.get('cats', []), + 'entities': record.label.get('entities', []), + **record.metadata + }, ensure_ascii=False) + else: + return json.dumps({ + 'id': record.id, + 'text': record.data, + 'cats': [], + 'entities': [], + **record.metadata + }, ensure_ascii=False)