Spaces:
No application file
No application file
Update record_interestingness.py
Browse files
tools/record_interestingness.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Template for custom function or Pydantic model."""
|
| 2 |
+
|
| 3 |
+
def record_interestingness(titles: list[str], uninteresting: list[bool]) -> None:
|
| 4 |
+
"""Label the interestingness of the entries.
|
| 5 |
+
|
| 6 |
+
Args:
|
| 7 |
+
titles (list[str]): The titles of the entries to label.
|
| 8 |
+
uninteresting (list[bool]): The list of booleans indicating whether the
|
| 9 |
+
entry is uninteresting.
|
| 10 |
+
"""
|
| 11 |
+
assert len(titles) == len(uninteresting)
|
| 12 |
+
|
| 13 |
+
# Create result.csv if it doesn't exist
|
| 14 |
+
result_file = Path("result.csv")
|
| 15 |
+
file_exists = result_file.exists()
|
| 16 |
+
|
| 17 |
+
with open(result_file, "a", newline="") as f:
|
| 18 |
+
writer = csv.writer(f)
|
| 19 |
+
|
| 20 |
+
# Write header if file is new
|
| 21 |
+
if not file_exists:
|
| 22 |
+
writer.writerow(["title", "uninteresting"])
|
| 23 |
+
|
| 24 |
+
# Write results
|
| 25 |
+
for title, is_uninteresting in zip(titles, uninteresting, strict=True):
|
| 26 |
+
writer.writerow([title, int(is_uninteresting)])
|