iiegn Claude Sonnet 4.5 commited on
Commit
287fe11
·
verified ·
1 Parent(s): 8749bb2

Update MIGRATION.md for external ud-hf-parquet-tools library

Browse files

Major updates to reflect architectural changes:

**New Section: Helper Functions Moved to External Library**
- Documents that parse_feats, parse_misc, write_conllu, etc. are no longer
part of the dataset
- Provides installation instructions for ud-hf-parquet-tools package
- Shows updated import examples using the external library
- Includes alternative for users who don't need helper functions (work with
raw strings directly)

**Updated "What's New" Section**
- Added overview of architecture changes (Parquet, no Python script, external
helper library)
- Clarified data changes (MWT bug fix, new MWT field, enhanced metadata)

**New Issue: Helper Function Import Errors**
- Added Issue 4 documenting ImportError when trying to import from
non-existent universal_dependencies module
- Provides clear solution with installation and import examples

**Enhanced Summary**
- Added "v2.0 is modular" to key takeaways
- Updated migration checklist with helper library installation steps
- Separated estimated migration time for basic vs. helper function users
- Added resources section with links to dataset, helper library, and changelog

**Updated Support Section**
- Added link to ud-hf-parquet-tools documentation

All code examples now use correct imports from ud-hf-parquet-tools package.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. MIGRATION.md +114 -3
MIGRATION.md CHANGED
@@ -2,6 +2,18 @@
2
 
3
  This guide helps you migrate from Universal Dependencies dataset loader v1.x to v2.0.
4
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ## Quick Start
6
 
7
  ### For Users with datasets >=4.0.0
@@ -186,6 +198,73 @@ dataset = load_dataset(
186
  )
187
  ```
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  ## New Features in v2.0
190
 
191
  ### 1. Parquet Format (5-10x Faster Loading)
@@ -344,13 +423,35 @@ tokens = example["tokens"]
344
  mwts = example.get("mwt", []) # Empty list if not present
345
  ```
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  ## Support
348
 
349
  If you encounter issues during migration:
350
 
351
  1. Check the [CHANGELOG.md](CHANGELOG.md) for detailed changes
352
  2. Review the [README.md](README.md) for updated examples
353
- 3. Report issues at: https://github.com/UniversalDependencies/UD_HuggingFace/issues
 
354
 
355
  ## Summary
356
 
@@ -360,13 +461,23 @@ If you encounter issues during migration:
360
  ✅ **v2.0 is faster:** Parquet format is 5-10x quicker
361
  ✅ **v2.0 is more secure:** No remote code execution
362
  ✅ **v2.0 adds features:** MWT information now available
 
363
 
364
  **Migration Checklist:**
365
 
366
  - [ ] Upgrade to datasets >=4.0.0
367
  - [ ] Test your code with v2.0 data
368
  - [ ] Update token count expectations (if using MWT treebanks)
369
- - [ ] Utilize new MWT field for research (optional)
370
  - [ ] Update any hard-coded token indices (if applicable)
 
 
 
 
 
 
 
371
 
372
- **Estimated Migration Time:** 15-30 minutes for most users
 
 
 
 
2
 
3
  This guide helps you migrate from Universal Dependencies dataset loader v1.x to v2.0.
4
 
5
+ ## What's New in v2.0
6
+
7
+ **Architecture Changes:**
8
+ - **Parquet format**: Native support with datasets >=4.0.0 (5-10x faster loading)
9
+ - **No Python script**: Dataset no longer requires `trust_remote_code=True`
10
+ - **External helper library**: CoNLL-U processing utilities moved to [`ud-hf-parquet-tools`](https://github.com/bot-zen/ud-hf-parquet-tools)
11
+
12
+ **Data Changes:**
13
+ - **MWT bug fix**: Token sequences now correctly exclude Multi-Word Token surface forms
14
+ - **MWT field added**: New structured `mwt` field with Multi-Word Token information
15
+ - **Enhanced metadata**: Includes `num_fused` (MWT counts) in statistics
16
+
17
  ## Quick Start
18
 
19
  ### For Users with datasets >=4.0.0
 
198
  )
