From fc4d4dbd5a59e33028e03d976647a20ecb29f42f Mon Sep 17 00:00:00 2001 From: JACProjec <157226629+JACProjec@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:30:35 +0100 Subject: [PATCH] dealing with blank statements and removing scape --- perspective_ranker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/perspective_ranker.py b/perspective_ranker.py index 1adc1c0..6d479a2 100644 --- a/perspective_ranker.py +++ b/perspective_ranker.py @@ -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, } @@ -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, @@ -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}")