Datasets:
Critical fix: MWT detection was incorrectly including empty nodes
Browse filesIssue: Empty nodes (8, '.', 1) were being added to BOTH mwts and empty_nodes:
- As MWT: "8-1" (wrong - invalid ID)
- As empty_node: "8.1" (correct)
Root cause: MWT detection checked isinstance(token['id'], tuple) without
checking the middle element. Both MWTs and empty nodes are tuples:
- MWT: (1, '-', 2) for "1-2"
- Empty node: (8, '.', 1) for "8.1"
Fix: Add token['id'][1] == '-' check to MWT detection to exclude empty nodes
This caused 75 validation errors in sentences with empty nodes.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
tools/04_generate_parquet.py
CHANGED
|
@@ -90,9 +90,11 @@ def extract_examples_from_conllu(filepath: str) -> List[Dict[str, Any]]:
|
|
| 90 |
sent_idx = str(idx)
|
| 91 |
|
| 92 |
# Extract Multi-Word Tokens (MWTs) - tokens with tuple IDs like (1, '-', 2)
|
|
|
|
| 93 |
mwts = []
|
| 94 |
for token in sent:
|
| 95 |
-
if isinstance(token["id"], tuple)
|
|
|
|
| 96 |
mwts.append({
|
| 97 |
"id": f"{token['id'][0]}-{token['id'][2]}",
|
| 98 |
"form": token["form"],
|
|
|
|
| 90 |
sent_idx = str(idx)
|
| 91 |
|
| 92 |
# Extract Multi-Word Tokens (MWTs) - tokens with tuple IDs like (1, '-', 2)
|
| 93 |
+
# Note: Exclude empty nodes which have '.' as middle element: (22, '.', 1)
|
| 94 |
mwts = []
|
| 95 |
for token in sent:
|
| 96 |
+
if isinstance(token["id"], tuple) and len(token["id"]) == 3 and token["id"][1] == '-':
|
| 97 |
+
# MWT line (e.g., (1, '-', 2) for "1-2")
|
| 98 |
mwts.append({
|
| 99 |
"id": f"{token['id'][0]}-{token['id'][2]}",
|
| 100 |
"form": token["form"],
|
tools/templates/universal_dependencies.tmpl
CHANGED
|
@@ -194,9 +194,11 @@ class UniversalDependencies(datasets.GeneratorBasedBuilder):
|
|
| 194 |
idx = id
|
| 195 |
|
| 196 |
# Extract Multi-Word Tokens (MWTs) - tokens with tuple IDs like (1, '-', 2)
|
|
|
|
| 197 |
mwts = []
|
| 198 |
for token in sent:
|
| 199 |
-
if isinstance(token["id"], tuple)
|
|
|
|
| 200 |
mwts.append({
|
| 201 |
"id": f"{token['id'][0]}-{token['id'][2]}",
|
| 202 |
"form": token["form"],
|
|
|
|
| 194 |
idx = id
|
| 195 |
|
| 196 |
# Extract Multi-Word Tokens (MWTs) - tokens with tuple IDs like (1, '-', 2)
|
| 197 |
+
# Note: Exclude empty nodes which have '.' as middle element: (22, '.', 1)
|
| 198 |
mwts = []
|
| 199 |
for token in sent:
|
| 200 |
+
if isinstance(token["id"], tuple) and len(token["id"]) == 3 and token["id"][1] == '-':
|
| 201 |
+
# MWT line (e.g., (1, '-', 2) for "1-2")
|
| 202 |
mwts.append({
|
| 203 |
"id": f"{token['id'][0]}-{token['id'][2]}",
|
| 204 |
"form": token["form"],
|