hadikhamoud commited on
Commit
100bf33
·
verified ·
1 Parent(s): c93c142

Upload TypePrediction dataset

Browse files
Files changed (2) hide show
  1. README.md +81 -0
  2. build_type_prediction_dataset.py +81 -0
README.md CHANGED
@@ -20,6 +20,9 @@ Unified mention-level type prediction data built from all available local Wojood
20
  ## Main file
21
 
22
  - `type_predictor_data.jsonl`
 
 
 
23
 
24
  Each row contains:
25
 
@@ -40,6 +43,60 @@ Each row contains:
40
  }
41
  ```
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ## Construction
44
 
45
  1. Parse all sentence-separated CoNLL-style files from:
@@ -52,6 +109,22 @@ Each row contains:
52
  4. Reconstruct full sentence text and both token and character spans.
53
  5. Deduplicate by `(sentence, entity, type, start_token, end_token)` and merge provenance.
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  ## Summary
56
 
57
  - total rows: `132763`
@@ -96,3 +169,11 @@ Each row contains:
96
  - `PERCENT`: 312
97
  - `PRODUCT`: 191
98
  - `QUANTITY`: 115
 
 
 
 
 
 
 
 
 
20
  ## Main file
21
 
22
  - `type_predictor_data.jsonl`
23
+ - `summary.json`
24
+ - `build_type_prediction_dataset.py`
25
+ - `push_to_hf.py`
26
 
27
  Each row contains:
28
 
 
43
  }
44
  ```
45
 
46
+ ## Stored row examples
47
+
48
+ Simple flat/coarse example:
49
+
50
+ ```json
51
+ {
52
+ "entity": "عبد الحميد عبد العاطي",
53
+ "type": "PERS",
54
+ "sentence": "! ! ! تم النشر قبل بواسطة عبد الحميد عبد العاطي ازهقنا .",
55
+ "start_token": 7,
56
+ "end_token": 10,
57
+ "start_char": 26,
58
+ "end_char": 47,
59
+ "raw_types": ["PERS"],
60
+ "sources": [{"dataset": "WojoodFine", "split": "train"}]
61
+ }
62
+ ```
63
+
64
+ Example where a fine label is mapped to a coarse label:
65
+
66
+ ```json
67
+ {
68
+ "entity": "قضاء رام الله",
69
+ "type": "GPE",
70
+ "sentence": """ ديوان قائمقام قضاء رام الله ، الى رئيس بلدية مدينة البيرة بشان المادة الخامسة من قانون الدفاع رقم "" "" 6 "" "" لسنة 1939 بتاريخ ( 9 / 7 / 1952 ) "" .",
71
+ "start_token": 3,
72
+ "end_token": 5,
73
+ "start_char": 17,
74
+ "end_char": 30,
75
+ "raw_types": ["GPE", "STATE-OR-PROVINCE"],
76
+ "sources": [{"dataset": "WojoodFine", "split": "train"}]
77
+ }
78
+ ```
79
+
80
+ Example merged across multiple source datasets:
81
+
82
+ ```json
83
+ {
84
+ "entity": "مصر",
85
+ "type": "GPE",
86
+ "sentence": "بعدما أطاح به آية الله الخميني وبنظامه ، حيث توجه بداية إلى مصر قبل أن يستقر به الأمر في المغرب ، ,",
87
+ "start_token": 12,
88
+ "end_token": 12,
89
+ "start_char": 60,
90
+ "end_char": 63,
91
+ "raw_types": ["GPE", "COUNTRY"],
92
+ "sources": [
93
+ {"dataset": "Wojood1_1_flat", "split": "test"},
94
+ {"dataset": "Wojood1_1_nested", "split": "test"},
95
+ {"dataset": "WojoodFine-Flat", "split": "split20"}
96
+ ]
97
+ }
98
+ ```
99
+
100
  ## Construction
101
 
102
  1. Parse all sentence-separated CoNLL-style files from:
 
109
  4. Reconstruct full sentence text and both token and character spans.
110
  5. Deduplicate by `(sentence, entity, type, start_token, end_token)` and merge provenance.
111
 
112
+ ## Parsing details and edge cases
113
+
114
+ - `Wojood1_1_flat` uses simple space-separated `token tag` rows.
115
+ - `Wojood1_1_nested` uses space-separated rows with multiple BIO tags on the same token when nested annotations exist.
116
+ - `WojoodFine` and `WojoodFine-Flat` use tab-separated rows.
117
+ - Some `WojoodFine` rows place multiple tags inside a single tab field, for example:
118
+ - `نبيه\tI-OCC B-PERS\t\t\t`
119
+ The builder normalizes this by splitting tag cells on internal whitespace.
120
+ - Some fine labels appear with alias spellings that differ from the ontology ids, for example:
121
+ - `GPE-ORG` -> `GPE_ORG`
122
+ - `Cluster` -> `CLUSTER`
123
+ - `Path` -> `PATH`
124
+ The builder canonicalizes these before mapping to coarse parents.
125
+ - Sentence boundaries are read from blank lines in the CoNLL files.
126
+ - Character spans are reconstructed after joining sentence tokens with single spaces.
127
+
128
  ## Summary
129
 
130
  - total rows: `132763`
 
169
  - `PERCENT`: 312
170
  - `PRODUCT`: 191
171
  - `QUANTITY`: 115
172
+
173
+ ## Validation performed
174
+
175
+ - verified that all four non-relation Wojood sources were included
176
+ - verified nested extraction is enabled when multiple tags occur on one token
177
+ - verified fine-to-coarse mapping uses the repo's `wojood_ontology.json`
178
+ - verified `sentence[start_char:end_char] == entity` across the built file
179
+ - verified deduped rows merge provenance rather than silently dropping it
build_type_prediction_dataset.py CHANGED
@@ -239,6 +239,9 @@ Unified mention-level type prediction data built from all available local Wojood
239
  ## Main file
