Browse Source

Rename OffsetLabel to SpanLabel

pull/1619/head
Hironsan 2 years ago
parent
commit
31e5d34cc4
4 changed files with 6 additions and 6 deletions
  1. 4
      backend/api/tests/upload/test_builder.py
  2. 4
      backend/api/views/upload/cleaners.py
  3. 2
      backend/api/views/upload/factories.py
  4. 2
      backend/api/views/upload/label.py

4
backend/api/tests/upload/test_builder.py

@ -4,7 +4,7 @@ from typing import List
from ...views.upload import builders
from ...views.upload.data import TextData
from ...views.upload.exception import FileParseException
from ...views.upload.label import CategoryLabel, OffsetLabel
from ...views.upload.label import CategoryLabel, SpanLabel
class TestColumnBuilder(unittest.TestCase):
@ -71,7 +71,7 @@ class TestColumnBuilder(unittest.TestCase):
data_column = builders.DataColumn('text', TextData)
label_columns = [
builders.LabelColumn('cats', CategoryLabel),
builders.LabelColumn('entities', OffsetLabel)
builders.LabelColumn('entities', SpanLabel)
]
actual = self.create_record(row, data_column, label_columns)
expected = {

4
backend/api/views/upload/cleaners.py

@ -1,7 +1,7 @@
from typing import List
from ...models import Project
from .label import CategoryLabel, Label, OffsetLabel
from .label import CategoryLabel, Label, SpanLabel
class Cleaner:
@ -23,7 +23,7 @@ class SpanCleaner(Cleaner):
super().__init__(project)
self.allow_overlapping = getattr(project, 'allow_overlapping', False)
def clean(self, labels: List[OffsetLabel]) -> List[OffsetLabel]:
def clean(self, labels: List[SpanLabel]) -> List[SpanLabel]:
if self.allow_overlapping:
return labels

2
backend/api/views/upload/factories.py

@ -32,7 +32,7 @@ def create_parser(file_format: str, **kwargs):
def get_label_class(project_type: str):
mapping = {
DOCUMENT_CLASSIFICATION: label.CategoryLabel,
SEQUENCE_LABELING: label.OffsetLabel,
SEQUENCE_LABELING: label.SpanLabel,
SEQ2SEQ: label.TextLabel,
IMAGE_CLASSIFICATION: label.CategoryLabel,
SPEECH2TEXT: label.TextLabel,

2
backend/api/views/upload/label.py

@ -73,7 +73,7 @@ class CategoryLabel(Label):
)
class OffsetLabel(Label):
class SpanLabel(Label):
label: Union[str, int]
start_offset: int
end_offset: int

Loading…
Cancel
Save