199
  ```
200
 
201
+ ## Helper Functions Moved to External Library
202
+
203
+ **Important:** Helper functions for CoNLL-U processing are now in a separate package.
204
+
205
+ ### What Moved
206
+
207
+ The following functions are **no longer part of the dataset**:
208
+ - `parse_feats()`, `parse_misc()`, `parse_deps()` - Parse CoNLL-U field strings
209
+ - `write_conllu()`, `example_to_conllu()` - Export data to CoNLL-U format
210
+ - Various internal conversion utilities
211
+
212
+ ### How to Access Helper Functions
213
+
214
+ If you need CoNLL-U processing utilities, install the external library:
215
+
216
+ ```bash
217
+ pip install ud-hf-parquet-tools
218
+ ```
219
+
220
+ Then import from the package:
221
+
222
+ ```python
223
+ from datasets import load_dataset
224
+ from ud_hf_parquet_tools import parse_feats, parse_misc, write_conllu
225
+
226
+ # Load dataset
227
+ ds = load_dataset("commul/universal_dependencies", "en_ewt", split="train")
228
+
229
+ # Parse optional fields
230
+ sentence = ds[0]
231
+ for i, token in enumerate(sentence['tokens']):
232
+ feats = parse_feats(sentence['feats'][i]) # Returns dict or {}
233
+ misc = parse_misc(sentence['misc'][i]) # Returns dict or {}
234
+ print(f"{token}: UPOS={sentence['upos'][i]}, feats={feats}, misc={misc}")
235
+
236
+ # Export back to CoNLL-U format
237
+ write_conllu(ds, "output.conllu")
238
+ ```
239
+
240
+ **Library Documentation:** https://github.com/bot-zen/ud-hf-parquet-tools
241
+
242
+ ### If You Don't Need Helper Functions
243
+
244
+ Most users only need the dataset itself and can work directly with the fields:
245
+
246
+ ```python
247
+ from datasets import load_dataset
248
+
249
+ ds = load_dataset("commul/universal_dependencies", "en_ewt", split="train")
250
+
251
+ # Access data directly
252
+ sentence = ds[0]
253
+ print(f"Tokens: {sentence['tokens']}")
254
+ print(f"POS tags: {sentence['upos']}")
255
+ print(f"Dependencies: {sentence['deprel']}")
256
+
257
+ # FEATS and MISC are strings in CoNLL-U format
258
+ print(f"Features (raw): {sentence['feats'][0]}") # e.g., "Case=Nom|Number=Sing"
259
+ print(f"Misc (raw): {sentence['misc'][0]}") # e.g., "SpaceAfter=No"
260
+
261
+ # Parse manually if needed (simple cases)
262
+ feats_str = sentence['feats'][0]
263
+ if feats_str:
264
+ feats_dict = dict(kv.split('=') for kv in feats_str.split('|'))
265
+ print(f"Features (parsed): {feats_dict}")
266
+ ```
267
+
268
  ## New Features in v2.0
269
 
270
  ### 1. Parquet Format (5-10x Faster Loading)
 
423
  mwts = example.get("mwt", []) # Empty list if not present
424
  ```
425
 
426
+ ### Issue 4: Helper Function Import Errors
427
+
428
+ **Error:**
429
+ ```python
430
+ from universal_dependencies import parse_feats
431
+ # ImportError: No module named 'universal_dependencies'
432
+ ```
433
+
434
+ **Cause:** Helper functions moved to separate library
435
+
436
+ **Solution:**
437
+ ```bash
438
+ # Install the helper library
439
+ pip install ud-hf-parquet-tools
440
+
441
+ # Update imports
442
+ from ud_hf_parquet_tools import parse_feats, parse_misc, write_conllu
443
+ ```
444
+
445
+ Or work with raw strings directly (see "If You Don't Need Helper Functions" section above).
446
+
447
  ## Support
448
 
449
  If you encounter issues during migration:
450
 
451
  1. Check the [CHANGELOG.md](CHANGELOG.md) for detailed changes
452
  2. Review the [README.md](README.md) for updated examples
453
+ 3. Helper library documentation: https://github.com/bot-zen/ud-hf-parquet-tools
454
+ 4. Report issues at: https://huggingface.co/datasets/commul/universal_dependencies/discussions
455
 
456
  ## Summary
457
 
 
461
  ✅ **v2.0 is faster:** Parquet format is 5-10x quicker
462
  ✅ **v2.0 is more secure:** No remote code execution
463
  ✅ **v2.0 adds features:** MWT information now available
464
+ ✅ **v2.0 is modular:** Helper functions available as separate library
465
 
466
  **Migration Checklist:**
467
 
468
  - [ ] Upgrade to datasets >=4.0.0
469
  - [ ] Test your code with v2.0 data
470
  - [ ] Update token count expectations (if using MWT treebanks)
 
471
  - [ ] Update any hard-coded token indices (if applicable)
472
+ - [ ] If using helper functions: Install `ud-hf-parquet-tools` and update imports
473
+ - [ ] If exporting to CoNLL-U: Use `write_conllu()` from `ud-hf-parquet-tools`
474
+ - [ ] Utilize new MWT field for research (optional)
475
+
476
+ **Estimated Migration Time:**
477
+ - Basic usage: 15-30 minutes
478
+ - With helper functions: +10 minutes (install library, update imports)
479
 
480
+ **Resources:**
481
+ - Dataset repository: https://huggingface.co/datasets/commul/universal_dependencies
482
+ - Helper library: https://github.com/bot-zen/ud-hf-parquet-tools
483
+ - CHANGELOG: [CHANGELOG.md](CHANGELOG.md)