ArneBinder commited on
Commit
1d20f53
·
1 Parent(s): 1eceef9

add DOCUMENT_CONVERTERS

Browse files
Files changed (1) hide show
  1. conll2003.py +8 -1
conll2003.py CHANGED
@@ -4,7 +4,7 @@ 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
 
@@ -35,6 +35,13 @@ class Conll2003(pytorch_ie.data.builder.GeneratorBasedBuilder):
35
  ),
36
  ]
37
 
 
 
 
 
 
 
 
38
  def _generate_document_kwargs(self, dataset):
39
  return {"int_to_str": dataset.features["ner_tags"].feature.int2str}
40
 
 
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, TextDocumentWithLabeledSpans
8
  from pytorch_ie.utils.span import tokens_and_tags_to_text_and_labeled_spans
9
 
10
 
 
35
  ),
36
  ]
37
 
38
+ DOCUMENT_CONVERTERS = {
39
+ TextDocumentWithLabeledSpans: {
40
+ # just rename the layer
41
+ "entities": "labeled_spans",
42
+ }
43
+ }
44
+
45
  def _generate_document_kwargs(self, dataset):
46
  return {"int_to_str": dataset.features["ner_tags"].feature.int2str}
47