Dmitry Chaplinsky commited on
Commit
beaaafa
1 Parent(s): dace661

Script to calculate stats, current stats in readme and a separate file

Browse files
Files changed (3) hide show
  1. README.md +118 -2
  2. bin/get_stats.py +55 -0
  3. every_prompt_stats.csv +111 -0
README.md CHANGED
@@ -26,14 +26,130 @@ You'll need to apply extra cleansing/evaluation of the instructions you've got b
26
 
27
  **Caveat emptor**: the format of the FAQs and HowTo's in the dataset might vary greatly. Account for that. To understand potential pitfalls, look at the jmespath expression at the `export_structured_data.py`.
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ## Recreating the results
30
  1. Clone the repo without the LFS files.
31
  2. Install requirements from `requirements.txt`.
32
  3. Install `pv` and `parallel`.
33
  4. Run `bin/get_seed_urls.sh` to filter urls of interest out of 1.6TB of compressed data. Don't worry about disk space. Worry about the traffic. That will take around 5h on decent connection.
34
  5. Run scrapy spider like this `scrapy crawl webdatacommons_org -s WEB_DATA_COMMONS=web_data_commons_urls_sample.txt -L INFO -o webdatacommons.jsonlines` with `WEB_DATA_COMMONS` pointing to the list of seed URLs from step 4. That might take up to a few weeks.
35
- 6. Run `python extract_relevant_structured_data.py --num-threads 12 webdatacommons.jsonlines relevant.jsonlines.bz2`. That's fast, probably around 30 minutes.
36
- 7. Run `python export_structured_data.py relevant.jsonlines.bz2 extruct_out.jsonlines.bz2` to obtain the final version of the dataset.
 
 
37
 
38
  ## Advices
39
  If you want to recreate the results:
 
26
 
27
  **Caveat emptor**: the format of the FAQs and HowTo's in the dataset might vary greatly. Account for that. To understand potential pitfalls, look at the jmespath expression at the `export_structured_data.py`.
28
 
