Spaces:
Sleeping
Sleeping
Create utils/utils.py
Browse files- utils/utils.py +14 -0
utils/utils.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
def load_config():
|
| 4 |
+
with open("config.json", "r") as f:
|
| 5 |
+
return json.load(f)
|
| 6 |
+
|
| 7 |
+
def load_data(data_path):
|
| 8 |
+
with open(data_path, "r") as f:
|
| 9 |
+
return [line.strip() for line in f.readlines()]
|
| 10 |
+
|
| 11 |
+
def save_results(results, output_path):
|
| 12 |
+
with open(output_path, "w") as f:
|
| 13 |
+
for result in results:
|
| 14 |
+
f.write(str(result) + "\n")
|