Quentin Lhoest commited on
Commit
c1d9a20
1 Parent(s): f8ce113

Release: 1.18.1

Browse files

Commit from https://github.com/huggingface/datasets/commit/218e496519ff14b4bc69ea559616af6f2ef89e57

Files changed (1) hide show
  1. journalists_questions.py +76 -76
journalists_questions.py CHANGED
@@ -1,76 +1,76 @@
1
- # coding=utf-8
2
- # Copyright 2020 The TensorFlow Datasets Authors and the 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
-
17
- import csv
18
-
19
- import datasets
20
-
21
-
22
- _CITATION = """\
23
- @inproceedings{hasanain2016questions,
24
- title={What Questions Do Journalists Ask on Twitter?},
25
- author={Hasanain, Maram and Bagdouri, Mossaab and Elsayed, Tamer and Oard, Douglas W},
26
- booktitle={Tenth International AAAI Conference on Web and Social Media},
27
- year={2016}
28
- }
29
- """
30
-
31
- _DESCRIPTION = """\
32
- The journalists_questions corpus (version 1.0) is a collection of 10K human-written Arabic
33
- tweets manually labeled for question identification over Arabic tweets posted by journalists.
34
- """
35
- _DATA_URL = "https://drive.google.com/uc?export=download&id=1CBrh-9OrSpKmPQBxTK_ji6mq6WTN_U9U"
36
-
37
-
38
- class JournalistsQuestions(datasets.GeneratorBasedBuilder):
39
- BUILDER_CONFIGS = [
40
- datasets.BuilderConfig(
41
- name="plain_text",
42
- version=datasets.Version("1.0.0", ""),
43
- description="Journalists tweet IDs and annotation by whether the tweet has a question",
44
- )
45
- ]
46
-
47
- def _info(self):
48
- return datasets.DatasetInfo(
49
- description=_DESCRIPTION,
50
- features=datasets.Features(
51
- {
52
- "tweet_id": datasets.Value("string"),
53
- "label": datasets.features.ClassLabel(names=["no", "yes"]),
54
- "label_confidence": datasets.Value("float"),
55
- }
56
- ),
57
- homepage="http://qufaculty.qu.edu.qa/telsayed/datasets/",
58
- citation=_CITATION,
59
- )
60
-
61
- def _split_generators(self, dl_manager):
62
- dl_dir = dl_manager.download_and_extract(_DATA_URL)
63
- return [
64
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": dl_dir}),
65
- ]
66
-
67
- def _generate_examples(self, filepath):
68
- """This function returns the examples in the raw (text) form."""
69
- with open(filepath, encoding="utf-8") as f:
70
- reader = csv.DictReader(f, delimiter="\t", fieldnames=["tweet_id", "label", "label_confidence"])
71
- for idx, row in enumerate(reader):
72
- yield idx, {
73
- "tweet_id": row["tweet_id"],
74
- "label": row["label"],
75
- "label_confidence": float(row["label_confidence"]),
76
- }
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the 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
+
17
+ import csv
18
+
19
+ import datasets
20
+
21
+
22
+ _CITATION = """\
23
+ @inproceedings{hasanain2016questions,
24
+ title={What Questions Do Journalists Ask on Twitter?},
25
+ author={Hasanain, Maram and Bagdouri, Mossaab and Elsayed, Tamer and Oard, Douglas W},
26
+ booktitle={Tenth International AAAI Conference on Web and Social Media},
27
+ year={2016}
28
+ }
29
+ """
30
+
31
+ _DESCRIPTION = """\
32
+ The journalists_questions corpus (version 1.0) is a collection of 10K human-written Arabic
33
+ tweets manually labeled for question identification over Arabic tweets posted by journalists.
34
+ """
35
+ _DATA_URL = "https://drive.google.com/uc?export=download&id=1CBrh-9OrSpKmPQBxTK_ji6mq6WTN_U9U"
36
+
37
+
38
+ class JournalistsQuestions(datasets.GeneratorBasedBuilder):
39
+ BUILDER_CONFIGS = [
40
+ datasets.BuilderConfig(
41
+ name="plain_text",
42
+ version=datasets.Version("1.0.0", ""),
43
+ description="Journalists tweet IDs and annotation by whether the tweet has a question",
44
+ )
45
+ ]
46
+
47
+ def _info(self):
48
+ return datasets.DatasetInfo(
49
+ description=_DESCRIPTION,
50
+ features=datasets.Features(
51
+ {
52
+ "tweet_id": datasets.Value("string"),
53
+ "label": datasets.features.ClassLabel(names=["no", "yes"]),
54
+ "label_confidence": datasets.Value("float"),
55
+ }
56
+ ),
57
+ homepage="http://qufaculty.qu.edu.qa/telsayed/datasets/",
58
+ citation=_CITATION,
59
+ )
60
+
61
+ def _split_generators(self, dl_manager):
62
+ dl_dir = dl_manager.download_and_extract(_DATA_URL)
63
+ return [
64
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": dl_dir}),
65
+ ]
66
+
67
+ def _generate_examples(self, filepath):
68
+ """This function returns the examples in the raw (text) form."""
69
+ with open(filepath, encoding="utf-8") as f:
70
+ reader = csv.DictReader(f, delimiter="\t", fieldnames=["tweet_id", "label", "label_confidence"])
71
+ for idx, row in enumerate(reader):
72
+ yield idx, {
73
+ "tweet_id": row["tweet_id"],
74
+ "label": row["label"],
75
+ "label_confidence": float(row["label_confidence"]),
76
+ }