Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
zhangir-azerbayev commited on
Commit
811340b
1 Parent(s): c0ecdaa

added proofwiki

Browse files
fetch_books_and_formal.py CHANGED
@@ -13,9 +13,6 @@ from tqdm import tqdm
13
 
14
  import base64
15
 
16
- PROOFWIKI_URL = (
17
- "https://zenodo.org/record/4902289/files/naturalproofs_proofwiki.json?download=1"
18
- )
19
 
20
  def check_encoding(path):
21
  for f in os.listdir(path):
@@ -361,58 +358,6 @@ def afp(testing=False):
361
 
362
  _delete_files_except_pattern(save_dir, r".*\.thy|.*\.tex")
363
 
364
-
365
- def naturalproofs_proofwiki(testing=False):
366
- save_dir = "wikis/proofwiki"
367
- Path(save_dir).mkdir(parents=True, exist_ok=True)
368
-
369
- if testing:
370
- with open("naturalproofs/proofwiki.json") as f:
371
- struct = json.load(f)
372
- else:
373
- print("DOWNLOADING PROOFWIKI")
374
- resp = _download_with_progress_bar(PROOFWIKI_URL)
375
- struct = json.loads(resp.decode("utf-8"))
376
- print("DONE DOWNLOADING PROOFWIKI")
377
-
378
- for thm in struct["dataset"]["theorems"]:
379
- if thm["contents"]:
380
- thm_string = "\\section{" + thm["label"] + "}\n"
381
- thm_string += (
382
- "Tags: " + ", ".join(thm["categories"]).replace("/", ": ") + "\n\n"
383
- )
384
-
385
- thm_string += (
386
- "\\begin{theorem}\n"
387
- + "\n".join(thm["contents"])
388
- + "\n\\end{theorem}\n\n"
389
- )
390
-
391
- for proof in thm["proofs"]:
392
- thm_string += (
393
- "\\begin{proof}\n"
394
- + "\n".join(proof["contents"])
395
- + "\n\\end{proof}\n\n"
396
- )
397
-
398
- with open(os.path.join(save_dir, str(thm["id"]) + ".txt"), "w") as f:
399
- f.write(thm_string)
400
-
401
- defn_string = ""
402
- for defn in struct["dataset"]["definitions"]:
403
- if defn["contents"]:
404
- defn_string += (
405
- "\\begin{definition}["
406
- + defn["label"]
407
- + "]\n"
408
- + "\n".join(defn["contents"])
409
- + "\n\\end{definition}\n\n"
410
- )
411
-
412
- with open(os.path.join(save_dir, "defs.txt"), "w") as f:
413
- f.write(defn_string)
414
-
415
-
416
  def mizar(creds):
417
  save_dir = "formal/mizar"
418
  Path(save_dir).mkdir(parents=True, exist_ok=True)
 
13
 
14
  import base64
15
 
 
 
 
16
 
17
  def check_encoding(path):
18
  for f in os.listdir(path):
 
358
 
359
  _delete_files_except_pattern(save_dir, r".*\.thy|.*\.tex")
360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  def mizar(creds):
362
  save_dir = "formal/mizar"
363
  Path(save_dir).mkdir(parents=True, exist_ok=True)
fetch_wiki.py CHANGED
@@ -1,8 +1,13 @@
1
  from bs4 import BeautifulSoup as bs
 
2
  import wikipediaapi
3
  import sys
4
  import re
5
  import pypandoc
 
 
 
 
6
 
7
  def page_titles_of_category(cat_page):
8
  """
@@ -17,10 +22,8 @@ def page_titles_of_category(cat_page):
17
  return titles
18
 
19
  def wikipedia():
20
- wiki = wikipediaapi.Wikipedia('en')
21
- wiki_html = wikipediaapi.Wikipedia(language='en',
22
- extract_format=wikipediaapi.ExtractFormat.HTML)
23
-
24
  """
