albertvillanova HF staff commited on
Commit
d489d2d
1 Parent(s): 2f4bf07

Delete loading script

Browse files
Files changed (1) hide show
  1. bing_coronavirus_query_set.py +0 -131
bing_coronavirus_query_set.py DELETED
@@ -1,131 +0,0 @@
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
-
18
- import datasets
19
-
20
-
21
- _DESCRIPTION = """\
22
- This dataset was curated from the Bing search logs (desktop users only) over the period of Jan 1st, 2020 – (Current Month - 1). Only searches that were issued many times by multiple users were included. The dataset includes queries from all over the world that had an intent related to the Coronavirus or Covid-19. In some cases this intent is explicit in the query itself (e.g., “Coronavirus updates Seattle”), in other cases it is implicit , e.g. “Shelter in place”. The implicit intent of search queries (e.g., “Toilet paper”) was extracted using random walks on the click graph as outlined in this paper by Microsoft Research. All personal data were removed.
23
- """
24
- _HOMEPAGE_URL = "https://github.com/microsoft/BingCoronavirusQuerySet"
25
- _CITATION = None
26
-
27
- _VERSION = "1.0.0"
28
- _BASE_URL = "https://raw.githubusercontent.com/microsoft/BingCoronavirusQuerySet/master/data/2020/{}_{}_{}.tsv"
29
-
30
-
31
- class BingCoronavirusQuerySetConfig(datasets.BuilderConfig):
32
- def __init__(self, *args, queries_by=None, start_date=None, end_date=None, **kwargs):
33
- super().__init__(
34
- *args,
35
- name=f"{queries_by}_{start_date}_{end_date}",
36
- **kwargs,
37
- )
38
- self.queries_by = queries_by
39
- self.start_date = start_date
40
- self.end_date = end_date
41
-
42
-
43
- class BingCoronavirusQuerySet(datasets.GeneratorBasedBuilder):
44
- BUILDER_CONFIGS = [
45
- BingCoronavirusQuerySetConfig(
46
- queries_by="country",
47
- start_date="2020-09-01",
48
- end_date="2020-09-30",
49
- description="Query by: country, start_date: 2020-09-01, end_date: 2020-09-30",
50
- version=datasets.Version(_VERSION),
51
- )
52
- ]
53
- BUILDER_CONFIG_CLASS = BingCoronavirusQuerySetConfig
54
-
55
- def _info(self):
56
- if self.config.queries_by == "country":
57
- features = datasets.Features(
58
- {
59
- "id": datasets.Value("int32"),
60
- "Date": datasets.Value("string"),
61
- "Query": datasets.Value("string"),
62
- "IsImplicitIntent": datasets.Value("string"),
63
- "Country": datasets.Value("string"),
64
- "PopularityScore": datasets.Value("int32"),
65
- },
66
- )
67
- elif self.config.queries_by == "state":
68
- features = datasets.Features(
69
- {
70
- "id": datasets.Value("int32"),
71
- "Date": datasets.Value("string"),
72
- "Query": datasets.Value("string"),
73
- "IsImplicitIntent": datasets.Value("string"),
74
- "State": datasets.Value("string"),
75
- "Country": datasets.Value("string"),
76
- "PopularityScore": datasets.Value("int32"),
77
- },
78
- )
79
- else:
80
- raise Exception("Unknown queries_by. Choose one of: country or state")
81
- return datasets.DatasetInfo(
82
- description=_DESCRIPTION,
83
- features=features,
84
- supervised_keys=None,
85
- homepage=_HOMEPAGE_URL,
86
- citation=_CITATION,
87
- )
88
-
89
- def _split_generators(self, dl_manager):
90
- def _base_url(queries_by, start_date, end_date):
91
- if queries_by == "country":
92
- queries_by = "QueriesByCountry"
93
- else:
94
- queries_by = "QueriesByState"
95
- return _BASE_URL.format(queries_by, start_date, end_date)
96
-
97
- download_url = _base_url(self.config.queries_by, self.config.start_date, self.config.end_date)
98
- path = dl_manager.download_and_extract(download_url)
99
- return [
100
- datasets.SplitGenerator(
101
- name=datasets.Split.TRAIN,
102
- gen_kwargs={"datapath": path},
103
- )
104
- ]
105
-
106
- def _generate_examples(self, datapath):
107
- with open(datapath, encoding="utf-8") as f:
108
- for sentence_counter, row in enumerate(f):
109
- if sentence_counter == 0:
110
- continue
111
- row = row.strip().split("\t")
112
- if self.config.queries_by == "country":
113
- resp = {
114
- "id": sentence_counter,
115
- "Date": row[0],
116
- "Query": row[1],
117
- "IsImplicitIntent": row[2],
118
- "Country": row[3],
119
- "PopularityScore": row[4],
120
- }
121
- else:
122
- resp = {
123
- "id": sentence_counter,
124
- "Date": row[0],
125
- "Query": row[1],
126
- "IsImplicitIntent": row[2],
127
- "State": row[3],
128
- "Country": row[4],
129
- "PopularityScore": int(row[5]),
130
- }
131
- yield sentence_counter, resp