Datasets:
Commit
·
5dedc64
1
Parent(s):
f96dd69
Brrrr
Browse files- source/create_dataset.py +5 -0
source/create_dataset.py
CHANGED
@@ -8,6 +8,7 @@ import random
|
|
8 |
lang = "de"
|
9 |
n = 1100
|
10 |
|
|
|
11 |
def cleandata():
|
12 |
input_file = f'data_{lang}.csv'
|
13 |
output_file = f'{lang}-wikihow-qa-dataset-1k.csv'
|
@@ -32,11 +33,14 @@ def cleandata():
|
|
32 |
print(f"Duplicate row found, url: {url}")
|
33 |
print("Done!")
|
34 |
|
|
|
35 |
def getrandom():
|
36 |
how_to = RandomHowTo(lang)
|
37 |
wkhowto_url = how_to.url
|
38 |
|
39 |
theme = unquote(how_to.title.encode('utf-8'))
|
|
|
|
|
40 |
templates = [
|
41 |
"Wie mache ich {theme}?",
|
42 |
"Schreibe wie ich folgendes tun kann: {theme}"
|
@@ -46,6 +50,7 @@ def getrandom():
|
|
46 |
wkhowto_a = how_to.print(extended=True)
|
47 |
return wkhowto_q, wkhowto_a, wkhowto_url
|
48 |
|
|
|
49 |
with open(f'data_{lang}.csv', mode='w', newline='') as file:
|
50 |
writer = csv.writer(file)
|
51 |
writer.writerow(['INSTRUCTION', 'RESPONSE', 'SOURCE', 'URL'])
|
|
|
8 |
lang = "de"
|
9 |
n = 1100
|
10 |
|
11 |
+
# removing duplicates
|
12 |
def cleandata():
|
13 |
input_file = f'data_{lang}.csv'
|
14 |
output_file = f'{lang}-wikihow-qa-dataset-1k.csv'
|
|
|
33 |
print(f"Duplicate row found, url: {url}")
|
34 |
print("Done!")
|
35 |
|
36 |
+
# getting a random article
|
37 |
def getrandom():
|
38 |
how_to = RandomHowTo(lang)
|
39 |
wkhowto_url = how_to.url
|
40 |
|
41 |
theme = unquote(how_to.title.encode('utf-8'))
|
42 |
+
|
43 |
+
# randomization
|
44 |
templates = [
|
45 |
"Wie mache ich {theme}?",
|
46 |
"Schreibe wie ich folgendes tun kann: {theme}"
|
|
|
50 |
wkhowto_a = how_to.print(extended=True)
|
51 |
return wkhowto_q, wkhowto_a, wkhowto_url
|
52 |
|
53 |
+
# saving .csv
|
54 |
with open(f'data_{lang}.csv', mode='w', newline='') as file:
|
55 |
writer = csv.writer(file)
|
56 |
writer.writerow(['INSTRUCTION', 'RESPONSE', 'SOURCE', 'URL'])
|