Skip to content

Commit 6b6b1cb

Browse files
author
Val Brodsky
committed
Add DocumentEntity class
1 parent 44f843a commit 6b6b1cb

File tree

1 file changed

+19
-2
lines changed
  • labelbox/data/annotation_types

1 file changed

+19
-2
lines changed

labelbox/data/annotation_types/ner.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Dict, Any
1+
from typing import Dict, Any, List
22

3-
from pydantic import BaseModel, root_validator
3+
from pydantic import BaseModel, root_validator, validator
44

55

66
class TextEntity(BaseModel):
@@ -17,3 +17,20 @@ def validate_start_end(cls, values):
1717
raise ValueError(
1818
"Location end must be greater or equal to start")
1919
return values
20+
21+
22+
class DocumentTextSelection(BaseModel):
23+
tokenIds: List[str]
24+
groupId: str
25+
page: int
26+
27+
@validator("page")
28+
def validate_page(cls, v):
29+
if v < 1:
30+
raise ValueError("Page must be greater than 1")
31+
return v
32+
33+
class DocumentEntity(BaseModel):
34+
""" Represents a text entity """
35+
name: str
36+
text_selections: List[DocumentTextSelection]

0 commit comments

Comments
 (0)