Martyna Wiącek commited on
Commit
f7403e0
1 Parent(s): ee89518

final version of nlprepl.py

Browse files
Files changed (25) hide show
  1. nkjp_tagset/fair_by_document_name/_conll/dev_nlprepl-nkjp.conll.gz +3 -0
  2. nkjp_tagset/fair_by_document_name/_conll/test_nlprepl-nkjp.conll.gz +3 -0
  3. nkjp_tagset/fair_by_document_name/_conll/train_nlprepl-nkjp.conll.gz +3 -0
  4. nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_dev_nlprepl-nkjp.conll.gz +3 -0
  5. nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_test_nlprepl-nkjp.conll.gz +3 -0
  6. nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_train_nlprepl-nkjp.conll.gz +3 -0
  7. nkjp_tagset/fair_by_document_name/{dev_nlprepl-nkjp.conllu.gz → _conllu/dev_nlprepl-nkjp.conllu.gz} +0 -0
  8. nkjp_tagset/fair_by_document_name/{test_nlprepl-nkjp.conllu.gz → _conllu/test_nlprepl-nkjp.conllu.gz} +0 -0
  9. nkjp_tagset/fair_by_document_name/{train_nlprepl-nkjp.conllu.gz → _conllu/train_nlprepl-nkjp.conllu.gz} +0 -0
  10. nkjp_tagset/fair_by_document_type/_conll/dev_nlprepl-nkjp.conll.gz +3 -0
  11. nkjp_tagset/fair_by_document_type/_conll/test_nlprepl-nkjp.conll.gz +3 -0
  12. nkjp_tagset/fair_by_document_type/_conll/train_nlprepl-nkjp.conll.gz +3 -0
  13. nkjp_tagset/fair_by_document_type/_conll_space_after/multiword_space_after_dev_nlprepl-nkjp.conll.gz +3 -0
  14. nkjp_tagset/fair_by_document_type/_conll_space_after/multiword_space_after_test_nlprepl-nkjp.conll.gz +3 -0
  15. nkjp_tagset/fair_by_document_type/_conll_space_after/multiword_space_after_train_nlprepl-nkjp.conll.gz +3 -0
  16. nkjp_tagset/fair_by_document_type/{dev_nlprepl-nkjp.conllu.gz → _conllu/dev_nlprepl-nkjp.conllu.gz} +0 -0
  17. nkjp_tagset/fair_by_document_type/{test_nlprepl-nkjp.conllu.gz → _conllu/test_nlprepl-nkjp.conllu.gz} +0 -0
  18. nkjp_tagset/fair_by_document_type/{train_nlprepl-nkjp.conllu.gz → _conllu/train_nlprepl-nkjp.conllu.gz} +0 -0
  19. nlprepl.py +75 -26
  20. ud_tagset/fair_by_document_name/{dev_nlprepl-ud.conllu.gz → _conllu/dev_nlprepl-ud.conllu.gz} +0 -0
  21. ud_tagset/fair_by_document_name/{test_nlprepl-ud.conllu.gz → _conllu/test_nlprepl-ud.conllu.gz} +0 -0
  22. ud_tagset/fair_by_document_name/{train_nlprepl-ud.conllu.gz → _conllu/train_nlprepl-ud.conllu.gz} +0 -0
  23. ud_tagset/fair_by_document_type/{dev_nlprepl-ud.conllu.gz → _conllu/dev_nlprepl-ud.conllu.gz} +0 -0
  24. ud_tagset/fair_by_document_type/{test_nlprepl-ud.conllu.gz → _conllu/test_nlprepl-ud.conllu.gz} +0 -0
  25. ud_tagset/fair_by_document_type/{train_nlprepl-ud.conllu.gz → _conllu/train_nlprepl-ud.conllu.gz} +0 -0
