Skip to content

Commit

Permalink
feat: keep track of note scores
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed Jun 10, 2024
1 parent 5096914 commit 8370a7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions x_notes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def save_notes(
"shown",
"summary",
"ratings",
"score",
]
if k in note
}
Expand Down
6 changes: 4 additions & 2 deletions x_notes/ratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit 8370a7c

Please sign in to comment.