Kriyans commited on
Commit
db585e5
1 Parent(s): 9a58bab

Update indian_names.py

Browse files
Files changed (1) hide show
  1. indian_names.py +89 -11
indian_names.py CHANGED
@@ -1,28 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import datasets
2
 
3
 
4
  logger = datasets.logging.get_logger(__name__)
5
 
6
 
7
- csv_file_path = "https://github.com/Kriyansparsana/demorepo/blob/main/wnut17train.conll"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
 
 
 
 
 
 
 
 
 
9
 
10
- class indina_namesConfig(datasets.BuilderConfig):
 
 
 
 
 
11
 
12
  def __init__(self, **kwargs):
13
- super(indina_namesConfig, self).__init__(**kwargs)
 
 
 
 
14
 
15
 
16
- class indina_names(datasets.GeneratorBasedBuilder):
 
17
 
18
  BUILDER_CONFIGS = [
19
- indina_namesConfig(
20
- name="indina_names", version=datasets.Version("1.0.0"), description="The indina_names Emerging Entities Dataset"
21
  ),
22
  ]
23
 
24
  def _info(self):
25
  return datasets.DatasetInfo(
 
26
  features=datasets.Features(
27
  {
28
  "id": datasets.Value("string"),
@@ -30,25 +93,40 @@ class indina_names(datasets.GeneratorBasedBuilder):
30
  "ner_tags": datasets.Sequence(
31
  datasets.features.ClassLabel(
32
  names=[
33
- "B-PER",
34
- "B-ORG",
 
 
 
 
 
 
 
 
 
 
 
35
  ]
36
  )
37
  ),
38
  }
39
  ),
40
  supervised_keys=None,
 
 
41
  )
42
 
43
  def _split_generators(self, dl_manager):
44
  """Returns SplitGenerators."""
45
  urls_to_download = {
46
- "train": f"{csv_file_path}",
 
47
  }
48
  downloaded_files = dl_manager.download_and_extract(urls_to_download)
49
 
50
  return [
51
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
 
52
  ]
53
 
54
  def _generate_examples(self, filepath):
@@ -61,9 +139,9 @@ class indina_names(datasets.GeneratorBasedBuilder):
61
  row = row.rstrip()
62
  if row:
63
  token, label = row.split("\t")
64
- row_values = row.split("\t")
65
  current_tokens.append(token)
66
  current_labels.append(label)
 
67
  # New sentence
68
  if not current_tokens:
69
  # Consecutive empty lines will cause empty sentences
@@ -87,4 +165,4 @@ class indina_names(datasets.GeneratorBasedBuilder):
87
  "id": str(sentence_counter),
88
  "tokens": current_tokens,
89
  "ner_tags": current_labels,
90
- }
 
1
+ # coding=utf-8
2
+ # Copyright 2020 HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """The WNUT 17 Emerging Entities Dataset."""
18
+
19
+
20
  import datasets
21
 
22
 
23
  logger = datasets.logging.get_logger(__name__)
24
 
25
 
26
+ _CITATION = """\
27
+ @inproceedings{derczynski-etal-2017-results,
28
+ title = "Results of the {WNUT}2017 Shared Task on Novel and Emerging Entity Recognition",
29
+ author = "Derczynski, Leon and
30
+ Nichols, Eric and
31
+ van Erp, Marieke and
32
+ Limsopatham, Nut",
33
+ booktitle = "Proceedings of the 3rd Workshop on Noisy User-generated Text",
34
+ month = sep,
35
+ year = "2017",
36
+ address = "Copenhagen, Denmark",
37
+ publisher = "Association for Computational Linguistics",
38
+ url = "https://www.aclweb.org/anthology/W17-4418",
39
+ doi = "10.18653/v1/W17-4418",
40
+ pages = "140--147",
41
+ abstract = "This shared task focuses on identifying unusual, previously-unseen entities in the context of emerging discussions.
42
+ Named entities form the basis of many modern approaches to other tasks (like event clustering and summarization),
43
+ but recall on them is a real problem in noisy text - even among annotators.
44
+ This drop tends to be due to novel entities and surface forms.
45
+ Take for example the tweet {``}so.. kktny in 30 mins?!{''} {--} even human experts find the entity {`}kktny{'}
46
+ hard to detect and resolve. The goal of this task is to provide a definition of emerging and of rare entities,
47
+ and based on that, also datasets for detecting these entities. The task as described in this paper evaluated the
48
+ ability of participating entries to detect and classify novel and emerging named entities in noisy text.",
49
+ }
50
+ """
51
 