nkjp_tagset/fair_by_document_name/_conll/dev_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4b51e5b273a7aac5562274c251020d5270527a0d010835847af744f1ac7b51e
3
+ size 1430153
nkjp_tagset/fair_by_document_name/_conll/test_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e2051028f2d95642f81767ca9ada79bae40536119de21058b1653e002d81f6a
3
+ size 1591281
nkjp_tagset/fair_by_document_name/_conll/train_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd2ff5f5fc63f8014ed2bf55855c68860d798b9e9fdf80fcc71c8a11bdbca0a8
3
+ size 12691647
nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_dev_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4a07b86f0d4bb7d41a052ab819ff50334e4889e3ac85ea161576d73ae21da62
3
+ size 1465716
nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_test_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:634e0c4d0de9bfc1ac9eeefda845aad9505d34ff2b9c8a7bf25264380ee3b1e9
3
+ size 1630643
nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_train_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06eec6efcebc805c5ed0bfccb6ee3e029236177567e74f6e1d30bad7aa04a473
3
+ size 13008638
nkjp_tagset/fair_by_document_name/{dev_nlprepl-nkjp.conllu.gz → _conllu/dev_nlprepl-nkjp.conllu.gz} RENAMED
File without changes
nkjp_tagset/fair_by_document_name/{test_nlprepl-nkjp.conllu.gz → _conllu/test_nlprepl-nkjp.conllu.gz} RENAMED
File without changes
nkjp_tagset/fair_by_document_name/{train_nlprepl-nkjp.conllu.gz → _conllu/train_nlprepl-nkjp.conllu.gz} RENAMED
File without changes
nkjp_tagset/fair_by_document_type/_conll/dev_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec30bc3c105852a537e30470fb7beca7e2bf8061ed00afb56d0ad88fa1d91e2f
3
+ size 1467266
nkjp_tagset/fair_by_document_type/_conll/test_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a851a4440dbb571e89b05d578f5c71abcb7da5b54d131a5a43179b79713a355
3
+ size 1630292
nkjp_tagset/fair_by_document_type/_conll/train_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7724541f89b5e5a37764805a8eeab62244bf079403f9543f0098b3739befc9a
3
+ size 12610773
nkjp_tagset/fair_by_document_type/_conll_space_after/multiword_space_after_dev_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e93013fba08bf85803a9d888be34076904d982cc1a9a346aee0046a5a3e8f4b
3
+ size 1503561
nkjp_tagset/fair_by_document_type/_conll_space_after/multiword_space_after_test_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e60a816a197ce819ab2b3c307358b570bbbf82bedaf0a70f8e40d7cb41f10ca0
3
+ size 1670153
nkjp_tagset/fair_by_document_type/_conll_space_after/multiword_space_after_train_nlprepl-nkjp.conll.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a9f87e727d615f14bc49f477d693eadb978f00d301976095f027b7639df72fe
3
+ size 12926291
nkjp_tagset/fair_by_document_type/{dev_nlprepl-nkjp.conllu.gz → _conllu/dev_nlprepl-nkjp.conllu.gz} RENAMED
File without changes
nkjp_tagset/fair_by_document_type/{test_nlprepl-nkjp.conllu.gz → _conllu/test_nlprepl-nkjp.conllu.gz} RENAMED
File without changes
nkjp_tagset/fair_by_document_type/{train_nlprepl-nkjp.conllu.gz → _conllu/train_nlprepl-nkjp.conllu.gz} RENAMED
File without changes
nlprepl.py CHANGED
@@ -14,10 +14,16 @@ BY_TYPE = "by_type"
14
  TAGSET_NKJP = "nkjp"
15
  TAGSET_UD = "ud"
16
 
 
 
 
 
 
 