29
+ ## Detailed stats (with breakdown by language and data type)
30
+ | language | FAQPage count | FAQPage text length | HowTo count | HowTo text length | items count | text length |
31
+ | --- | --- | --- | --- | --- | --- | --- |
32
+ | en | 592730 | 1186748927 | 29017 | 77135350 | 621747 | 1263884277 |
33
+ | de | 83184 | 213931486 | 3370 | 13905977 | 86554 | 227837463 |
34
+ | es | 63237 | 113906536 | 6466 | 30517773 | 69703 | 144424309 |
35
+ | fr | 65081 | 141638675 | 3672 | 21632272 | 68753 | 163270947 |
36
+ | ja | 55439 | 46231152 | 1402 | 1678468 | 56841 | 47909620 |
37
+ | ru | 41271 | 70947161 | 2403 | 12805308 | 43674 | 83752469 |
38
+ | nl | 34066 | 102719276 | 2007 | 11078079 | 36073 | 113797355 |
39
+ | it | 23076 | 43968063 | 2465 | 13696136 | 25541 | 57664199 |
40
+ | vi | 23115 | 38603954 | 720 | 3224051 | 23835 | 41828005 |
41
+ | zh | 22496 | 21111729 | 1112 | 1513344 | 23608 | 22625073 |
42
+ | pl | 19424 | 41446645 | 306 | 419787 | 19730 | 41866432 |
43
+ | fa | 17263 | 31294557 | 1819 | 1915117 | 19082 | 33209674 |
44
+ | tr | 13619 | 20040069 | 722 | 418695 | 14341 | 20458764 |
45
+ | und | 12256 | 1032156 | 322 | 8941 | 12578 | 1041097 |
46
+ | pt | 10784 | 26163387 | 1775 | 8295306 | 12559 | 34458693 |
47
+ | ro | 10536 | 16405628 | 75 | 89946 | 10611 | 16495574 |
48
+ | id | 8256 | 14353165 | 1871 | 13055561 | 10127 | 27408726 |
49
+ | ko | 8348 | 7624222 | 616 | 1533830 | 8964 | 9158052 |
50
+ | sv | 8007 | 15926376 | 390 | 638054 | 8397 | 16564430 |
51
+ | ar | 6950 | 10240266 | 1241 | 7517175 | 8191 | 17757441 |
52
+ | da | 7691 | 15277244 | 408 | 450176 | 8099 | 15727420 |
53
+ | cs | 7546 | 13201121 | 480 | 2471544 | 8026 | 15672665 |
54
+ | fi | 7767 | 14468764 | 199 | 170138 | 7966 | 14638902 |
55
+ | hi | 4517 | 4307716 | 683 | 4294129 | 5200 | 8601845 |
56
+ | hu | 4866 | 10639836 | 125 | 61118 | 4991 | 10700954 |
57
+ | el | 4600 | 10555382 | 103 | 55576 | 4703 | 10610958 |
58
+ | no | 4357 | 8426887 | 179 | 354796 | 4536 | 8781683 |
59
+ | uk | 4401 | 6925331 | 90 | 37285 | 4491 | 6962616 |
60
+ | iw | 4056 | 7723904 | 36 | 35305 | 4092 | 7759209 |
61
+ | bg | 3620 | 10154727 | 41 | 31268 | 3661 | 10185995 |
62
+ | sk | 2639 | 4394140 | 65 | 32527 | 2704 | 4426667 |
63
+ | th | 1877 | 3823867 | 613 | 3171583 | 2490 | 6995450 |
64
+ | mr | 2002 | 2274197 | 57 | 75906 | 2059 | 2350103 |
65
+ | mt | 1886 | 3761332 | 14 | 5443 | 1900 | 3766775 |
66
+ | cy | 1524 | 3171667 | 25 | 11641 | 1549 | 3183308 |
67
+ | bs | 1366 | 2031881 | 34 | 23298 | 1400 | 2055179 |
68
+ | et | 1299 | 1694117 | 5 | 2005 | 1304 | 1696122 |
69
+ | ms | 989 | 1927545 | 174 | 720492 | 1163 | 2648037 |
70
+ | ca | 1068 | 1614073 | 62 | 34072 | 1130 | 1648145 |
71
+ | lt | 1056 | 2272916 | 44 | 57169 | 1100 | 2330085 |
72
+ | ne | 966 | 771410 | 29 | 28569 | 995 | 799979 |
73
+ | hr | 796 | 1394174 | 15 | 10191 | 811 | 1404365 |
74
+ | fy | 743 | 633705 | 24 | 5823 | 767 | 639528 |
75
+ | lb | 703 | 1133527 | 18 | 3985 | 721 | 1137512 |
76
+ | gl | 628 | 1159618 | 34 | 9049 | 662 | 1168667 |
77
+ | mn | 644 | 1174921 | 11 | 3592 | 655 | 1178513 |
78
+ | la | 635 | 363380 | 13 | 2009 | 648 | 365389 |
79
+ | af | 577 | 444351 | 38 | 14403 | 615 | 458754 |
80
+ | sl | 451 | 1708497 | 50 | 50361 | 501 | 1758858 |
81
+ | ht | 455 | 223768 | 13 | 4406 | 468 | 228174 |
82
+ | lv | 317 | 1017694 | 32 | 31983 | 349 | 1049677 |
83
+ | gd | 273 | 295170 | 52 | 20374 | 325 | 315544 |
84
+ | sr | 287 | 367782 | 23 | 5177 | 310 | 372959 |
85
+ | co | 288 | 284629 | 12 | 3530 | 300 | 288159 |
86
+ | az | 268 | 273548 | 9 | 13011 | 277 | 286559 |
87
+ | fil | 210 | 165520 | 63 | 77100 | 273 | 242620 |
88
+ | jv | 244 | 153411 | 14 | 75932 | 258 | 229343 |
89
+ | sn | 239 | 175459 | 10 | 8890 | 249 | 184349 |
90
+ | bn | 190 | 301199 | 42 | 23451 | 232 | 324650 |
91
+ | ga | 198 | 263174 | 30 | 12905 | 228 | 276079 |
92
+ | mg | 201 | 53082 | 18 | 6141 | 219 | 59223 |
93
+ | hi-Latn | 194 | 250495 | 4 | 33091 | 198 | 283586 |
94
+ | hmn | 173 | 793850 | 16 | 5902 | 189 | 799752 |
95
+ | ka | 162 | 262305 | 8 | 3427 | 170 | 265732 |
96
+ | ig | 136 | 129243 | 10 | 2941 | 146 | 132184 |
97
+ | is | 139 | 236415 | 4 | 1277 | 143 | 237692 |
98
+ | ta | 129 | 155042 | 12 | 4079 | 141 | 159121 |
99
+ | kk | 102 | 152629 | 28 | 11885 | 130 | 164514 |
100
+ | eu | 118 | 130847 | 10 | 3522 | 128 | 134369 |
101
+ | eo | 121 | 69071 | 6 | 1885 | 127 | 70956 |
102
+ | ur | 93 | 259680 | 33 | 20499 | 126 | 280179 |
103
+ | so | 112 | 203877 | 6 | 2151 | 118 | 206028 |
104
+ | tg | 99 | 73437 | 16 | 5539 | 115 | 78976 |
105
+ | mk | 29 | 62730 | 84 | 391780 | 113 | 454510 |
106
+ | be | 100 | 88386 | 8 | 2193 | 108 | 90579 |
107
+ | sm | 100 | 1309239 | 8 | 2778 | 108 | 1312017 |
108
+ | uz | 93 | 116820 | 7 | 2987 | 100 | 119807 |
109
+ | zu | 84 | 136023 | 9 | 2744 | 93 | 138767 |
110
+ | haw | 81 | 59685 | 6 | 822 | 87 | 60507 |
111
+ | sq | 74 | 120593 | 12 | 6205 | 86 | 126798 |
112
+ | ny | 78 | 19403 | 6 | 2046 | 84 | 21449 |
113
+ | hy | 66 | 81675 | 10 | 3613 | 76 | 85288 |
114
+ | ha | 44 | 84457 | 19 | 68032 | 63 | 152489 |
115
+ | ru-Latn | 60 | 40266 | 1 | 61 | 61 | 40327 |
116
+ | el-Latn | 57 | 55657 | 4 | 342 | 61 | 55999 |
117
+ | zh-Latn | 58 | 27522 | 1 | 66 | 59 | 27588 |
118
+ | sd | 52 | 51341 | 7 | 2044 | 59 | 53385 |
119
+ | su | 50 | 17291 | 7 | 2358 | 57 | 19649 |
120
+ | ku | 47 | 23147 | 6 | 1998 | 53 | 25145 |
121
+ | bg-Latn | 48 | 15419 | 1 | 414 | 49 | 15833 |
122
+ | st | 25 | 65162 | 19 | 6346 | 44 | 71508 |
123
+ | yo | 37 | 103685 | 6 | 1790 | 43 | 105475 |
124
+ | ceb | 41 | 72950 | 1 | 107 | 42 | 73057 |
125
+ | ky | 30 | 23062 | 10 | 3679 | 40 | 26741 |
126
+ | te | 32 | 42803 | 7 | 2558 | 39 | 45361 |
127
+ | yi | 32 | 227267 | 7 | 2443 | 39 | 229710 |
128
+ | mi | 26 | 10132 | 11 | 2915 | 37 | 13047 |
129
+ | gu | 25 | 37857 | 10 | 4608 | 35 | 42465 |
130
+ | ja-Latn | 33 | 17560 | 2 | 88 | 35 | 17648 |
131
+ | sw | 26 | 17579 | 8 | 2726 | 34 | 20305 |
132
+ | xh | 28 | 46466 | 4 | 1409 | 32 | 47875 |
133
+ | ml | 16 | 33198 | 6 | 2721 | 22 | 35919 |
134
+ | ps | 10 | 7671 | 12 | 2642 | 22 | 10313 |
135
+ | am | 6 | 8017 | 8 | 1987 | 14 | 10004 |
136
+ | kn | 5 | 22197 | 9 | 3523 | 14 | 25720 |
137
+ | km | 7 | 8936 | 6 | 1879 | 13 | 10815 |
138
+ | pa | 10 | 26617 | 3 | 1100 | 13 | 27717 |
139
+ | si | 5 | 24000 | 5 | 1722 | 10 | 25722 |
140
+ | lo | 1 | 6204 | 7 | 2115 | 8 | 8319 |
141
+ | my | 3 | 14663 | 3 | 1179 | 6 | 15842 |
142
+
143
  ## Recreating the results
