Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
from bs4 import BeautifulSoup as bs | |
import wikipediaapi | |
import sys | |
import re | |
import pypandoc | |
def page_titles_of_category(cat_page): | |
""" | |
recursively | |
""" | |
titles = [] | |
for member in cat_page.categorymembers.values(): | |
if member.ns == wikipediaapi.Namespace.MAIN: | |
titles.append(member.title) | |
elif member.ns == wikipediaapi.Namespace.CATEGORY: | |
titles += page_titles_of_category(member) | |
return titles | |
def wikipedia(): | |
wiki = wikipediaapi.Wikipedia('en') | |
wiki_html = wikipediaapi.Wikipedia(language='en', | |
extract_format=wikipediaapi.ExtractFormat.HTML) | |
""" | |
init_categories = [ | |
#"Category:Mathematical_theorems", | |
"Category:Mathematical_proofs", | |
#"Category:Mathematical_examples", | |
#"Category:Mathematical_problems", | |
#"Category:Mathematical_terminology", | |
] | |
title_set = set() | |
for cat_name in init_categories: | |
print(cat_name + "...") | |
title_set = title_set.union(page_titles_of_category(wiki.page(cat_name))) | |
for title in title_set: | |
""" | |
p_html = wiki_html.page('Division by zero').text | |
pd_obj = pypandoc.convert_text(p_html, "latex", format="html") | |
print(pd_obj) | |
sys.exit() | |
if __name__=="__main__": | |
wikipedia() | |