Guest User

Untitled

a guest
Mar 4th, 2024
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import csv
  2. from html import escape
  3. import urllib.request
  4. import io
  5. from zipfile import ZipFile
  6.  
  7. request = urllib.request.urlopen(
  8. "https://github.com/idavidrein/gpqa/archive/refs/heads/main.zip"
  9. )
  10. repo_zip = ZipFile(io.BytesIO(request.read()))
  11. dataset_zip = ZipFile(repo_zip.open("gpqa-main/dataset.zip"))
  12. dataset_file = dataset_zip.open("dataset/gpqa_main.csv", pwd=b"deserted-untie-orchid")
  13. css = """
  14. body{
  15. margin:40px auto;
  16. max-width:650px;
  17. line-height:1.6;
  18. font-size:18px;
  19. color:#444;
  20. padding:0 10px;
  21. word-wrap: break-word;
  22. }
  23. h1,h2,h3 {line-height:1.2}
  24. """
  25. print(f"<html><head><style type='text/css'>{css}</style><body><h1>GPQA Questions</h1>")
  26. for i, row in enumerate(csv.DictReader(io.TextIOWrapper(dataset_file, "utf-8"))):
  27. question = row["Question"]
  28. subdomain = row["Subdomain"]
  29. print(f"<h2>Question {i+1} {subdomain}</h2>")
  30. for paragraph in question.split("\n"):
  31. print(f"<p>{escape(paragraph)}</p>")
  32. print(f"<p><b>Answer:</b>{escape(row['Correct Answer'])}</p>")
  33. print("</body></html>")
Advertisement
Add Comment
Please, Sign In to add comment