Improve writing spellcheck to return fixed_text.
This commit is contained in:
@@ -249,15 +249,12 @@ def extract_existing_sections_from_body(my_dict, keys_to_extract):
|
||||
my_dict['sections']))
|
||||
|
||||
|
||||
def get_misspelled_pairs(text):
|
||||
message = ('From the given text, extract the misspelled words and put them in the json with the correct word that '
|
||||
'should be on the text instead. Sample JSON: '
|
||||
'{"misspelled_words":[{"misspelled": "piza", "correction": "pizza"}] \n The text: "' + text + '"')
|
||||
def get_fixed_text(text):
|
||||
message = ('Fix the errors in the given text and put it in a JSON. Sample JSON: {"fixed_text": "fixed test with no '
|
||||
'misspelling errors"}] \n The text: "' + text + '"')
|
||||
token_count = count_tokens(message)["n_tokens"]
|
||||
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count, ["misspelled_words"], 0.2)
|
||||
# Filter out items with the same value for misspelled and correction
|
||||
filtered_data = [item for item in response["misspelled_words"] if item['misspelled'] != item['correction']]
|
||||
return filtered_data
|
||||
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count, ["fixed_text"], 0.2)
|
||||
return response["fixed_text"]
|
||||
|
||||
def get_speaking_corrections(text):
|
||||
message = ('Given the provided transcription, identify and extract any inaccuracies, including incorrect words and '
|
||||
|
||||
Reference in New Issue
Block a user