ArneBinder commited on
Commit
ad58881
·
verified ·
1 Parent(s): 363fdb6

use pie-documents 0.1.0

Browse files

from https://github.com/ArneBinder/pie-datasets/pull/209 (and https://github.com/ArneBinder/pie-datasets/pull/211), also see https://github.com/ArneBinder/pie-documents/releases/tag/v0.1.0

Files changed (3) hide show
  1. README.md +9 -9
  2. requirements.txt +1 -1
  3. sciarg.py +2 -2
README.md CHANGED
@@ -9,7 +9,7 @@ Therefore, the `sciarg` dataset as described here follows the data structure fro
9
  ```python
10
  from pie_datasets import load_dataset
11
  from pie_datasets.builders.brat import BratDocumentWithMergedSpans, BratDocument
12
- from pie_modules.documents import TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions, TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions
13
 
14
  # load default version
15
  dataset = load_dataset("pie/sciarg")
@@ -74,20 +74,20 @@ See [PIE-Brat Data Schema](https://huggingface.co/datasets/pie/brat#data-schema)
74
 
75
  The dataset provides document converters for the following target document types:
76
 
77
- - `pie_modules.documents.TextDocumentWithLabeledSpansAndBinaryRelations`
78
  - `LabeledSpans`, converted from `BratDocument`'s `spans`
79
  - labels: `background_claim`, `own_claim`, `data`
80
  - if `spans` contain whitespace at the beginning and/or the end, the whitespace are trimmed out.
81
  - `BinraryRelations`, converted from `BratDocument`'s `relations`
82
  - labels: `supports`, `contradicts`, `semantically_same`, `parts_of_same`
83
  - if the `relations` label is `semantically_same` or `parts_of_same`, they are merged if they are the same arguments after sorting.
84
- - `pie_modules.documents.TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions`
85
  - `LabeledSpans`, as above
86
  - `BinaryRelations`, as above
87
  - `LabeledPartitions`, partitioned `BratDocument`'s `text`, according to the paragraph, using regex.
88
  - labels: `title`, `abstract`, `H1`
89
 
90
- See [here](https://github.com/ArneBinder/pie-modules/blob/main/src/pie_modules/documents.py) for the document type
91
  definitions.
92
 
93
  ### Data Splits
@@ -196,14 +196,14 @@ python src/evaluate_documents.py dataset=sciarg_base metric=METRIC
196
 
197
  From `default` version:
198
 
199
- - `pie_modules.documents.TextDocumentWithLabeledSpansAndBinaryRelations`
200
  - `labeled_spans`: `LabeledSpan` annotations, converted from `BratDocumentWithMergedSpans`'s `spans`
201
  - labels: `background_claim`, `own_claim`, `data`
202
  - if `spans` contain whitespace at the beginning and/or the end, that whitespace is trimmed out.
203
  - `binary_relations`: `BinaryRelation` annotations, converted from `BratDocumentWithMergedSpans`'s `relations`
204
  - labels: `supports`, `contradicts`, `semantically_same`, `parts_of_same`
205
  - if the `relations` label is `semantically_same` or `parts_of_same` (i.e. it is a symmetric relation), their arguments are sorted by their start and end indices.
206
- - `pie_modules.documents.TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions`
207
  - `labeled_spans`, as above
208
  - `binary_relations`, as above
209
  - `labeled_partitions`, `LabeledSpan` annotations, created from splitting `BratDocumentWithMergedSpans`'s `text` at new paragraph in `xml` format.
@@ -211,7 +211,7 @@ From `default` version:
211
 
212
  From `resolve_parts_of_same` version:
213
 
214
- - `pie_modules.documents.TextDocumentWithLabeledMultiSpansAndBinaryRelations`:
215
  - `labeled_multi_spans`: `LabeledMultiSpan` annotations, converted from `BratDocument`'s `spans`
216
  - labels: as above
217
  - if spans contain whitespace at the beginning and/or the end, that whitespace is trimmed out.
@@ -219,7 +219,7 @@ From `resolve_parts_of_same` version:
219
  - labels: `supports`, `contradicts`, `semantically_same`
220
  - in contrast to the `default` version, spans connected with `parts_of_same` relation are stored as one labeled multi-span
221
  - if the `relations` label is `semantically_same` (i.e. it is a symmetric relation), their arguments are sorted by their start and end indices.
222
- - `pie_modules.documents.TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions`:
223
  - `labeled_multi_spans`, as above
224
  - `binary_relations`, as above
225
  - `labeled_partitions`, `LabeledSpan` annotations, created from splitting `BratDocument`'s `text` at new paragraph in `xml` format.
@@ -235,7 +235,7 @@ input:
235
  revision: 982d5682ba414ee13cf92cb93ec18fc8e78e2b81
236
  ```
237
 
