diff --git a/annotators/speech_function_classifier/server.py b/annotators/speech_function_classifier/server.py index f16470d8d8..5721e9e42d 100644 --- a/annotators/speech_function_classifier/server.py +++ b/annotators/speech_function_classifier/server.py @@ -36,13 +36,13 @@ def handler(payload: List[Dict]): phrases = [p["prev_phrase"]] + p["phrase"] authors = ["John"] + ["Doe"] * phrase_len response = [p["prev_speech_function"]] - logger.info(f'PREV_SF:{response}') + logger.info(f"PREV_SF:{response}") for phr, prev_phr, auth, prev_auth in zip(phrases[1:], phrases[:-1], authors[1:], authors[:-1]): - speech_f = get_speech_function(phr, prev_phr,response[-1], auth, prev_auth) + speech_f = get_speech_function(phr, prev_phr, response[-1], auth, prev_auth) response.append(speech_f) responses[i] = response[1:] - logger.info(f'RESPONSE:{response}') - + logger.info(f"RESPONSE:{response}") + except Exception as e: sentry_sdk.capture_exception(e) logger.exception(e) @@ -58,11 +58,7 @@ def answer(): payloads = [] for phr, prev_phr, prev_speech_func in zip_longest(phrases, prev_phrases, prev_speech_funcs): payloads.append( - { - "phrase": sent_tokenize(phr), - "prev_phrase": prev_phr, - "prev_speech_function": prev_speech_func - } + {"phrase": sent_tokenize(phr), "prev_phrase": prev_phr, "prev_speech_function": prev_speech_func} ) responses = handler(payloads) total_time = time.time() - st_time @@ -81,11 +77,7 @@ def annotation(): payloads = [] for phr, prev_phr, prev_speech_func in zip_longest(phrases, prev_phrases, prev_speech_funcs): payloads.append( - { - "phrase": sent_tokenize(phr), - "prev_phrase": prev_phr, - "prev_speech_function": prev_speech_func - } + {"phrase": sent_tokenize(phr), "prev_phrase": prev_phr, "prev_speech_function": prev_speech_func} ) responses = handler(payloads) total_time = time.time() - st_time diff --git a/annotators/speech_function_predictor/model.py b/annotators/speech_function_predictor/model.py index 4a684e753d..6f8fe26aea 100644 --- a/annotators/speech_function_predictor/model.py +++ b/annotators/speech_function_predictor/model.py @@ -1,14 +1,12 @@ import json - def init_model(): - with open('sf_pairs.json', 'r') as json_file: + with open("sf_pairs.json", "r") as json_file: lines = json_file.readlines() - prev_sfs = [json.loads(line)['prev_sf'] for line in lines] - current_sfs = [json.loads(line)['current_sf'] for line in lines] - + prev_sfs = [json.loads(line)["prev_sf"] for line in lines] + current_sfs = [json.loads(line)["current_sf"] for line in lines] class_dict = {} label_to_name = [] diff --git a/annotators/speech_function_predictor/test_server.py b/annotators/speech_function_predictor/test_server.py index aa7df8a6e8..1e311090aa 100644 --- a/annotators/speech_function_predictor/test_server.py +++ b/annotators/speech_function_predictor/test_server.py @@ -23,5 +23,6 @@ def run_test(): print("Success") + if __name__ == "__main__": run_test()