Abirate commited on
Commit
f76e410
1 Parent(s): 3364976

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -0
README.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dataset Card for English quotes
2
+ #### Dataset Summary
3
+ english_quotes is a dataset of English quotes 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.
4
+
5
+ #### Supported Tasks and Leaderboards
6
+ - 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.
7
+ - 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).
8
+
9
+ #### Languages
10
+ The texts in the dataset are in English (en).
11
+
12
+ # Dataset Structure
13
+ #### Data Instances
14
+ A JSON-formatted example of a typical instance in the dataset:
15
+ ```python
16
+ {'author': 'Ralph Waldo Emerson',
17
+ 'quote': '“To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.”',
18
+ 'tags': ['accomplishment', 'be-yourself', 'conformity', 'individuality']}
19
+ ```
20
+ #### Data Fields
21
+ - **author** : The author of the quote.
22
+ - **quote** : The text of the quote.
23
+ - **tags**: The tags could be characterized as topics around the quote.
24
+
25
+ #### Data Splits
26
+ 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.
27
+
28
+ # Dataset Creation
29
+ #### Curation Rationale
30
+ 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.
31
+
32
+ #### Source Data
33
+ The source of Data is [goodreads](https://www.goodreads.com/?ref=nav_home) site: from [goodreads quotes](https://www.goodreads.com/quotes)
34
+
35
+ #### Initial Data Collection and Normalization
36
+
37
+ The data collection process is web scraping using BeautifulSoup and Requests libraries.
38
+ 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.
39
+
40
+ #### Who are the source Data producers ?
41
+ The data is machine-generated (using web scraping) and subjected to human additional treatment.
42
+
43
+ below, I provide the script I created to scrape the data (as well as my additional treatment):
44
+ ```python
45
+ import requests
46
+ from bs4 import BeautifulSoup
47
+ import pandas as pd
48
+ import json
49
+ from collections import OrderedDict
50
+
51
+ page = requests.get('https://www.goodreads.com/quotes')
52
+ if page.status_code == 200:
53
+ pageParsed = BeautifulSoup(page.content, 'html5lib')
54
+
55
+ # Define a function that retrieves information about each HTML quote code in a dictionary form.
56
+ def extract_data_quote(quote_html):
57
+ quote = quote_html.find('div',{'class':'quoteText'}).get_text().strip().split('\n')[0]
58
+ author = quote_html.find('span',{'class':'authorOrTitle'}).get_text().strip()
59
+ if quote_html.find('div',{'class':'greyText smallText left'}) is not None:
60
+ tags_list = [tag.get_text() for tag in quote_html.find('div',{'class':'greyText smallText left'}).find_all('a')]
61
+ tags = list(OrderedDict.fromkeys(tags_list))
62
+ if 'attributed-no-source' in tags:
63
+ tags.remove('attributed-no-source')
64
+ else:
65
+ tags = None
66
+ data = {'quote':quote, 'author':author, 'tags':tags}
67
+ return data
68
+
69
+ # Define a function that retrieves all the quotes on a single page.
70
+ def get_quotes_data(page_url):
71
+ page = requests.get(page_url)
72
+ if page.status_code == 200:
73
+ pageParsed = BeautifulSoup(page.content, 'html5lib')
74
+ quotes_html_page = pageParsed.find_all('div',{'class':'quoteDetails'})
75
+ return [extract_data_quote(quote_html) for quote_html in quotes_html_page]
76
+
77
+ # Retrieve data from the first page.
78
+ data = get_quotes_data('https://www.goodreads.com/quotes')
79
+
80
+ # Retrieve data from all pages.
81
+ for i in range(2,101):
82
+ print(i)
83
+ url = f'https://www.goodreads.com/quotes?page={i}'
84
+ data_current_page = get_quotes_data(url)
85
+ if data_current_page is None:
86
+ continue
87
+ data = data + data_current_page
88
+
89
+ data_df = pd.DataFrame.from_dict(data)
90
+ for i, row in data_df.iterrows():
91
+ if row['tags'] is None:
92
+ data_df = data_df.drop(i)
93
+ # Produce the data in a JSON format.
94
+ data_df.to_json('C:/Users/Abir/Desktop/quotes.jsonl',orient="records", lines =True,force_ascii=False)
95
+ # Then I used the familiar process to push it to the Hugging Face hub.
96
+
97
+ ```
98
+ #### Annotations
99
+ Annotations are part of the initial data collection (see the script above).
100
+
101
+ # Additional Information
102
+ #### Dataset Curators
103
+ Abir ELTAIEF :
104
+ https://tn.linkedin.com/in/abir-eltaief-pmp%C2%AE-469048115
105
+
106
+ #### Licensing Information
107
+ 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).
108
+
109
+ #### Contributions
110
+ Thanks to @Abirate for adding this dataset.