17
  _DESCRIPTION = {
18
  BY_NAME: {
19
  TAGSET_NKJP: "NLPrePL divided by document name for NKJP tagset",
20
- TAGSET_UD: "NLPrePL divided by document name for UD tagset"
21
  },
22
  BY_TYPE: {
23
  TAGSET_NKJP: "NLPrePL divided by document type for NKJP tagset",
@@ -30,28 +36,60 @@ _TAGSETS = [TAGSET_NKJP, TAGSET_UD]
30
 
31
  _URLS = {
32
  BY_NAME: {
33
- TAGSET_NKJP: {
34
- 'train': "nkjp_tagset/fair_by_document_name/train_nlprepl-nkjp.conllu.gz",
35
- 'dev': "nkjp_tagset/fair_by_document_name/dev_nlprepl-nkjp.conllu.gz",
36
- 'test': "nkjp_tagset/fair_by_document_name/test_nlprepl-nkjp.conllu.gz"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  },
38
- TAGSET_UD: {
39
- 'train': "ud_tagset/fair_by_document_name/train_nlprepl-ud.conllu.gz",
40
- 'dev': "ud_tagset/fair_by_document_name/dev_nlprepl-ud.conllu.gz",
41
- 'test': "ud_tagset/fair_by_document_name/test_nlprepl-ud.conllu.gz"
42
- }
43
  },
44
  BY_TYPE: {
45
- TAGSET_NKJP: {
46
- 'train': "nkjp_tagset/fair_by_document_type/train_nlprepl-nkjp.conllu.gz",
47
- 'dev': "nkjp_tagset/fair_by_document_type/dev_nlprepl-nkjp.conllu.gz",
48
- 'test': "nkjp_tagset/fair_by_document_type/test_nlprepl-nkjp.conllu.gz"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  },
50
- TAGSET_UD: {
51
- 'train': "ud_tagset/fair_by_document_type/train_nlprepl-ud.conllu.gz",
52
- 'dev': "ud_tagset/fair_by_document_type/dev_nlprepl-ud.conllu.gz",
53
- 'test': "ud_tagset/fair_by_document_type/test_nlprepl-ud.conllu.gz"
54
- }
55
  }
56
  }
57
 
@@ -59,7 +97,7 @@ _URLS = {
59
  class NLPrePLConfig(datasets.BuilderConfig):
60
  """BuilderConfig for NKJP1M"""
61
 
62
- def __init__(self, tagset, **kwargs):
63
  """BuilderConfig forNKJP1M.
64
 
65
  Args:
@@ -68,6 +106,7 @@ class NLPrePLConfig(datasets.BuilderConfig):
68
  super(NLPrePLConfig, self).__init__(**kwargs)
69
 
70
  self.tagset = tagset
 
71
 
72
 
73
  class NLPrePL(datasets.GeneratorBasedBuilder):
@@ -75,16 +114,18 @@ class NLPrePL(datasets.GeneratorBasedBuilder):
75
 
76
  BUILDER_CONFIGS = [
77
  NLPrePLConfig(
78
- name=t + "-" + tagset,
79
  version=datasets.Version("1.0.0"),
80
  tagset=tagset,
 
81
  description=_DESCRIPTION[t]
82
  )
83
- for t in _TYPES for tagset in _TAGSETS
84
  ]
85
 
86
  def _info(self):
87
- dataset, tagset = self.config.name.split("-")
 
88
  return datasets.DatasetInfo(
89
  description=_DESCRIPTION[dataset][tagset],
90
  features=datasets.Features(
@@ -110,8 +151,8 @@ class NLPrePL(datasets.GeneratorBasedBuilder):
110
 
111
  def _split_generators(self, dl_manager):
112
  """Returns SplitGenerators."""
113
- dataset, tagset = self.config.name.split("-")
114
- urls = _URLS[dataset][tagset]
115
  downloaded_files = dl_manager.download_and_extract(urls)
116
  return [
117
  datasets.SplitGenerator(
@@ -126,8 +167,16 @@ class NLPrePL(datasets.GeneratorBasedBuilder):
126
  ]
127
 
128
  def _generate_examples(self, filepath):
 
 
 
 
 
 
 
129
  id = 0
130
  logger.info("⏳ Generating examples from = %s", filepath)
 
131
 
132
  with open(filepath, 'r', encoding="utf-8") as f:
133
  tokenlist = list(conllu.parse_incr(f))
@@ -156,6 +205,6 @@ class NLPrePL(datasets.GeneratorBasedBuilder):
156
  "head": [str(token["head"]) for token in sent],
157
  "deprel": [str(token["deprel"]) for token in sent],
158
  "deps": [str(token["deps"]) for token in sent],
159
- "misc": [str(token["misc"]) for token in sent],
160
  }
161
  id += 1
 
14
  TAGSET_NKJP = "nkjp"
15
  TAGSET_UD = "ud"
16
 
17
+ EXTENSION_CONLL = "conll"
18
+ EXTENSION_CONLLU = "conllu"
19
+ EXTENSION_CONLL_SPACE_AFTER = "conll_space_after"
20
+
21
+ _EXTENSIONS = [EXTENSION_CONLL, EXTENSION_CONLLU, EXTENSION_CONLL_SPACE_AFTER]
22
+
23
  _DESCRIPTION = {
24
  BY_NAME: {
25
  TAGSET_NKJP: "NLPrePL divided by document name for NKJP tagset",
26
+ TAGSET_UD: "TNLPrePL divided by document name for UD tagset"
27
  },
28
  BY_TYPE: {
29
  TAGSET_NKJP: "NLPrePL divided by document type for NKJP tagset",
 
36
 
37
  _URLS = {
38
  BY_NAME: {
39
+ EXTENSION_CONLLU: {
40
+ TAGSET_NKJP: {
41
+ 'train': "nkjp_tagset/fair_by_document_name/_conllu/train_nlprepl-nkjp.conllu.gz",
42
+ 'dev': "nkjp_tagset/fair_by_document_name/_conllu/dev_nlprepl-nkjp.conllu.gz",
43
+ 'test': "nkjp_tagset/fair_by_document_name/_conllu/test_nlprepl-nkjp.conllu.gz"
44
+ },
45
+ TAGSET_UD: {
46
+ 'train': "ud_tagset/fair_by_document_name/_conllu/train_nlprepl-ud.conllu.gz",
47
+ 'dev': "ud_tagset/fair_by_document_name/_conllu/dev_nlprepl-ud.conllu.gz",
48
+ 'test': "ud_tagset/fair_by_document_name/_conllu/test_nlprepl-ud.conllu.gz"
49
+ }
50
+ },
51
+ EXTENSION_CONLL: {
52
+ TAGSET_NKJP: {
53
+ 'train': "nkjp_tagset/fair_by_document_name/_conll/train_nlprepl-nkjp.conll.gz",
54
+ 'dev': "nkjp_tagset/fair_by_document_name/_conll/dev_nlprepl-nkjp.conll.gz",
55
+ 'test': "nkjp_tagset/fair_by_document_name/_conll/test_nlprepl-nkjp.conll.gz"
56
+ }
57
+ },
58
+ EXTENSION_CONLL_SPACE_AFTER: {
59
+ TAGSET_NKJP: {
60
+ 'train': "nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_train_nlprepl-nkjp.conll.gz",
61
+ 'dev': "nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_dev_nlprepl-nkjp.conll.gz",
62
+ 'test': "nkjp_tagset/fair_by_document_name/_conll_space_after/multiword_space_after_test_nlprepl-nkjp.conll.gz"
63
+ }
64
  },
 
 
 
 
 
65
  },
66
  BY_TYPE: {
67
+ EXTENSION_CONLLU: {
68
+ TAGSET_NKJP: {
69
+ 'train': "nkjp_tagset/fair_by_document_type/_conllu/train_nlprepl-nkjp.conllu.gz",
70
+ 'dev': "nkjp_tagset/fair_by_document_type/_conllu/dev_nlprepl-nkjp.conllu.gz",
71
+ 'test': "nkjp_tagset/fair_by_document_type/_conllu/test_nlprepl-nkjp.conllu.gz"
72
+ },
73
+ TAGSET_UD: {
74
+ 'train': "ud_tagset/fair_by_document_type/_conllu/train_nlprepl-ud.conllu.gz",
75
+ 'dev': "ud_tagset/fair_by_document_type/_conllu/dev_nlprepl-ud.conllu.gz",
76
+ 'test': "ud_tagset/fair_by_document_type/_conllu/test_nlprepl-ud.conllu.gz"
77
+ }
78
+ },
79
+ EXTENSION_CONLL: {
80
+ TAGSET_NKJP: {
81
+ 'train': "nkjp_tagset/fair_by_document_type/_conll/train_nlprepl-nkjp.conll.gz",
82
+ 'dev': "nkjp_tagset/fair_by_document_type/_conll/dev_nlprepl-nkjp.conll.gz",
83
+ 'test': "nkjp_tagset/fair_by_document_type/_conll/test_nlprepl-nkjp.conll.gz"
84
+ }
85
+ },
86
+ EXTENSION_CONLL_SPACE_AFTER: {
87
+ TAGSET_NKJP: {
88
+ 'train': "nkjp_tagset/fair_by_document_type/_conllu_space_after/multiword_space_after_train_nlprepl-nkjp.conll.gz",
89
+ 'dev': "nkjp_tagset/fair_by_document_type/_conllu_space_after/multiword_space_after_dev_nlprepl-nkjp.conll.gz",
90
+ 'test': "nkjp_tagset/fair_by_document_type/_conllu_space_after/multiword_space_after_test_nlprepl-nkjp.conll.gz"
91
+ }
92
  },
 
 
 
 
 
93
  }
94
  }
95
 
 
97
  class NLPrePLConfig(datasets.BuilderConfig):
98
  """BuilderConfig for NKJP1M"""
99
 
100
+ def __init__(self, tagset, extension, **kwargs):
101
  """BuilderConfig forNKJP1M.
102
 
103
  Args:
 
106
  super(NLPrePLConfig, self).__init__(**kwargs)
107
 
108
  self.tagset = tagset
109
+ self.extension = extension
110
 
111
 
112
  class NLPrePL(datasets.GeneratorBasedBuilder):
 
114
 
115
  BUILDER_CONFIGS = [
116
  NLPrePLConfig(
117
+ name=t + "-" + tagset + "-" + extension,
118
  version=datasets.Version("1.0.0"),
119
  tagset=tagset,
120
+ extension=extension,
121
  description=_DESCRIPTION[t]
122
  )
123
+ for t in _URLS.keys() for extension in _URLS[t].keys() for tagset in _URLS[t][extension].keys()
124
  ]
125
 
126
  def _info(self):
127
+ dataset, tagset, extension = self.config.name.split("-")
128
+
129
  return datasets.DatasetInfo(
130
  description=_DESCRIPTION[dataset][tagset],
131
  features=datasets.Features(
 
151
 
152
  def _split_generators(self, dl_manager):
153
  """Returns SplitGenerators."""
154
+ dataset, tagset, extension = self.config.name.split("-")
155
+ urls = _URLS[dataset][extension][tagset]
156
  downloaded_files = dl_manager.download_and_extract(urls)
157
  return [
158
  datasets.SplitGenerator(
 
167
  ]
168
 
169
  def _generate_examples(self, filepath):
170
+
171
+ def generate_misc_column(misc_content: dict):
172
+ if misc_content is None:
173
+ return ""
174
+ else:
175
+ return "|".join([k + "=" + v for k, v in misc_content.items()])
176
+
177
  id = 0
178
  logger.info("⏳ Generating examples from = %s", filepath)
179
+ print("Cached PATHS -- copy into STEP 5:", filepath)
180
 
181
  with open(filepath, 'r', encoding="utf-8") as f:
182
  tokenlist = list(conllu.parse_incr(f))
 
205
  "head": [str(token["head"]) for token in sent],
206
  "deprel": [str(token["deprel"]) for token in sent],
207
  "deps": [str(token["deps"]) for token in sent],
208
+ "misc": [generate_misc_column(token["misc"]) for token in sent],
209
  }
210
  id += 1
ud_tagset/fair_by_document_name/{dev_nlprepl-ud.conllu.gz → _conllu/dev_nlprepl-ud.conllu.gz} RENAMED
File without changes
ud_tagset/fair_by_document_name/{test_nlprepl-ud.conllu.gz → _conllu/test_nlprepl-ud.conllu.gz} RENAMED
File without changes
ud_tagset/fair_by_document_name/{train_nlprepl-ud.conllu.gz → _conllu/train_nlprepl-ud.conllu.gz} RENAMED
File without changes
ud_tagset/fair_by_document_type/{dev_nlprepl-ud.conllu.gz → _conllu/dev_nlprepl-ud.conllu.gz} RENAMED
File without changes
ud_tagset/fair_by_document_type/{test_nlprepl-ud.conllu.gz → _conllu/test_nlprepl-ud.conllu.gz} RENAMED
File without changes
ud_tagset/fair_by_document_type/{train_nlprepl-ud.conllu.gz → _conllu/train_nlprepl-ud.conllu.gz} RENAMED
File without changes