Commit
·
85ef67c
1
Parent(s):
12f9b00
Upload conll2003.py
Browse files- conll2003.py +19 -1
conll2003.py
CHANGED
@@ -1,10 +1,22 @@
|
|
1 |
from dataclasses import dataclass
|
2 |
|
|
|
3 |
import pytorch_ie.data.builder
|
4 |
from pytorch_ie import AnnotationList, LabeledSpan, TextDocument, annotation_field
|
5 |
from pytorch_ie.utils.span import bio_tags_to_spans
|
6 |
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
@dataclass
|
9 |
class CoNLL2003Document(TextDocument):
|
10 |
entities: AnnotationList[LabeledSpan] = annotation_field(target="text")
|
@@ -13,7 +25,13 @@ class CoNLL2003Document(TextDocument):
|
|
13 |
class Conll2003(pytorch_ie.data.builder.GeneratorBasedBuilder):
|
14 |
DOCUMENT_TYPE = CoNLL2003Document
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def _generate_document_kwargs(self, dataset):
|
19 |
return {"int_to_str": dataset.features["ner_tags"].feature.int2str}
|
|
|
1 |
from dataclasses import dataclass
|
2 |
|
3 |
+
import datasets
|
4 |
import pytorch_ie.data.builder
|
5 |
from pytorch_ie import AnnotationList, LabeledSpan, TextDocument, annotation_field
|
6 |
from pytorch_ie.utils.span import bio_tags_to_spans
|
7 |
|
8 |
|
9 |
+
class Conll2003Config(datasets.BuilderConfig):
|
10 |
+
"""BuilderConfig for Conll2003"""
|
11 |
+
|
12 |
+
def __init__(self, **kwargs):
|
13 |
+
"""BuilderConfig forConll2003.
|
14 |
+
Args:
|
15 |
+
**kwargs: keyword arguments forwarded to super.
|
16 |
+
"""
|
17 |
+
super().__init__(**kwargs)
|
18 |
+
|
19 |
+
|
20 |
@dataclass
|
21 |
class CoNLL2003Document(TextDocument):
|
22 |
entities: AnnotationList[LabeledSpan] = annotation_field(target="text")
|
|
|
25 |
class Conll2003(pytorch_ie.data.builder.GeneratorBasedBuilder):
|
26 |
DOCUMENT_TYPE = CoNLL2003Document
|
27 |
|
28 |
+
BASE_DATASET_PATH = "conll2003"
|
29 |
+
|
30 |
+
BUILDER_CONFIGS = [
|
31 |
+
Conll2003Config(
|
32 |
+
name="conll2003", version=datasets.Version("1.0.0"), description="Conll2003 dataset"
|
33 |
+
),
|
34 |
+
]
|
35 |
|
36 |
def _generate_document_kwargs(self, dataset):
|
37 |
return {"int_to_str": dataset.features["ner_tags"].feature.int2str}
|