Browse Source

Update Cleaner to change error the message by the project type

pull/1568/head
Hironsan 3 years ago
parent
commit
af3185a858
2 changed files with 13 additions and 2 deletions
  1. 12
      backend/api/views/upload/cleaners.py
  2. 3
      backend/api/views/upload/dataset.py

12
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.'

3
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

Loading…
Cancel
Save