25
  init_categories = [
26
  #"Category:Mathematical_theorems",
@@ -35,14 +38,65 @@ def wikipedia():
35
  print(cat_name + "...")
36
  title_set = title_set.union(page_titles_of_category(wiki.page(cat_name)))
37
 
38
- for title in title_set:
39
- """
40
 
41
- p_html = wiki_html.page('Division by zero').text
 
 
 
 
 
42
 
43
- pd_obj = pypandoc.convert_text(p_html, "latex", format="html")
44
- print(pd_obj)
45
- sys.exit()
46
- if __name__=="__main__":
47
- wikipedia()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from bs4 import BeautifulSoup as bs
2
+ import os
3
  import wikipediaapi
4
  import sys
5
  import re
6
  import pypandoc
7
+ import json
8
+ from pathlib import Path
9
+ from fetch_books_and_formal import _download_with_progress_bar
10
+ from fetch_mathoverflow import batch_loader
11
 
12
  def page_titles_of_category(cat_page):
13
  """
 
22
  return titles
23
 
24
  def wikipedia():
25
+ """
26
+ this doesnt work dont run it
 
 
27
  """
28
  init_categories = [
29
  #"Category:Mathematical_theorems",
 
38
  print(cat_name + "...")
39
  title_set = title_set.union(page_titles_of_category(wiki.page(cat_name)))
40
 
 
 
41
 
42
+ PROOFWIKI_URL = (
43
+ "https://zenodo.org/record/4902289/files/naturalproofs_proofwiki.json?download=1"
44
+ )
45
+ def proofwiki(testing=False):
46
+ save_dir = "wiki/proofwiki"
47
+ Path(save_dir).mkdir(parents=True, exist_ok=True)
48
 
49
+ if testing:
50
+ with open("naturalproofs/proofwiki.json") as f:
51
+ struct = json.load(f)
52
+ else:
53
+ print("DOWNLOADING PROOFWIKI")
54
+ resp = _download_with_progress_bar(PROOFWIKI_URL)
55
+ struct = json.loads(resp.decode("utf-8"))
56
+ print("DONE DOWNLOADING PROOFWIKI")
57
+
58
+ batches = batch_loader(struct["dataset"]["theorems"], 500)
59
+ for i, batch in enumerate(batches):
60
+ thms_list = []
61
+ for thm in batch:
62
+ if thm["contents"]:
63
+ thm_string = "\\section{" + thm["label"] + "}\n"
64
+ thm_string += (
65
+ "Tags: " + ", ".join(thm["categories"]).replace("/", ": ") + "\n\n"
66
+ )
67
+
68
+ thm_string += (
69
+ "\\begin{theorem}\n"
70
+ + "\n".join(thm["contents"])
71
+ + "\n\\end{theorem}\n\n"
72
+ )
73
 
74
+ for proof in thm["proofs"]:
75
+ thm_string += (
76
+ "\\begin{proof}\n"
77
+ + "\n".join(proof["contents"])
78
+ + "\n\\end{proof}\n\n"
79
+ )
80
+
81
+ thms_list.append(thm_string.strip())
82
+
83
+ with open(os.path.join(save_dir, f"shard_{i}.txt"), "w") as f:
84
+ f.write("<|endoftext|>\n".join(thms_list))
85
+
86
+ defn_strings = []
87
+ for defn in struct["dataset"]["definitions"]:
88
+ if defn["contents"]:
89
+ defn_strings.append((
90
+ "\\begin{definition}["
91
+ + defn["label"]
92
+ + "]\n"
93
+ + "\n".join(defn["contents"])
94
+ + "\n\\end{definition}").strip()
95
+ )
96
+
97
+ with open(os.path.join(save_dir, "defs.txt"), "w") as f:
98
+ f.write("<|endoftext|>\n".join(defn_strings))
99
+
100
+ if __name__=="__main__":
101
+ #wikipedia()
102
+ proofwiki()
wiki/proofwiki/defs.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_0.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_1.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_10.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_11.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_12.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_13.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_14.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_15.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_16.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_17.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_18.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_19.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_2.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_20.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_21.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_22.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_23.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_24.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_25.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_26.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_27.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_28.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_29.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_3.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_30.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_31.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_32.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_33.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_34.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_35.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_36.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_37.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_38.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_39.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_4.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_5.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_6.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_7.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_8.txt ADDED
The diff for this file is too large to render. See raw diff
 
wiki/proofwiki/shard_9.txt ADDED
The diff for this file is too large to render. See raw diff