File size: 953 Bytes
c54bb81
1ce200c
 
c54bb81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Template for custom function or Pydantic model."""
import csv
from pathlib import Path

def record_interestingness(titles: list[str], uninteresting: list[bool]) -> None:
    """Label the interestingness of the entries.

    Args:
        titles (list[str]): The titles of the entries to label.
        uninteresting (list[bool]): The list of booleans indicating whether the
        entry is uninteresting.
    """
    assert len(titles) == len(uninteresting)

    # Create result.csv if it doesn't exist
    result_file = Path("result.csv")
    file_exists = result_file.exists()

    with open(result_file, "a", newline="") as f:
        writer = csv.writer(f)

        # Write header if file is new
        if not file_exists:
            writer.writerow(["title", "uninteresting"])

        # Write results
        for title, is_uninteresting in zip(titles, uninteresting, strict=True):
            writer.writerow([title, int(is_uninteresting)])