52
+ _DESCRIPTION = """\
53
+ WNUT 17: Emerging and Rare entity recognition
54
+ This shared task focuses on identifying unusual, previously-unseen entities in the context of emerging discussions.
55
+ Named entities form the basis of many modern approaches to other tasks (like event clustering and summarisation),
56
+ but recall on them is a real problem in noisy text - even among annotators. This drop tends to be due to novel entities and surface forms.
57
+ Take for example the tweet “so.. kktny in 30 mins?” - even human experts find entity kktny hard to detect and resolve.
58
+ This task will evaluate the ability to detect and classify novel, emerging, singleton named entities in noisy text.
59
+ The goal of this task is to provide a definition of emerging and of rare entities, and based on that, also datasets for detecting these entities.
60
+ """
61
 
62
+ _URL = "https://github.com/Kriyansparsana/demorepo/blob/main/"
63
+ _TRAINING_FILE = "wnut17train.conll"
64
+
65
+
66
+ class indian_namesConfig(datasets.BuilderConfig):
67
+ """The WNUT 17 Emerging Entities Dataset."""
68
 
69
  def __init__(self, **kwargs):
70
+ """BuilderConfig for WNUT 17.
71
+ Args:
72
+ **kwargs: keyword arguments forwarded to super.
73
+ """
74
+ super(indian_namesConfig, self).__init__(**kwargs)
75
 
76
 
77
+ class indian_names(datasets.GeneratorBasedBuilder):
78
+ """The WNUT 17 Emerging Entities Dataset."""
79
 
80
  BUILDER_CONFIGS = [
81
+ indian_namesConfig(
82
+ name="indian_names", version=datasets.Version("1.0.0"), description="The indian_names Emerging Entities Dataset"
83
  ),
84
  ]
85
 
86
  def _info(self):
87
  return datasets.DatasetInfo(
88
+ description=_DESCRIPTION,
89
  features=datasets.Features(
90
  {
91
  "id": datasets.Value("string"),
 
93
  "ner_tags": datasets.Sequence(
94
  datasets.features.ClassLabel(
95
  names=[
96
+ "O",
97
+ "B-corporation",
98
+ "I-corporation",
99
+ "B-creative-work",
100
+ "I-creative-work",
101
+ "B-group",
102
+ "I-group",
103
+ "B-location",
104
+ "I-location",
105
+ "B-person",
106
+ "I-person",
107
+ "B-product",
108
+ "I-product",
109
  ]
110
  )
111
  ),
112
  }
113
  ),
114
  supervised_keys=None,
115
+ homepage="http://noisy-text.github.io/2017/emerging-rare-entities.html",
116
+ citation=_CITATION,
117
  )
118
 
119
  def _split_generators(self, dl_manager):
120
  """Returns SplitGenerators."""
121
  urls_to_download = {
122
+ "train": f"{_URL}{_TRAINING_FILE}",
123
+
124
  }
125
  downloaded_files = dl_manager.download_and_extract(urls_to_download)
126
 
127
  return [
128
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
129
+
130
  ]
131
 
132
  def _generate_examples(self, filepath):
 
139
  row = row.rstrip()
140
  if row:
141
  token, label = row.split("\t")
 
142
  current_tokens.append(token)
143
  current_labels.append(label)
144
+ else:
145
  # New sentence
146
  if not current_tokens:
147
  # Consecutive empty lines will cause empty sentences
 
165
  "id": str(sentence_counter),
166
  "tokens": current_tokens,
167
  "ner_tags": current_labels,
168
+ }