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.
32 lines
874 B
32 lines
874 B
from typing import List
|
|
|
|
|
|
class FileParseException(Exception):
|
|
|
|
def __init__(self, filename: str, line_num: int, message: str):
|
|
self.filename = filename
|
|
self.line_num = line_num
|
|
self.message = message
|
|
|
|
def __str__(self):
|
|
return f'ParseError: You cannot parse line {self.line_num} in {self.filename}: {self.message}'
|
|
|
|
def dict(self):
|
|
return {
|
|
'filename': self.filename,
|
|
'line': self.line_num,
|
|
'message': self.message
|
|
}
|
|
|
|
|
|
class FileParseExceptions(Exception):
|
|
|
|
def __init__(self, exceptions: List[FileParseException]):
|
|
self.exceptions = exceptions
|
|
|
|
def __str__(self) -> str:
|
|
return f'ParseErrors: you failed to parse {len(self.exceptions)} lines.'
|
|
|
|
def __iter__(self) -> FileParseException:
|
|
for e in self.exceptions:
|
|
yield e.dict()
|