mirror of https://github.com/doccano/doccano.git
pythondatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learningannotation-tool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
554 B
31 lines
554 B
import abc
|
|
from typing import Dict
|
|
|
|
from pydantic import BaseModel, validator
|
|
|
|
|
|
class BaseData(BaseModel, abc.ABC):
|
|
filename: str
|
|
meta: Dict = {}
|
|
|
|
@classmethod
|
|
def parse(cls, **kwargs):
|
|
return cls.parse_obj(kwargs)
|
|
|
|
def __hash__(self):
|
|
return hash(tuple(self.dict()))
|
|
|
|
|
|
class TextData(BaseData):
|
|
text: str
|
|
|
|
@validator('text')
|
|
def text_is_not_empty(cls, value: str):
|
|
if value:
|
|
return value
|
|
else:
|
|
raise ValueError('is not empty.')
|
|
|
|
|
|
class FileData(BaseData):
|
|
pass
|