Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,38 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
import pandas as pd
|
| 3 |
-
from datasets import load_dataset
|
| 4 |
from docx import Document
|
| 5 |
-
from huggingface_hub import login
|
| 6 |
from pptx import Presentation
|
| 7 |
|
| 8 |
-
def get_questions():
|
| 9 |
-
token = os.getenv("HF_TOKEN")
|
| 10 |
-
|
| 11 |
-
login(token)
|
| 12 |
-
|
| 13 |
-
dataset = load_dataset("gaia-benchmark/GAIA", "2023_all", split="validation", trust_remote_code=True)
|
| 14 |
-
|
| 15 |
-
df = pd.DataFrame(dataset)
|
| 16 |
-
|
| 17 |
-
result_1=[]
|
| 18 |
-
result_2=[]
|
| 19 |
-
result_3=[]
|
| 20 |
-
|
| 21 |
-
for index, row in df.iterrows():
|
| 22 |
-
if row["Level"] == 1:
|
| 23 |
-
result_1.append([row["Question"], row["Level"], row["Final answer"], row["file_name"]])
|
| 24 |
-
if row["Level"] == 2:
|
| 25 |
-
result_2.append([row["Question"], row["Level"], row["Final answer"], row["file_name"]])
|
| 26 |
-
if row["Level"] == 3:
|
| 27 |
-
print(row["Question"])
|
| 28 |
-
print(row["Level"])
|
| 29 |
-
print(row["Final answer"])
|
| 30 |
-
print(row["file_name"])
|
| 31 |
-
result_3.append([row["Question"], row["Level"], row["Final answer"], row["file_name"]])
|
| 32 |
-
|
| 33 |
-
return result_1, result_2, result_3
|
| 34 |
-
|
| 35 |
-
"""
|
| 36 |
def get_questions(file_path, level):
|
| 37 |
df = pd.read_json(file_path, lines=True)
|
| 38 |
|
|
@@ -45,7 +15,6 @@ def get_questions(file_path, level):
|
|
| 45 |
result.append([row["Question"], row["Level"], row["Final answer"], row["file_name"]])
|
| 46 |
|
| 47 |
return result
|
| 48 |
-
"""
|
| 49 |
|
| 50 |
def is_ext(file_path, ext):
|
| 51 |
return os.path.splitext(file_path)[1].lower() == ext.lower()
|
|
|
|
| 1 |
import os
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
from docx import Document
|
|
|
|
| 4 |
from pptx import Presentation
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def get_questions(file_path, level):
|
| 7 |
df = pd.read_json(file_path, lines=True)
|
| 8 |
|
|
|
|
| 15 |
result.append([row["Question"], row["Level"], row["Final answer"], row["file_name"]])
|
| 16 |
|
| 17 |
return result
|
|
|
|
| 18 |
|
| 19 |
def is_ext(file_path, ext):
|
| 20 |
return os.path.splitext(file_path)[1].lower() == ext.lower()
|