Datasets:
Matej Klemen
commited on
Commit
·
7524c13
1
Parent(s):
0492e5d
Add initial version of SloIE parsing script
Browse files- dataset_infos.json +1 -0
- sloie.py +102 -0
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "SloIE is a manually labelled dataset of Slovene idiomatic expressions. \nIt contains 29,400 sentences with 75 different expressions that can occur with either a literal or an idiomatic meaning, \nwith appropriate manual annotations for each token. The idiomatic expressions were selected from the Slovene Lexical \nDatabase (http://hdl.handle.net/11356/1030). Only expressions that can occur with both a literal and an idiomatic \nmeaning were selected. The sentences were extracted from the Gigafida corpus.\n", "citation": "@article{skvorc2022mice,\ntitle = {MICE: Mining Idioms with Contextual Embeddings},\njournal = {Knowledge-Based Systems},\nvolume = {235},\npages = {107606},\nyear = {2022},\nissn = {0950-7051},\ndoi = {https://doi.org/10.1016/j.knosys.2021.107606},\nurl = {https://www.sciencedirect.com/science/article/pii/S0950705121008686},\nauthor = {{\u000b S}kvorc, Tadej and Gantar, Polona and Robnik-{\u000b S}ikonja, Marko},\n}\n", "homepage": "http://hdl.handle.net/11356/1030", "license": "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)", "features": {"sentence": {"dtype": "string", "id": null, "_type": "Value"}, "expression": {"dtype": "string", "id": null, "_type": "Value"}, "word_order": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "sentence_words": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "is_idiom": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "sloie", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 15801505, "num_examples": 29399, "dataset_name": "sloie"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1335/SloIE.zip": {"num_bytes": 4425132, "checksum": "26602f475742c4717c7bfaa32e6d66b98220dfb5c7dc010d1b1cc8e7eb9a33b1"}}, "download_size": 4425132, "post_processing_size": null, "dataset_size": 15801505, "size_in_bytes": 20226637}}
|
sloie.py
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""" SloIE is a manually labelled dataset of Slovene idiomatic expressions. """
|
2 |
+
|
3 |
+
|
4 |
+
import os
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
_CITATION = """\
|
9 |
+
@article{skvorc2022mice,
|
10 |
+
title = {MICE: Mining Idioms with Contextual Embeddings},
|
11 |
+
journal = {Knowledge-Based Systems},
|
12 |
+
volume = {235},
|
13 |
+
pages = {107606},
|
14 |
+
year = {2022},
|
15 |
+
issn = {0950-7051},
|
16 |
+
doi = {https://doi.org/10.1016/j.knosys.2021.107606},
|
17 |
+
url = {https://www.sciencedirect.com/science/article/pii/S0950705121008686},
|
18 |
+
author = {{\v S}kvorc, Tadej and Gantar, Polona and Robnik-{\v S}ikonja, Marko},
|
19 |
+
}
|
20 |
+
"""
|
21 |
+
|
22 |
+
_DESCRIPTION = """\
|
23 |
+
SloIE is a manually labelled dataset of Slovene idiomatic expressions.
|
24 |
+
It contains 29,400 sentences with 75 different expressions that can occur with either a literal or an idiomatic meaning,
|
25 |
+
with appropriate manual annotations for each token. The idiomatic expressions were selected from the Slovene Lexical
|
26 |
+
Database (http://hdl.handle.net/11356/1030). Only expressions that can occur with both a literal and an idiomatic
|
27 |
+
meaning were selected. The sentences were extracted from the Gigafida corpus.
|
28 |
+
"""
|
29 |
+
|
30 |
+
_HOMEPAGE = "http://hdl.handle.net/11356/1030"
|
31 |
+
|
32 |
+
_LICENSE = "Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)"
|
33 |
+
|
34 |
+
_URLS = {
|
35 |
+
"sloie": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1335/SloIE.zip"
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
class SloIE(datasets.GeneratorBasedBuilder):
|
40 |
+
""" SloIE is a manually labelled dataset of Slovene idiomatic expressions. """
|
41 |
+
|
42 |
+
VERSION = datasets.Version("1.0.0")
|
43 |
+
|
44 |
+
def _info(self):
|
45 |
+
features = datasets.Features(
|
46 |
+
{
|
47 |
+
"sentence": datasets.Value("string"),
|
48 |
+
"expression": datasets.Value("string"),
|
49 |
+
"word_order": datasets.Sequence(datasets.Value("int32")),
|
50 |
+
"sentence_words": datasets.Sequence(datasets.Value("string")),
|
51 |
+
"is_idiom": datasets.Sequence(datasets.Value("string"))
|
52 |
+
}
|
53 |
+
)
|
54 |
+
return datasets.DatasetInfo(
|
55 |
+
description=_DESCRIPTION,
|
56 |
+
features=features,
|
57 |
+
homepage=_HOMEPAGE,
|
58 |
+
license=_LICENSE,
|
59 |
+
citation=_CITATION,
|
60 |
+
)
|
61 |
+
|
62 |
+
def _split_generators(self, dl_manager):
|
63 |
+
urls = _URLS["sloie"]
|
64 |
+
data_dir = dl_manager.download_and_extract(urls)
|
65 |
+
return [
|
66 |
+
datasets.SplitGenerator(
|
67 |
+
name=datasets.Split.TRAIN,
|
68 |
+
gen_kwargs={"file_path": os.path.join(data_dir, "SloIE.txt")}
|
69 |
+
)
|
70 |
+
]
|
71 |
+
|
72 |
+
def _generate_examples(self, file_path):
|
73 |
+
idx_instance = 0
|
74 |
+
with open(file_path, "r", encoding="utf-8") as f:
|
75 |
+
line = f.readline().strip()
|
76 |
+
while line:
|
77 |
+
assert line.startswith("#")
|
78 |
+
sent = line[1:] # Remove initial "#"
|
79 |
+
word_order = list(map(int, f.readline().strip().split(" ")))
|
80 |
+
expression = ""
|
81 |
+
sentence_words, idiomaticity = [], []
|
82 |
+
|
83 |
+
line = f.readline().strip()
|
84 |
+
while line:
|
85 |
+
token_info = line.split("\t")
|
86 |
+
word, is_idiomatic_str, expression = token_info
|
87 |
+
sentence_words.append(word)
|
88 |
+
idiomaticity.append(is_idiomatic_str)
|
89 |
+
|
90 |
+
line = f.readline().strip()
|
91 |
+
# Encountered start of the next sentence - Note that "#" may also be an annotated word, hence the second condition
|
92 |
+
if line.startswith("#") and len(line.split("\t")) == 1:
|
93 |
+
break
|
94 |
+
|
95 |
+
yield idx_instance, {
|
96 |
+
"sentence": sent,
|
97 |
+
"expression": expression,
|
98 |
+
"word_order": word_order,
|
99 |
+
"sentence_words": sentence_words,
|
100 |
+
"is_idiom": idiomaticity
|
101 |
+
}
|
102 |
+
idx_instance += 1
|