diff --git a/x_notes/helpers.py b/x_notes/helpers.py index f2761c92..987b47b6 100644 --- a/x_notes/helpers.py +++ b/x_notes/helpers.py @@ -68,6 +68,7 @@ def save_notes( "shown", "summary", "ratings", + "score", ] if k in note } diff --git a/x_notes/ratings.py b/x_notes/ratings.py index 988b6c44..c6e411e6 100644 --- a/x_notes/ratings.py +++ b/x_notes/ratings.py @@ -3,12 +3,13 @@ from .helpers import load_notes, save_notes from .tsv import get_generator -# helpfulness_lookup = {"HELPFUL": 0, "SOMEWHAT_HELPFUL": 1, "NOT_HELPFUL": 2} +helpfulness_lookup = {"HELPFUL": 2, "SOMEWHAT_HELPFUL": 1, "NOT_HELPFUL": -2} def add_ratings(notes: dict[str, dict[str, Any]]) -> None: for note in notes.values(): del note["ratings"] + del note["score"] index = 0 while True: @@ -19,10 +20,11 @@ def add_ratings(notes: dict[str, dict[str, Any]]) -> None: for row in gen: if row["noteId"] in notes: note = notes[row["noteId"]] - # rating = helpfulness_lookup[row["helpfulnessLevel"]] if "ratings" not in note: note["ratings"] = 0 + note["score"] = 0 note["ratings"] += 1 + note["score"] += helpfulness_lookup[row["helpfulnessLevel"]] index += 1 save_notes(notes)