From af3185a8583cf456cbe235601ccded783df01c10 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 26 Nov 2021 08:40:50 +0900 Subject: [PATCH] Update Cleaner to change error the message by the project type --- backend/api/views/upload/cleaners.py | 12 ++++++++++++ backend/api/views/upload/dataset.py | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/api/views/upload/cleaners.py b/backend/api/views/upload/cleaners.py index e19fa981..d0d4fd92 100644 --- a/backend/api/views/upload/cleaners.py +++ b/backend/api/views/upload/cleaners.py @@ -12,6 +12,10 @@ class Cleaner: def clean(self, labels: List[Label]) -> List[Label]: return labels + @property + def message(self) -> str: + return '' + class SpanCleaner(Cleaner): @@ -32,6 +36,10 @@ class SpanCleaner(Cleaner): new_labels.append(label) return new_labels + @property + def message(self) -> str: + return 'This project cannot allow label overlapping. It\'s cleaned.' + class CategoryCleaner(Cleaner): @@ -44,3 +52,7 @@ class CategoryCleaner(Cleaner): return labels[:1] else: return labels + + @property + def message(self) -> str: + return 'This project only one label can apply but multiple label found. It\'s cleaned.' diff --git a/backend/api/views/upload/dataset.py b/backend/api/views/upload/dataset.py index b57cb14a..76c650c6 100644 --- a/backend/api/views/upload/dataset.py +++ b/backend/api/views/upload/dataset.py @@ -38,11 +38,10 @@ class Record: changed = len(label) != len(self.label) self._label = label if changed: - message = 'There are invalid labels. It\'s cleaned.' raise FileParseException( filename=self._data.filename, line_num=self._line_num, - message=message + message=cleaner.message ) @property