144
  1. Clone the repo without the LFS files.
145
  2. Install requirements from `requirements.txt`.
146
  3. Install `pv` and `parallel`.
147
  4. Run `bin/get_seed_urls.sh` to filter urls of interest out of 1.6TB of compressed data. Don't worry about disk space. Worry about the traffic. That will take around 5h on decent connection.
148
  5. Run scrapy spider like this `scrapy crawl webdatacommons_org -s WEB_DATA_COMMONS=web_data_commons_urls_sample.txt -L INFO -o webdatacommons.jsonlines` with `WEB_DATA_COMMONS` pointing to the list of seed URLs from step 4. That might take up to a few weeks.
149
+ 6. Run `python bin/extract_relevant_structured_data.py --num-threads 12 webdatacommons.jsonlines relevant.jsonlines.bz2`. That's fast, probably around 30 minutes.
150
+ 7. Run `python bin/export_structured_data.py relevant.jsonlines.bz2 extruct_out.jsonlines.bz2` to obtain the final version of the dataset.
151
+ 8. Optionally you can calculate the resulting stats like that: `python bin/get_stats.py extruct_out.jsonlines.bz2 every_prompt_stats.csv`
152
+
153
 
154
  ## Advices
155
  If you want to recreate the results:
bin/get_stats.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import csv
3
+ from collections import defaultdict
4
+ import json
5
+
6
+ from tqdm import tqdm
7
+ import smart_open
8
+
9
+ if __name__ == "__main__":
10
+ parser = argparse.ArgumentParser(
11
+ description="Calculate instructions stats for a large JSONL file."
12
+ )
13
+ parser.add_argument("input_file", help="path to input JSONL file")
14
+ parser.add_argument("output_file", help="path to output CSV file")
15
+
16
+ args = parser.parse_args()
17
+
18
+ stats = defaultdict(lambda: defaultdict(int))
19
+
20
+ with smart_open.open(args.input_file, "rt", encoding="utf-8") as reader:
21
+ for item in tqdm(map(json.loads, reader)):
22
+ stats[item["language"]][f"{item['@type']} count"] += 1
23
+ stats[item["language"]][f"{item['@type']} text length"] += item[
24
+ "text_length"
25
+ ]
26
+
27
+ stats[item["language"]]["items count"] += 1
28
+ stats[item["language"]]["text length"] += item["text_length"]
29
+
30
+ with smart_open.open(args.output_file, "wt", encoding="utf-8") as writer:
31
+ w = csv.DictWriter(
32
+ writer,
33
+ fieldnames=[
34
+ "language",
35
+ "FAQPage count",
36
+ "FAQPage text length",
37
+ "HowTo count",
38
+ "HowTo text length",
39
+ "items count",
40
+ "text length",
41
+ ],
42
+ )
43
+ w.writeheader()
44
+ for language, language_stats in stats.items():
45
+ w.writerow(
46
+ {
47
+ "language": language,
48
+ "FAQPage count": language_stats["FAQPage count"],
49
+ "FAQPage text length": language_stats["FAQPage text length"],
50
+ "HowTo count": language_stats["HowTo count"],
51
+ "HowTo text length": language_stats["HowTo text length"],
52
+ "items count": language_stats["items count"],
53
+ "text length": language_stats["text length"],
54
+ }
55
+ )
every_prompt_stats.csv ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "language","FAQPage count","FAQPage text length","HowTo count","HowTo text length","items count","text length"
2
+ "en",592730,1186748927,29017,77135350,621747,1263884277
3
+ "de",83184,213931486,3370,13905977,86554,227837463
4
+ "es",63237,113906536,6466,30517773,69703,144424309
5
+ "fr",65081,141638675,3672,21632272,68753,163270947
6
+ "ja",55439,46231152,1402,1678468,56841,47909620
7
+ "ru",41271,70947161,2403,12805308,43674,83752469
8
+ "nl",34066,102719276,2007,11078079,36073,113797355
9
+ "it",23076,43968063,2465,13696136,25541,57664199
10
+ "vi",23115,38603954,720,3224051,23835,41828005
11
+ "zh",22496,21111729,1112,1513344,23608,22625073
12
+ "pl",19424,41446645,306,419787,19730,41866432
13
+ "fa",17263,31294557,1819,1915117,19082,33209674
14
+ "tr",13619,20040069,722,418695,14341,20458764
15
+ "und",12256,1032156,322,8941,12578,1041097
16
+ "pt",10784,26163387,1775,8295306,12559,34458693
17
+ "ro",10536,16405628,75,89946,10611,16495574
18
+ "id",8256,14353165,1871,13055561,10127,27408726
19
+ "ko",8348,7624222,616,1533830,8964,9158052
20
+ "sv",8007,15926376,390,638054,8397,16564430
21
+ "ar",6950,10240266,1241,7517175,8191,17757441
22
+ "da",7691,15277244,408,450176,8099,15727420
23
+ "cs",7546,13201121,480,2471544,8026,15672665
24
+ "fi",7767,14468764,199,170138,7966,14638902
25
+ "hi",4517,4307716,683,4294129,5200,8601845
26
+ "hu",4866,10639836,125,61118,4991,10700954
27
+ "el",4600,10555382,103,55576,4703,10610958
28
+ "no",4357,8426887,179,354796,4536,8781683
29
+ "uk",4401,6925331,90,37285,4491,6962616
30
+ "iw",4056,7723904,36,35305,4092,7759209
31
+ "bg",3620,10154727,41,31268,3661,10185995
32
+ "sk",2639,4394140,65,32527,2704,4426667
33
+ "th",1877,3823867,613,3171583,2490,6995450
34
+ "mr",2002,2274197,57,75906,2059,2350103
35
+ "mt",1886,3761332,14,5443,1900,3766775
36
+ "cy",1524,3171667,25,11641,1549,3183308
37
+ "bs",1366,2031881,34,23298,1400,2055179
38
+ "et",1299,1694117,5,2005,1304,1696122
39
+ "ms",989,1927545,174,720492,1163,2648037
40
+ "ca",1068,1614073,62,34072,1130,1648145
41
+ "lt",1056,2272916,44,57169,1100,2330085
42
+ "ne",966,771410,29,28569,995,799979
43
+ "hr",796,1394174,15,10191,811,1404365
44
+ "fy",743,633705,24,5823,767,639528
45
+ "lb",703,1133527,18,3985,721,1137512
46
+ "gl",628,1159618,34,9049,662,1168667
47
+ "mn",644,1174921,11,3592,655,1178513
48
+ "la",635,363380,13,2009,648,365389
49
+ "af",577,444351,38,14403,615,458754
50
+ "sl",451,1708497,50,50361,501,1758858
51
+ "ht",455,223768,13,4406,468,228174
52
+ "lv",317,1017694,32,31983,349,1049677
53
+ "gd",273,295170,52,20374,325,315544
54
+ "sr",287,367782,23,5177,310,372959
55
+ "co",288,284629,12,3530,300,288159
56
+ "az",268,273548,9,13011,277,286559
57
+ "fil",210,165520,63,77100,273,242620
58
+ "jv",244,153411,14,75932,258,229343
59
+ "sn",239,175459,10,8890,249,184349
60
+ "bn",190,301199,42,23451,232,324650
61
+ "ga",198,263174,30,12905,228,276079
62
+ "mg",201,53082,18,6141,219,59223
63
+ "hi-Latn",194,250495,4,33091,198,283586
64
+ "hmn",173,793850,16,5902,189,799752
65
+ "ka",162,262305,8,3427,170,265732
66
+ "ig",136,129243,10,2941,146,132184
67
+ "is",139,236415,4,1277,143,237692
68
+ "ta",129,155042,12,4079,141,159121
69
+ "kk",102,152629,28,11885,130,164514
70
+ "eu",118,130847,10,3522,128,134369
71
+ "eo",121,69071,6,1885,127,70956
72
+ "ur",93,259680,33,20499,126,280179
73
+ "so",112,203877,6,2151,118,206028
74
+ "tg",99,73437,16,5539,115,78976
75
+ "mk",29,62730,84,391780,113,454510
76
+ "be",100,88386,8,2193,108,90579
77
+ "sm",100,1309239,8,2778,108,1312017
78
+ "uz",93,116820,7,2987,100,119807
79
+ "zu",84,136023,9,2744,93,138767
80
+ "haw",81,59685,6,822,87,60507
81
+ "sq",74,120593,12,6205,86,126798
82
+ "ny",78,19403,6,2046,84,21449
83
+ "hy",66,81675,10,3613,76,85288
84
+ "ha",44,84457,19,68032,63,152489
85
+ "ru-Latn",60,40266,1,61,61,40327
86
+ "el-Latn",57,55657,4,342,61,55999
87
+ "zh-Latn",58,27522,1,66,59,27588
88
+ "sd",52,51341,7,2044,59,53385
89
+ "su",50,17291,7,2358,57,19649
90
+ "ku",47,23147,6,1998,53,25145
91
+ "bg-Latn",48,15419,1,414,49,15833
92
+ "st",25,65162,19,6346,44,71508
93
+ "yo",37,103685,6,1790,43,105475
94
+ "ceb",41,72950,1,107,42,73057
95
+ "ky",30,23062,10,3679,40,26741
96
+ "te",32,42803,7,2558,39,45361
97
+ "yi",32,227267,7,2443,39,229710
98
+ "mi",26,10132,11,2915,37,13047
99
+ "gu",25,37857,10,4608,35,42465
100
+ "ja-Latn",33,17560,2,88,35,17648
101
+ "sw",26,17579,8,2726,34,20305
102
+ "xh",28,46466,4,1409,32,47875
103
+ "ml",16,33198,6,2721,22,35919
104
+ "ps",10,7671,12,2642,22,10313
105
+ "am",6,8017,8,1987,14,10004
106
+ "kn",5,22197,9,3523,14,25720
107
+ "km",7,8936,6,1879,13,10815
108
+ "pa",10,26617,3,1100,13,27717
109
+ "si",5,24000,5,1722,10,25722
110
+ "lo",1,6204,7,2115,8,8319
111
+ "my",3,14663,3,1179,6,15842