Regemens commited on
Commit
873af8a
1 Parent(s): a2bf465

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +130 -0
  2. quotes.jsonl +0 -0
README.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - expert-generated
6
+ - crowdsourced
7
+ language:
8
+ - en
9
+ multilinguality:
10
+ - monolingual
11
+ source_datasets:
12
+ - original
13
+ task_categories:
14
+ - text-classification
15
+ task_ids:
16
+ - multi-label-classification
17
+ ---
18
+
19
+
20
+ # ****Dataset Card for English quotes****
21
+ # **I-Dataset Summary**
22
+ english_quotes is a dataset of all the quotes retrieved from [goodreads quotes](https://www.goodreads.com/quotes). This dataset can be used for multi-label text classification and text generation. The content of each quote is in English and concerns the domain of datasets for NLP and beyond.
23
+
24
+ # **II-Supported Tasks and Leaderboards**
25
+ - Multi-label text classification : The dataset can be used to train a model for text-classification, which consists of classifying quotes by author as well as by topic (using tags). Success on this task is typically measured by achieving a high or low accuracy.
26
+ - Text-generation : The dataset can be used to train a model to generate quotes by fine-tuning an existing pretrained model on the corpus composed of all quotes (or quotes by author).
27
+
28
+ # **III-Languages**
29
+ The texts in the dataset are in English (en).
30
+
31
+ # **IV-Dataset Structure**
32
+ #### Data Instances
33
+ A JSON-formatted example of a typical instance in the dataset:
34
+ ```python
35
+ {'author': 'Ralph Waldo Emerson',
36
+ 'quote': '“To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.”',
37
+ 'tags': ['accomplishment', 'be-yourself', 'conformity', 'individuality']}
38
+ ```
39
+ #### Data Fields
40
+ - **author** : The author of the quote.
41
+ - **quote** : The text of the quote.
42
+ - **tags**: The tags could be characterized as topics around the quote.
43
+
44
+ #### Data Splits
45
+ I kept the dataset as one block (train), so it can be shuffled and split by users later using methods of the hugging face dataset library like the (.train_test_split()) method.
46
+
47
+ # **V-Dataset Creation**
48
+ #### Curation Rationale
49
+ I want to share my datasets (created by web scraping and additional cleaning treatments) with the HuggingFace community so that they can use them in NLP tasks to advance artificial intelligence.
50
+
51
+ #### Source Data
52
+ The source of Data is [goodreads](https://www.goodreads.com/?ref=nav_home) site: from [goodreads quotes](https://www.goodreads.com/quotes)
53
+
54
+ #### Initial Data Collection and Normalization
55
+
56
+ The data collection process is web scraping using BeautifulSoup and Requests libraries.
57
+ The data is slightly modified after the web scraping: removing all quotes with "None" tags, and the tag "attributed-no-source" is removed from all tags, because it has not added value to the topic of the quote.
58
+
59
+ #### Who are the source Data producers ?
60
+ The data is machine-generated (using web scraping) and subjected to human additional treatment.
61
+
62
+ below, I provide the script I created to scrape the data (as well as my additional treatment):
63
+ ```python
64
+ import requests
65
+ from bs4 import BeautifulSoup
66
+ import pandas as pd
67
+ import json
68
+ from collections import OrderedDict
69
+
70
+ page = requests.get('https://www.goodreads.com/quotes')
71
+ if page.status_code == 200:
72
+ pageParsed = BeautifulSoup(page.content, 'html5lib')
73
+
74
+ # Define a function that retrieves information about each HTML quote code in a dictionary form.
75
+ def extract_data_quote(quote_html):
76
+ quote = quote_html.find('div',{'class':'quoteText'}).get_text().strip().split('\n')[0]
77
+ author = quote_html.find('span',{'class':'authorOrTitle'}).get_text().strip()
78
+ if quote_html.find('div',{'class':'greyText smallText left'}) is not None:
79
+ tags_list = [tag.get_text() for tag in quote_html.find('div',{'class':'greyText smallText left'}).find_all('a')]
80
+ tags = list(OrderedDict.fromkeys(tags_list))
81
+ if 'attributed-no-source' in tags:
82
+ tags.remove('attributed-no-source')
83
+ else:
84
+ tags = None
85
+ data = {'quote':quote, 'author':author, 'tags':tags}
86
+ return data
87
+
88
+ # Define a function that retrieves all the quotes on a single page.
89
+ def get_quotes_data(page_url):
90
+ page = requests.get(page_url)
91
+ if page.status_code == 200:
92
+ pageParsed = BeautifulSoup(page.content, 'html5lib')
93
+ quotes_html_page = pageParsed.find_all('div',{'class':'quoteDetails'})
94
+ return [extract_data_quote(quote_html) for quote_html in quotes_html_page]
95
+
96
+ # Retrieve data from the first page.
97
+ data = get_quotes_data('https://www.goodreads.com/quotes')
98
+
99
+ # Retrieve data from all pages.
100
+ for i in range(2,101):
101
+ print(i)
102
+ url = f'https://www.goodreads.com/quotes?page={i}'
103
+ data_current_page = get_quotes_data(url)
104
+ if data_current_page is None:
105
+ continue
106
+ data = data + data_current_page
107
+
108
+ data_df = pd.DataFrame.from_dict(data)
109
+ for i, row in data_df.iterrows():
110
+ if row['tags'] is None:
111
+ data_df = data_df.drop(i)
112
+ # Produce the data in a JSON format.
113
+ data_df.to_json('C:/Users/Abir/Desktop/quotes.jsonl',orient="records", lines =True,force_ascii=False)
114
+ # Then I used the familiar process to push it to the Hugging Face hub.
115
+
116
+ ```
117
+ #### Annotations
118
+ Annotations are part of the initial data collection (see the script above).
119
+
120
+ # **VI-Additional Informations**
121
+ #### Dataset Curators
122
+ Abir ELTAIEF
123
+
124
+
125
+ #### Licensing Information
126
+ This work is licensed under a Creative Commons Attribution 4.0 International License (all software and libraries used for web scraping are made available under this Creative Commons Attribution license).
127
+
128
+ #### Contributions
129
+ Thanks to [@Abirate](https://huggingface.co/Abirate)
130
+ for adding this dataset.
quotes.jsonl ADDED
The diff for this file is too large to render. See raw diff