Vasily Alexeev commited on
Commit ·
8447272
1
Parent(s): 55a54e6
refine datasets name usage in readme
Browse files
README.md
CHANGED
|
@@ -108,14 +108,14 @@ bow = load_dataset(
|
|
| 108 |
)
|
| 109 |
```
|
| 110 |
|
| 111 |
-
From the
|
| 112 |
|
| 113 |
```python
|
| 114 |
noow = load_dataset(
|
| 115 |
-
"csv", data_files={"corpus": "
|
| 116 |
)
|
| 117 |
bow = load_dataset(
|
| 118 |
-
"csv", data_files={"corpus": "
|
| 119 |
)
|
| 120 |
```
|
| 121 |
|
|
@@ -133,7 +133,7 @@ from pathlib import Path
|
|
| 133 |
|
| 134 |
csv.field_size_limit(2**31 - 1)
|
| 135 |
with Path("data/noow.csv").open(encoding="utf-8", newline="") as source:
|
| 136 |
-
with Path("../
|
| 137 |
for row in csv.DictReader(source):
|
| 138 |
output.write(row["vw_text"] + "\n")
|
| 139 |
```
|
|
@@ -293,24 +293,40 @@ without information from held-out documents. For text-only experiments, use only
|
|
| 293 |
|
| 294 |
### Rebuild NLP CSVs from ready article snapshots
|
| 295 |
|
| 296 |
-
Run
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
|
|
|
| 301 |
runtime for both build and verify: VW escaping depends on its Unicode database.
|
| 302 |
On Linux x86-64, use the supplied locks:
|
| 303 |
|
| 304 |
```bash
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
conda activate ruwiki-nlp
|
| 307 |
-
python -m pip install -r
|
| 308 |
-
python
|
| 309 |
-
python
|
| 310 |
-
|
| 311 |
-
python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
```
|
| 313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
`--stage nlp` is the default, so earlier commands without `--stage` continue to
|
| 315 |
work. Choose `--dataset full`, `selected` or `both`. The
|
| 316 |
[pinned NLP contract](preprocessing/wikipedia-quality-nlp-20261001.json) records
|
|
@@ -324,10 +340,10 @@ requirements in a separate environment, retain Python 3.11.15.
|
|
| 324 |
|
| 325 |
Download checks existing source files against their pins, fetches missing files,
|
| 326 |
and acquires the pinned NLTK archive at
|
| 327 |
-
`
|
| 328 |
-
place them at `
|
| 329 |
-
`
|
| 330 |
-
`
|
| 331 |
the local NLTK resource directory; no pre-existing `nltk_data` is required.
|
| 332 |
Use `--nltk-data` to select a different local NLTK resource directory.
|
| 333 |
|
|
@@ -335,7 +351,7 @@ Hugging Face downloads use anonymous Python `urllib`. For restricted repositorie
|
|
| 335 |
fetch the pinned files with authenticated tools, place them at the paths above,
|
| 336 |
and rerun download. The script does not handle authentication tokens.
|
| 337 |
Build runs offline, checks runtime versions and Russian stopword content, and
|
| 338 |
-
writes `
|
| 339 |
separate from published data and use a fresh scratch directory for a new build.
|
| 340 |
Progress messages identify phases and document counts. Each build manifest
|
| 341 |
records counts and ordered IDs of documents with an empty `@word` namespace;
|
|
@@ -358,11 +374,16 @@ one environment, not a bound for other machines.
|
|
| 358 |
Load a generated CSV directly:
|
| 359 |
|
| 360 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
noow = load_dataset(
|
| 362 |
-
"csv", data_files={"corpus":
|
| 363 |
)
|
| 364 |
bow = load_dataset(
|
| 365 |
-
"csv", data_files={"corpus":
|
| 366 |
)
|
| 367 |
```
|
| 368 |
|
|
@@ -375,25 +396,34 @@ retained Selected annotations. This public raw-dump replay has **not yet been ru
|
|
| 375 |
end to end**. Its download time, build time and peak disk and memory requirements
|
| 376 |
have not been measured; the NLP measurements above do not describe this stage.
|
| 377 |
|
| 378 |
-
|
| 379 |
-
|
| 380 |
The Selected annotation directory must already contain `labels.json` and
|
| 381 |
`topics.jsonl.gz`. These retained mappings reproduce the published subject
|
| 382 |
assignments; the script does not rerun AI labeling.
|
| 383 |
|
| 384 |
```bash
|
| 385 |
-
python
|
|
|
|
| 386 |
# Resume an interrupted dump download explicitly:
|
| 387 |
-
python
|
| 388 |
-
|
| 389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
```
|
| 391 |
|
| 392 |
Download stores and checks the six pinned files beneath `--sources-dir`.
|
| 393 |
After all files are present, build is offline. It reconstructs SQL metadata,
|
| 394 |
selects qualifying article IDs, extracts the indexed XML revisions, and applies
|
| 395 |
-
the readable-text cleanup. It writes `
|
| 396 |
-
`categories.jsonl.gz`, plus `
|
| 397 |
`topics.jsonl.gz`. Use separate fresh output and scratch directories, leaving
|
| 398 |
published `data/` untouched. Corpus verification compares outputs with the
|
| 399 |
independently bundled expected published payloads, rather than trusting hashes
|
|
@@ -401,11 +431,19 @@ newly written by the build itself.
|
|
| 401 |
|
| 402 |
For Full only, set `--dataset full` and omit `--annotations-dir`. Selected can
|
| 403 |
also be reconstructed from a previously accepted Full corpus without rereading
|
| 404 |
-
the dumps. From the same
|
| 405 |
|
| 406 |
```bash
|
| 407 |
-
|
| 408 |
-
python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
```
|
| 410 |
|
| 411 |
This Selected-only workflow has been verified byte for byte against the published
|
|
@@ -416,9 +454,15 @@ usable as `--sources-dir`. Download then supplies the pinned NLTK archive before
|
|
| 416 |
the offline NLP build:
|
| 417 |
|
| 418 |
```bash
|
| 419 |
-
python
|
| 420 |
-
|
| 421 |
-
python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
```
|
| 423 |
|
| 424 |
The code in `preprocessing/` is available under its [MIT license](preprocessing/LICENSE).
|
|
|
|
| 108 |
)
|
| 109 |
```
|
| 110 |
|
| 111 |
+
From the root of the downloaded repository:
|
| 112 |
|
| 113 |
```python
|
| 114 |
noow = load_dataset(
|
| 115 |
+
"csv", data_files={"corpus": "data/noow.csv"}, split="corpus"
|
| 116 |
)
|
| 117 |
bow = load_dataset(
|
| 118 |
+
"csv", data_files={"corpus": "data/bow.csv"}, split="corpus"
|
| 119 |
)
|
| 120 |
```
|
| 121 |
|
|
|
|
| 133 |
|
| 134 |
csv.field_size_limit(2**31 - 1)
|
| 135 |
with Path("data/noow.csv").open(encoding="utf-8", newline="") as source:
|
| 136 |
+
with Path("../noow.vw").open("w", encoding="utf-8", newline="") as output:
|
| 137 |
for row in csv.DictReader(source):
|
| 138 |
output.write(row["vw_text"] + "\n")
|
| 139 |
```
|
|
|
|
| 293 |
|
| 294 |
### Rebuild NLP CSVs from ready article snapshots
|
| 295 |
|
| 296 |
+
Run the preparation commands from `preprocessing/` in the downloaded Full
|
| 297 |
+
collection. Local repository directories may have any names. Replace the paths
|
| 298 |
+
below with your own absolute paths: `work_dir` is a separate working directory,
|
| 299 |
+
and `selected_data` points to the Selected collection's `data/` directory.
|
| 300 |
+
Choose fresh output and scratch paths on a disk with enough space; corpus output
|
| 301 |
+
and scratch inside a published clone are rejected. Python 3.11.15 is the pinned
|
| 302 |
runtime for both build and verify: VW escaping depends on its Unicode database.
|
| 303 |
On Linux x86-64, use the supplied locks:
|
| 304 |
|
| 305 |
```bash
|
| 306 |
+
cd "/absolute/path/to/full/preprocessing"
|
| 307 |
+
work_dir="/absolute/path/to/ruwiki-rebuild"
|
| 308 |
+
selected_data="/absolute/path/to/selected/data"
|
| 309 |
+
|
| 310 |
+
conda create --name ruwiki-nlp --file conda-linux-64.lock.txt
|
| 311 |
conda activate ruwiki-nlp
|
| 312 |
+
python -m pip install -r pip-linux-x86_64.lock.txt
|
| 313 |
+
python prepare.py --help
|
| 314 |
+
python prepare.py --stage nlp --action download --dataset both \
|
| 315 |
+
--sources-dir "$work_dir/nlp-sources"
|
| 316 |
+
python prepare.py --stage nlp --action build --dataset both \
|
| 317 |
+
--sources-dir "$work_dir/nlp-sources" \
|
| 318 |
+
--output-dir "$work_dir/nlp-output" \
|
| 319 |
+
--scratch-dir "$work_dir/nlp-scratch"
|
| 320 |
+
python prepare.py --stage nlp --action verify --dataset both \
|
| 321 |
+
--sources-dir "$work_dir/nlp-sources" \
|
| 322 |
+
--output-dir "$work_dir/nlp-output"
|
| 323 |
```
|
| 324 |
|
| 325 |
+
Local paths above are independent of Hugging Face repository names. Online
|
| 326 |
+
loading examples and cross-repository links use the published Hugging Face IDs.
|
| 327 |
+
If those IDs change, the links and the downloader's pinned source addresses need
|
| 328 |
+
to be reviewed separately; renaming a local directory does not change them.
|
| 329 |
+
|
| 330 |
`--stage nlp` is the default, so earlier commands without `--stage` continue to
|
| 331 |
work. Choose `--dataset full`, `selected` or `both`. The
|
| 332 |
[pinned NLP contract](preprocessing/wikipedia-quality-nlp-20261001.json) records
|
|
|
|
| 340 |
|
| 341 |
Download checks existing source files against their pins, fetches missing files,
|
| 342 |
and acquires the pinned NLTK archive at
|
| 343 |
+
`$work_dir/nlp-sources/nltk_data/corpora/stopwords.zip`. To reuse downloaded JSONL files,
|
| 344 |
+
place them at `$work_dir/nlp-sources/full/articles.jsonl.gz`,
|
| 345 |
+
`$work_dir/nlp-sources/selected/articles.jsonl.gz` and
|
| 346 |
+
`$work_dir/nlp-sources/selected/topics.jsonl.gz` before running download. This step creates
|
| 347 |
the local NLTK resource directory; no pre-existing `nltk_data` is required.
|
| 348 |
Use `--nltk-data` to select a different local NLTK resource directory.
|
| 349 |
|
|
|
|
| 351 |
fetch the pinned files with authenticated tools, place them at the paths above,
|
| 352 |
and rerun download. The script does not handle authentication tokens.
|
| 353 |
Build runs offline, checks runtime versions and Russian stopword content, and
|
| 354 |
+
writes `$work_dir/nlp-output/full` and `$work_dir/nlp-output/selected`. Keep outputs and scratch
|
| 355 |
separate from published data and use a fresh scratch directory for a new build.
|
| 356 |
Progress messages identify phases and document counts. Each build manifest
|
| 357 |
records counts and ordered IDs of documents with an empty `@word` namespace;
|
|
|
|
| 374 |
Load a generated CSV directly:
|
| 375 |
|
| 376 |
```python
|
| 377 |
+
from pathlib import Path
|
| 378 |
+
|
| 379 |
+
# Use the same work directory as in the shell commands.
|
| 380 |
+
work_dir = Path("/absolute/path/to/ruwiki-rebuild")
|
| 381 |
+
output_dir = work_dir / "nlp-output/full"
|
| 382 |
noow = load_dataset(
|
| 383 |
+
"csv", data_files={"corpus": str(output_dir / "noow.csv")}, split="corpus"
|
| 384 |
)
|
| 385 |
bow = load_dataset(
|
| 386 |
+
"csv", data_files={"corpus": str(output_dir / "bow.csv")}, split="corpus"
|
| 387 |
)
|
| 388 |
```
|
| 389 |
|
|
|
|
| 396 |
end to end**. Its download time, build time and peak disk and memory requirements
|
| 397 |
have not been measured; the NLP measurements above do not describe this stage.
|
| 398 |
|
| 399 |
+
Keep the same `preprocessing/` working directory and path variables as in the
|
| 400 |
+
NLP commands above.
|
| 401 |
The Selected annotation directory must already contain `labels.json` and
|
| 402 |
`topics.jsonl.gz`. These retained mappings reproduce the published subject
|
| 403 |
assignments; the script does not rerun AI labeling.
|
| 404 |
|
| 405 |
```bash
|
| 406 |
+
python prepare.py --stage corpus --action download --dataset both \
|
| 407 |
+
--sources-dir "$work_dir/dump-sources"
|
| 408 |
# Resume an interrupted dump download explicitly:
|
| 409 |
+
python prepare.py --stage corpus --action download --dataset both \
|
| 410 |
+
--sources-dir "$work_dir/dump-sources" \
|
| 411 |
+
--resume
|
| 412 |
+
python prepare.py --stage corpus --action build --dataset both \
|
| 413 |
+
--sources-dir "$work_dir/dump-sources" \
|
| 414 |
+
--annotations-dir "$selected_data" \
|
| 415 |
+
--output-dir "$work_dir/corpus-output" \
|
| 416 |
+
--scratch-dir "$work_dir/corpus-scratch"
|
| 417 |
+
python prepare.py --stage corpus --action verify --dataset both \
|
| 418 |
+
--sources-dir "$work_dir/dump-sources" \
|
| 419 |
+
--output-dir "$work_dir/corpus-output"
|
| 420 |
```
|
| 421 |
|
| 422 |
Download stores and checks the six pinned files beneath `--sources-dir`.
|
| 423 |
After all files are present, build is offline. It reconstructs SQL metadata,
|
| 424 |
selects qualifying article IDs, extracts the indexed XML revisions, and applies
|
| 425 |
+
the readable-text cleanup. It writes `$work_dir/corpus-output/full/articles.jsonl.gz` and
|
| 426 |
+
`categories.jsonl.gz`, plus `$work_dir/corpus-output/selected/articles.jsonl.gz` and
|
| 427 |
`topics.jsonl.gz`. Use separate fresh output and scratch directories, leaving
|
| 428 |
published `data/` untouched. Corpus verification compares outputs with the
|
| 429 |
independently bundled expected published payloads, rather than trusting hashes
|
|
|
|
| 431 |
|
| 432 |
For Full only, set `--dataset full` and omit `--annotations-dir`. Selected can
|
| 433 |
also be reconstructed from a previously accepted Full corpus without rereading
|
| 434 |
+
the dumps. From the same `preprocessing/` directory, resolve Full's data path:
|
| 435 |
|
| 436 |
```bash
|
| 437 |
+
full_data="$(cd ../data && pwd -P)"
|
| 438 |
+
python prepare.py --stage corpus --action build --dataset selected \
|
| 439 |
+
--sources-dir "$full_data" \
|
| 440 |
+
--full-dir "$full_data" \
|
| 441 |
+
--annotations-dir "$selected_data" \
|
| 442 |
+
--output-dir "$work_dir/selected-output" \
|
| 443 |
+
--scratch-dir "$work_dir/selected-scratch"
|
| 444 |
+
python prepare.py --stage corpus --action verify --dataset selected \
|
| 445 |
+
--sources-dir "$full_data" \
|
| 446 |
+
--output-dir "$work_dir/selected-output"
|
| 447 |
```
|
| 448 |
|
| 449 |
This Selected-only workflow has been verified byte for byte against the published
|
|
|
|
| 454 |
the offline NLP build:
|
| 455 |
|
| 456 |
```bash
|
| 457 |
+
python prepare.py --stage nlp --action download --dataset both \
|
| 458 |
+
--sources-dir "$work_dir/corpus-output"
|
| 459 |
+
python prepare.py --stage nlp --action build --dataset both \
|
| 460 |
+
--sources-dir "$work_dir/corpus-output" \
|
| 461 |
+
--output-dir "$work_dir/replay-nlp-output" \
|
| 462 |
+
--scratch-dir "$work_dir/replay-nlp-scratch"
|
| 463 |
+
python prepare.py --stage nlp --action verify --dataset both \
|
| 464 |
+
--sources-dir "$work_dir/corpus-output" \
|
| 465 |
+
--output-dir "$work_dir/replay-nlp-output"
|
| 466 |
```
|
| 467 |
|
| 468 |
The code in `preprocessing/` is available under its [MIT license](preprocessing/LICENSE).
|