240
 
241
  - `type_predictor_data.jsonl`
 
 
 
242
 
243
  Each row contains:
244
 
@@ -259,6 +262,60 @@ Each row contains:
259
  }}
260
  ```
261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  ## Construction
263
 
264
  1. Parse all sentence-separated CoNLL-style files from:
@@ -271,6 +328,22 @@ Each row contains:
271
  4. Reconstruct full sentence text and both token and character spans.
272
  5. Deduplicate by `(sentence, entity, type, start_token, end_token)` and merge provenance.
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  ## Summary
275
 
276
  - total rows: `{summary['total_rows']}`
@@ -285,6 +358,14 @@ Each row contains:
285
  ## Top coarse types
286
 
287
  {top_types}
 
 
 
 
 
 
 
 
288
  """
289
 
290
 
 
239
  ## Main file
240
 
241
  - `type_predictor_data.jsonl`
242
+ - `summary.json`
243
+ - `build_type_prediction_dataset.py`
244
+ - `push_to_hf.py`
245
 
246
  Each row contains:
247
 
 
262
  }}
263
  ```
264
 
265
+ ## Stored row examples
266
+
267
+ Simple flat/coarse example:
268
+
269
+ ```json
270
+ {{
271
+ "entity": "عبد الحميد عبد العاطي",
272
+ "type": "PERS",
273
+ "sentence": "! ! ! تم النشر قبل بواسطة عبد الحميد عبد العاطي ازهقنا .",
274
+ "start_token": 7,
275
+ "end_token": 10,
276
+ "start_char": 26,
277
+ "end_char": 47,
278
+ "raw_types": ["PERS"],
279
+ "sources": [{{"dataset": "WojoodFine", "split": "train"}}]
280
+ }}
281
+ ```
282
+
283
+ Example where a fine label is mapped to a coarse label:
284
+
285
+ ```json
286
+ {{
287
+ "entity": "قضاء رام الله",
288
+ "type": "GPE",
289
+ "sentence": "\"\" ديوان قائمقام قضاء رام الله ، الى رئيس بلدية مدينة البيرة بشان المادة الخامسة من قانون الدفاع رقم \"\" \"\" 6 \"\" \"\" لسنة 1939 بتاريخ ( 9 / 7 / 1952 ) \"\" .",
290
+ "start_token": 3,
291
+ "end_token": 5,
292
+ "start_char": 17,
293
+ "end_char": 30,
294
+ "raw_types": ["GPE", "STATE-OR-PROVINCE"],
295
+ "sources": [{{"dataset": "WojoodFine", "split": "train"}}]
296
+ }}
297
+ ```
298
+
299
+ Example merged across multiple source datasets:
300
+
301
+ ```json
302
+ {{
303
+ "entity": "مصر",
304
+ "type": "GPE",
305
+ "sentence": "بعدما أطاح به آية الله الخميني وبنظامه ، حيث توجه بداية إلى مصر قبل أن يستقر به الأمر في المغرب ، ,",
306
+ "start_token": 12,
307
+ "end_token": 12,
308
+ "start_char": 60,
309
+ "end_char": 63,
310
+ "raw_types": ["GPE", "COUNTRY"],
311
+ "sources": [
312
+ {{"dataset": "Wojood1_1_flat", "split": "test"}},
313
+ {{"dataset": "Wojood1_1_nested", "split": "test"}},
314
+ {{"dataset": "WojoodFine-Flat", "split": "split20"}}
315
+ ]
316
+ }}
317
+ ```
318
+
319
  ## Construction
320
 
321
  1. Parse all sentence-separated CoNLL-style files from:
 
328
  4. Reconstruct full sentence text and both token and character spans.
329
  5. Deduplicate by `(sentence, entity, type, start_token, end_token)` and merge provenance.
330
 
331
+ ## Parsing details and edge cases
332
+
333
+ - `Wojood1_1_flat` uses simple space-separated `token tag` rows.
334
+ - `Wojood1_1_nested` uses space-separated rows with multiple BIO tags on the same token when nested annotations exist.
335
+ - `WojoodFine` and `WojoodFine-Flat` use tab-separated rows.
336
+ - Some `WojoodFine` rows place multiple tags inside a single tab field, for example:
337
+ - `نبيه\\tI-OCC B-PERS\\t\\t\\t`
338
+ The builder normalizes this by splitting tag cells on internal whitespace.
339
+ - Some fine labels appear with alias spellings that differ from the ontology ids, for example:
340
+ - `GPE-ORG` -> `GPE_ORG`
341
+ - `Cluster` -> `CLUSTER`
342
+ - `Path` -> `PATH`
343
+ The builder canonicalizes these before mapping to coarse parents.
344
+ - Sentence boundaries are read from blank lines in the CoNLL files.
345
+ - Character spans are reconstructed after joining sentence tokens with single spaces.
346
+
347
  ## Summary
348
 
349
  - total rows: `{summary['total_rows']}`
 
358
  ## Top coarse types
359
 
360
  {top_types}
361
+
362
+ ## Validation performed
363
+
364
+ - verified that all four non-relation Wojood sources were included
365
+ - verified nested extraction is enabled when multiple tags occur on one token
366
+ - verified fine-to-coarse mapping uses the repo's `wojood_ontology.json`
367
+ - verified `sentence[start_char:end_char] == entity` across the built file
368
+ - verified deduped rows merge provenance rather than silently dropping it
369
  """
370
 
371