Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/services/implementations/claim_reliabity_scoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def claim_reliabity_scoring(atomic_verdicts:list[str]) -> float:
"""
This function calculates the claim reliability scoring based on the atomic verdicts.
The scoring is calculated as the ratio of true verdicts to the total number of verdicts.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will edit the documentation of the function later as it is not yet precise.


:param atomic_verdicts: A list of values representing the atomic verdicts.
:return: A float value representing the claim reliability scoring.
"""
if not atomic_verdicts or len(atomic_verdicts) == 0:
raise ValueError("Atomic verdicts list is empty")
score=0.0
for verdict in atomic_verdicts:
if verdict.lower() == "true":
score += 1.0
elif verdict.lower() == "false":
score += -1.0
elif verdict.lower() == "unverifiable":
score += 0.0
else:
raise ValueError(f"Invalid verdict value: {verdict}. Expected 'true', 'false', or 'unverifiable'.")

return score / len(atomic_verdicts)