238
- For token based metrics, this uses `bert-base-uncased` from `transformer.AutoTokenizer` (see [AutoTokenizer](https://huggingface.co/docs/transformers/v4.37.1/en/model_doc/auto#transformers.AutoTokenizer), and [bert-based-uncased](https://huggingface.co/bert-base-uncased) to tokenize `text` in `TextDocumentWithLabeledSpansAndBinaryRelations` (see [document type](https://github.com/ArneBinder/pie-modules/blob/main/src/pie_modules/documents.py)).
239
 
240
  #### Relation argument (outer) token distance per label
241
 
 
9
  ```python
10
  from pie_datasets import load_dataset
11
  from pie_datasets.builders.brat import BratDocumentWithMergedSpans, BratDocument
12
+ from pie_documents.documents import TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions, TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions
13
 
14
  # load default version
15
  dataset = load_dataset("pie/sciarg")
 
74
 
75
  The dataset provides document converters for the following target document types:
76
 
77
+ - `pie_documents.documents.TextDocumentWithLabeledSpansAndBinaryRelations`
78
  - `LabeledSpans`, converted from `BratDocument`'s `spans`
79
  - labels: `background_claim`, `own_claim`, `data`
80
  - if `spans` contain whitespace at the beginning and/or the end, the whitespace are trimmed out.
81
  - `BinraryRelations`, converted from `BratDocument`'s `relations`
82
  - labels: `supports`, `contradicts`, `semantically_same`, `parts_of_same`
83
  - if the `relations` label is `semantically_same` or `parts_of_same`, they are merged if they are the same arguments after sorting.
84
+ - `pie_documents.documents.TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions`
85
  - `LabeledSpans`, as above
86
  - `BinaryRelations`, as above
87
  - `LabeledPartitions`, partitioned `BratDocument`'s `text`, according to the paragraph, using regex.
88
  - labels: `title`, `abstract`, `H1`
89
 
90
+ See [here](https://github.com/ArneBinder/pie-documents/blob/main/src/pie_documents/documents.py) for the document type
91
  definitions.
92
 
93
  ### Data Splits
 
196
 
197
  From `default` version:
198
 
199
+ - `pie_documents.documents.TextDocumentWithLabeledSpansAndBinaryRelations`
200
  - `labeled_spans`: `LabeledSpan` annotations, converted from `BratDocumentWithMergedSpans`'s `spans`
201
  - labels: `background_claim`, `own_claim`, `data`
202
  - if `spans` contain whitespace at the beginning and/or the end, that whitespace is trimmed out.
203
  - `binary_relations`: `BinaryRelation` annotations, converted from `BratDocumentWithMergedSpans`'s `relations`
204
  - labels: `supports`, `contradicts`, `semantically_same`, `parts_of_same`
205
  - if the `relations` label is `semantically_same` or `parts_of_same` (i.e. it is a symmetric relation), their arguments are sorted by their start and end indices.
206
+ - `pie_documents.documents.TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions`
207
  - `labeled_spans`, as above
208
  - `binary_relations`, as above
209
  - `labeled_partitions`, `LabeledSpan` annotations, created from splitting `BratDocumentWithMergedSpans`'s `text` at new paragraph in `xml` format.
 
211
 
212
  From `resolve_parts_of_same` version:
213
 
214
+ - `pie_documents.documents.TextDocumentWithLabeledMultiSpansAndBinaryRelations`:
215
  - `labeled_multi_spans`: `LabeledMultiSpan` annotations, converted from `BratDocument`'s `spans`
216
  - labels: as above
217
  - if spans contain whitespace at the beginning and/or the end, that whitespace is trimmed out.
 
219
  - labels: `supports`, `contradicts`, `semantically_same`
220
  - in contrast to the `default` version, spans connected with `parts_of_same` relation are stored as one labeled multi-span
221
  - if the `relations` label is `semantically_same` (i.e. it is a symmetric relation), their arguments are sorted by their start and end indices.
222
+ - `pie_documents.documents.TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions`:
223
  - `labeled_multi_spans`, as above
224
  - `binary_relations`, as above
225
  - `labeled_partitions`, `LabeledSpan` annotations, created from splitting `BratDocument`'s `text` at new paragraph in `xml` format.
 
235
  revision: 982d5682ba414ee13cf92cb93ec18fc8e78e2b81
236
  ```
237
 
238
+ For token based metrics, this uses `bert-base-uncased` from `transformer.AutoTokenizer` (see [AutoTokenizer](https://huggingface.co/docs/transformers/v4.37.1/en/model_doc/auto#transformers.AutoTokenizer), and [bert-based-uncased](https://huggingface.co/bert-base-uncased) to tokenize `text` in `TextDocumentWithLabeledSpansAndBinaryRelations` (see [document type](https://github.com/ArneBinder/pie-documents/blob/main/src/pie_documents/documents.py)).
239
 
240
  #### Relation argument (outer) token distance per label
241
 
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
  pie-datasets>=0.10.11,<0.12.0
2
- pie-modules>=0.15.9,<0.16.0
3
  networkx>=3.0.0,<4.0.0
 
1
  pie-datasets>=0.10.11,<0.12.0
2
+ pie-documents>=0.1.0,<0.2.0
3
  networkx>=3.0.0,<4.0.0
sciarg.py CHANGED
@@ -3,13 +3,13 @@ import logging
3
  from typing import Union
4
 
5
  from pie_core import AnnotationLayer, Document, annotation_field
6
- from pie_modules.document.processing import (
7
  RegexPartitioner,
8
  RelationArgumentSorter,
9
  SpansViaRelationMerger,
10
  TextSpanTrimmer,
11
  )
12
- from pie_modules.documents import (
13
  TextDocumentWithLabeledMultiSpansAndBinaryRelations,
14
  TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions,
15
  TextDocumentWithLabeledSpansAndBinaryRelations,
 
3
  from typing import Union
4
 
5
  from pie_core import AnnotationLayer, Document, annotation_field
6
+ from pie_documents.document.processing import (
7
  RegexPartitioner,
8
  RelationArgumentSorter,
9
  SpansViaRelationMerger,
10
  TextSpanTrimmer,
11
  )
12
+ from pie_documents.documents import (
13
  TextDocumentWithLabeledMultiSpansAndBinaryRelations,
14
  TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions,
15
  TextDocumentWithLabeledSpansAndBinaryRelations,