lannliat commited on
Commit
cb1a1bb
1 Parent(s): 3ffddfd

Fix imports, filename, README.

Browse files
Files changed (3) hide show
  1. .gitignore +4 -0
  2. README.md +21 -1
  3. load_script.py → opus.py +2 -4
.gitignore CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  # Byte-compiled / optimized / DLL files
2
  __pycache__/
3
  *.py[cod]
 
1
+ data
2
+ test_loader.ipynb
3
+ preprocess.ipynb
4
+
5
  # Byte-compiled / optimized / DLL files
6
  __pycache__/
7
  *.py[cod]
README.md CHANGED
@@ -48,7 +48,8 @@ task_ids: []
48
  ## Dataset Description
49
  Loads [OPUS](https://opus.nlpl.eu/) as HuggingFace dataset. OPUS is an open parallel corpus covering 700+ languages and 1100+ datasets.
50
 
51
- Given a `src` and `tgt` language, this repository loads *all* available parallel corpus. To my knowledge, other OPUS datasets on Huggingface loads a specific corpus
 
52
 
53
  **Requirements**. Pip install my fork of `OpusTools`.
54
 
@@ -57,6 +58,25 @@ git clone https://github.com/larrylawl/OpusTools.git
57
  pip install -e OpusTools/opustools_pkg
58
  ```
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  **Disclaimer**.
61
 
62
  This repository is still in active development. Do make a PR if there're any issues!
 
48
  ## Dataset Description
49
  Loads [OPUS](https://opus.nlpl.eu/) as HuggingFace dataset. OPUS is an open parallel corpus covering 700+ languages and 1100+ datasets.
50
 
51
+ Given a `src` and `tgt` language, this repository can load *all* available parallel corpus. To my knowledge, other OPUS datasets on Huggingface loads a specific corpus
52
+
53
 
54
  **Requirements**. Pip install my fork of `OpusTools`.
55
 
 
58
  pip install -e OpusTools/opustools_pkg
59
  ```
60
 
61
+ **Example Usage**.
62
+
63
+ ```
64
+ # args follows `opustools`: https://pypi.org/project/opustools/
65
+
66
+ src="en"
67
+ tgt="id"
68
+ download_dir="data" # dir to save downloaded files
69
+ corpus="bible-uedin" # corpus name. Leave as `None` to download all available corpus for the src-tgt pair.
70
+
71
+
72
+ dataset = load_dataset("larrylawl/opus",
73
+ src=src,
74
+ tgt=tgt,
75
+ download_dir=download_dir,
76
+ corpus=corpus)
77
+ )
78
+ ```
79
+
80
  **Disclaimer**.
81
 
82
  This repository is still in active development. Do make a PR if there're any issues!
load_script.py → opus.py RENAMED
@@ -22,9 +22,7 @@ import os
22
  from typing import List
23
  import datasets
24
  import pandas as pd
25
- from constants import *
26
- from OpusTools.opustools_pkg.opustools.opus_read import OpusRead
27
- from OpusTools.opustools_pkg.opustools.opus_get import OpusRead
28
 
29
  _DESCRIPTION = """\
30
  Downloads OPUS data using `opustools`.
@@ -43,7 +41,7 @@ class OpusConfig(datasets.BuilderConfig):
43
  Args:
44
  src: str, source language
45
  tgt: str, target language
46
- corpus: List[str], List of corpus names. Leave as `None` to download all available corpus for the src-tgt pair.
47
  download_dir: str, dir to save downloaded files
48
 
49
  """
 
22
  from typing import List
23
  import datasets
24
  import pandas as pd
25
+ import opustools
 
 
26
 
27
  _DESCRIPTION = """\
28
  Downloads OPUS data using `opustools`.
 
41
  Args:
42
  src: str, source language
43
  tgt: str, target language
44
+ corpus: str, corpus name. Leave as `None` to download all available corpus for the src-tgt pair.
45
  download_dir: str, dir to save downloaded files
46
 
47
  """