lannliat commited on
Commit
446abaf
1 Parent(s): 5c5a1d4

First version of the multilexnorm dataset

Browse files
Files changed (2) hide show
  1. .gitignore +162 -0
  2. multilexnorm.py +182 -0
.gitignore ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ temp.ipynb
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/#use-with-ide
112
+ .pdm.toml
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
multilexnorm.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # TODO: Address all TODOs and remove all explanatory comments
15
+ """ Multilexnorm dataset."""
16
+
17
+
18
+ import csv
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ # TODO: Add BibTeX citation
26
+ # Find for instance the citation on arxiv or on the dataset repo/website
27
+ _CITATION = r"""\
28
+ @inproceedings{van-der-goot-etal-2021-multilexnorm,
29
+ title = "{M}ulti{L}ex{N}orm: A Shared Task on Multilingual Lexical Normalization",
30
+ author = {van der Goot, Rob and
31
+ Ramponi, Alan and
32
+ Zubiaga, Arkaitz and
33
+ Plank, Barbara and
34
+ Muller, Benjamin and
35
+ San Vicente Roncal, I{\~n}aki and
36
+ Ljube{\v{s}}i{\'c}, Nikola and
37
+ {\c{C}}etino{\u{g}}lu, {\"O}zlem and
38
+ Mahendra, Rahmad and
39
+ {\c{C}}olako{\u{g}}lu, Talha and
40
+ Baldwin, Timothy and
41
+ Caselli, Tommaso and
42
+ Sidorenko, Wladimir},
43
+ booktitle = "Proceedings of the Seventh Workshop on Noisy User-generated Text (W-NUT 2021)",
44
+ month = nov,
45
+ year = "2021",
46
+ address = "Online",
47
+ publisher = "Association for Computational Linguistics",
48
+ url = "https://aclanthology.org/2021.wnut-1.55",
49
+ doi = "10.18653/v1/2021.wnut-1.55",
50
+ pages = "493--509",
51
+ abstract = "Lexical normalization is the task of transforming an utterance into its standardized form. This task is beneficial for downstream analysis, as it provides a way to harmonize (often spontaneous) linguistic variation. Such variation is typical for social media on which information is shared in a multitude of ways, including diverse languages and code-switching. Since the seminal work of Han and Baldwin (2011) a decade ago, lexical normalization has attracted attention in English and multiple other languages. However, there exists a lack of a common benchmark for comparison of systems across languages with a homogeneous data and evaluation setup. The MultiLexNorm shared task sets out to fill this gap. We provide the largest publicly available multilingual lexical normalization benchmark including 13 language variants. We propose a homogenized evaluation setup with both intrinsic and extrinsic evaluation. As extrinsic evaluation, we use dependency parsing and part-of-speech tagging with adapted evaluation metrics (a-LAS, a-UAS, and a-POS) to account for alignment discrepancies. The shared task hosted at W-NUT 2021 attracted 9 participants and 18 submissions. The results show that neural normalization systems outperform the previous state-of-the-art system by a large margin. Downstream parsing and part-of-speech tagging performance is positively affected but to varying degrees, with improvements of up to 1.72 a-LAS, 0.85 a-UAS, and 1.54 a-POS for the winning system.",
52
+ }
53
+ """
54
+
55
+ # TODO: Add description of the dataset here
56
+ # You can copy an official description
57
+ _DESCRIPTION = """\
58
+ For this task, participants are asked to develop a system that performs lexical normalization: the conversion of non-canonical texts to their canonical equivalent form. In particular, this task includes data from 12 languages.
59
+ """
60
+
61
+ # TODO: Add a link to an official homepage for the dataset here
62
+ _HOMEPAGE = "http://noisy-text.github.io/2021/multi-lexnorm.html"
63
+
64
+ # TODO: Add the licence for the dataset here if you can find it
65
+ _LICENSE = "Creative Commons Attribution 4.0 International License."
66
+
67
+ # TODO: Add link to the official dataset URLs here
68
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
69
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
70
+ _URLS = {
71
+ "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
72
+ "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
73
+ }
74
+
75
+ _DATA_DIR = "./data"
76
+
77
+ # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
78
+ class MultiLexNorm(datasets.GeneratorBasedBuilder):
79
+ """ Lexnorm dataset for 12 languages."""
80
+
81
+ VERSION = datasets.Version("1.1.0")
82
+
83
+ # This is an example of a dataset with multiple configurations.
84
+ # If you don't want/need to define several sub-sets in your dataset,
85
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
86
+
87
+ # If you need to make complex sub-parts in the datasets with configurable options
88
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
89
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
90
+
91
+ # You will be able to load one or the other configurations in the following list with
92
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
93
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
94
+ BUILDER_CONFIGS = [
95
+ datasets.BuilderConfig(name="da", version=VERSION, description="Danish"),
96
+ datasets.BuilderConfig(name="de", version=VERSION, description="German"),
97
+ datasets.BuilderConfig(name="en", version=VERSION, description="English"),
98
+ datasets.BuilderConfig(name="es", version=VERSION, description="Spanish"),
99
+ datasets.BuilderConfig(name="hr", version=VERSION, description="Croatian"),
100
+ datasets.BuilderConfig(name="id-en", version=VERSION, description="Indonesian-English"),
101
+ datasets.BuilderConfig(name="it", version=VERSION, description="Italian"),
102
+ datasets.BuilderConfig(name="nl", version=VERSION, description="Dutch"),
103
+ datasets.BuilderConfig(name="sl", version=VERSION, description="Slovenian"),
104
+ datasets.BuilderConfig(name="sr", version=VERSION, description="Serbian"),
105
+ datasets.BuilderConfig(name="tr", version=VERSION, description="Turkish"),
106
+ datasets.BuilderConfig(name="tr-de", version=VERSION, description="Turkish-German"),
107
+ ]
108
+
109
+ def _info(self):
110
+ # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
111
+ features = datasets.Features(
112
+ {
113
+ "inputs": datasets.Value("string"),
114
+ "targets": datasets.Value("string"),
115
+ # These are the features of your dataset like images, labels ...
116
+ }
117
+ )
118
+ return datasets.DatasetInfo(
119
+ # This is the description that will appear on the datasets page.
120
+ description=_DESCRIPTION,
121
+ # This defines the different columns of the dataset and their types
122
+ features=features, # Here we define them above because they are different between the two configurations
123
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
124
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
125
+ # supervised_keys=("sentence", "label"),
126
+ # Homepage of the dataset for documentation
127
+ homepage=_HOMEPAGE,
128
+ # License for the dataset if available
129
+ license=_LICENSE,
130
+ # Citation for the dataset
131
+ citation=_CITATION,
132
+ )
133
+
134
+ def _split_generators(self, dl_manager):
135
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
136
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
137
+
138
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
139
+ # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
140
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
141
+
142
+ return [
143
+ datasets.SplitGenerator(
144
+ name=datasets.Split.TRAIN,
145
+ # These kwargs will be passed to _generate_examples
146
+ gen_kwargs={
147
+ "filepath": os.path.join(_DATA_DIR, self.config.name, "train.norm"),
148
+ "split": "train",
149
+ },
150
+ ),
151
+ datasets.SplitGenerator(
152
+ name=datasets.Split.VALIDATION,
153
+ # These kwargs will be passed to _generate_examples
154
+ gen_kwargs={
155
+ "filepath": os.path.join(_DATA_DIR, self.config.name, "dev.norm"),
156
+ "split": "dev",
157
+ },
158
+ ),
159
+ datasets.SplitGenerator(
160
+ name=datasets.Split.TEST,
161
+ # These kwargs will be passed to _generate_examples
162
+ gen_kwargs={
163
+ "filepath": os.path.join(_DATA_DIR, self.config.name, "test.norm"),
164
+ "split": "test",
165
+ },
166
+ ),
167
+ ]
168
+
169
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
170
+ def _generate_examples(self, filepath, split):
171
+ # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
172
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
173
+ with open(filepath, encoding="utf-8") as f:
174
+ for key, line in enumerate(f):
175
+ if len(line) > 1:
176
+ ip, tgt = line.split("\t")
177
+ else: # blank
178
+ ip, tgt = "", ""
179
+ yield key, {
180
+ "inputs": ip,
181
+ "targets": tgt,
182
+ }