Skip to content

Commit

Permalink
dealing with blank statements and removing scape
Browse files Browse the repository at this point in the history
  • Loading branch information
JACProjec committed Aug 22, 2024
1 parent b357741 commit fc4d4db
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions perspective_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def catch_all_error_handler_middleware(request: Request, call_next):
"CURIOSITY_EXPERIMENTAL": 1 / 6,
"FEARMONGERING_EXPERIMENTAL": -1 / 3,
"GENERALIZATION_EXPERIMENTAL": -1 / 3,
"SCAPEGOATING_EXPERIMENTAL": -1 / 9,
# "SCAPEGOATING_EXPERIMENTAL": -1 / 9,
"MORAL_OUTRAGE_EXPERIMENTAL": -1 / 9,
"ALIENATION_EXPERIMENTAL": -1 / 9,
}
Expand All @@ -126,7 +126,7 @@ async def catch_all_error_handler_middleware(request: Request, call_next):
"CURIOSITY_EXPERIMENTAL": 1 / 6,
"FEARMONGERING_EXPERIMENTAL": -1 / 6,
"GENERALIZATION_EXPERIMENTAL": -1 / 6,
"SCAPEGOATING_EXPERIMENTAL": -1 / 18,
# "SCAPEGOATING_EXPERIMENTAL": -1 / 18,
"MORAL_OUTRAGE_EXPERIMENTAL": -1 / 18,
"ALIENATION_EXPERIMENTAL": -1 / 18,
"TOXICITY": -1 / 8,
Expand Down Expand Up @@ -167,6 +167,9 @@ async def score(self, attributes, statement, statement_id):
"languages": ["en"],
"requestedAttributes": {attr: {} for attr in attributes},
}

if not statement.strip():
return self.ScoredStatement(statement, [], statement_id, False)

logger.info(f"Sending request to Perspective API for statement_id: {statement_id}")
logger.debug(f"Request payload: {data}")
Expand Down

0 comments on commit fc4d4db

Please sign in to comment.