Skip to content

Commit

Permalink
Update community_lm_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AakritiKinra authored Dec 13, 2024
1 parent 901d588 commit 756d990
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/community_lm/community_lm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,20 @@ def compute_group_stance_factscore(
print(f"Warning: Unknown party '{party}' in row: {row}")

# Function to evaluate sentiments
def evaluate_sentiments(responses, party_name):
def evaluate_sentiments(
responses: List,
party_name: str,
) -> float:
"""
Calculates sentiment for given responses and party.
Args:
responses (List): A list containing synthetic tweets for all politicians of a given party.
party_name (str): The party for which we calculate the sentiment.
Returns:
float: Group sentiment towards politicians of a given party.
"""
if not responses:
print(f"No responses found for party: {party_name.capitalize()}")
return None
Expand Down

0 comments on commit 756d990

Please sign in to comment.