Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- from html import escape
- import urllib.request
- import io
- from zipfile import ZipFile
- request = urllib.request.urlopen(
- "https://github.com/idavidrein/gpqa/archive/refs/heads/main.zip"
- )
- repo_zip = ZipFile(io.BytesIO(request.read()))
- dataset_zip = ZipFile(repo_zip.open("gpqa-main/dataset.zip"))
- dataset_file = dataset_zip.open("dataset/gpqa_main.csv", pwd=b"deserted-untie-orchid")
- css = """
- body{
- margin:40px auto;
- max-width:650px;
- line-height:1.6;
- font-size:18px;
- color:#444;
- padding:0 10px;
- word-wrap: break-word;
- }
- h1,h2,h3 {line-height:1.2}
- """
- print(f"<html><head><style type='text/css'>{css}</style><body><h1>GPQA Questions</h1>")
- for i, row in enumerate(csv.DictReader(io.TextIOWrapper(dataset_file, "utf-8"))):
- question = row["Question"]
- subdomain = row["Subdomain"]
- print(f"<h2>Question {i+1} {subdomain}</h2>")
- for paragraph in question.split("\n"):
- print(f"<p>{escape(paragraph)}</p>")
- print(f"<p><b>Answer:</b>{escape(row['Correct Answer'])}</p>")
- print("</body></html>")
Advertisement
Add Comment
Please, Sign In to add comment