christophalt commited on
Commit
0e67774
·
1 Parent(s): 5d594aa

Upload all datasets to hub

Browse files

Commit from https://github.com/huggingface/datasets/pie/commit/44e2b49f756ae55906addbd4cbcb339698ea0e7c

dummy/germeval_14/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43927bbe42ad2e816c846698795af3706e9f650b28e2e692024d9a03616c85f6
3
+ size 12583
germeval_14.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+
3
+ import datasets
4
+ import pytorch_ie.data.builder
5
+ from pytorch_ie.annotations import LabeledSpan
6
+ from pytorch_ie.core import AnnotationList, annotation_field
7
+ from pytorch_ie.documents import TextDocument
8
+ from pytorch_ie.utils.span import tokens_and_tags_to_text_and_labeled_spans
9
+
10
+
11
+ class GermEval14Config(datasets.BuilderConfig):
12
+ """BuilderConfig for GermEval 2014."""
13
+
14
+ def __init__(self, **kwargs):
15
+ """BuilderConfig for GermEval 2014.
16
+ Args:
17
+ **kwargs: keyword arguments forwarded to super.
18
+ """
19
+ super().__init__(**kwargs)
20
+
21
+
22
+ @dataclass
23
+ class GermEval14Document(TextDocument):
24
+ entities: AnnotationList[LabeledSpan] = annotation_field(target="text")
25
+
26
+
27
+ class GermEval14(pytorch_ie.data.builder.GeneratorBasedBuilder):
28
+ DOCUMENT_TYPE = GermEval14Document
29
+
30
+ BASE_DATASET_PATH = "germeval_14"
31
+
32
+ BUILDER_CONFIGS = [
33
+ GermEval14Config(
34
+ name="germeval_14",
35
+ version=datasets.Version("2.0.0"),
36
+ description="GermEval 2014 NER Shared Task dataset",
37
+ ),
38
+ ]
39
+
40
+ def _generate_document_kwargs(self, dataset):
41
+ return {"int_to_str": dataset.features["ner_tags"].feature.int2str}
42
+
43
+ def _generate_document(self, example, int_to_str):
44
+ doc_id = example["id"]
45
+ tokens = example["tokens"]
46
+ ner_tags = [int_to_str(tag) for tag in example["ner_tags"]]
47
+ nested_ner_tags = [int_to_str(tag) for tag in example["nested_ner_tags"]]
48
+
49
+ text, ner_spans = tokens_and_tags_to_text_and_labeled_spans(tokens=tokens, tags=ner_tags)
50
+ _, nested_ner_tags = tokens_and_tags_to_text_and_labeled_spans(
51
+ tokens=tokens, tags=nested_ner_tags
52
+ )
53
+
54
+ document = GermEval14Document(text=text, id=doc_id)
55
+
56
+ for span in sorted(ner_spans + nested_ner_tags, key=lambda span: span.start):
57
+ document.entities.append(span)
58
+
59
+ return document