Is it possible to write a python code that detects Crutch Words in a text file and…
- User
Is it possible to write a python code that detects Crutch Words in a text file and highlights them by placing a "[{(CRUTCH)}]" suffix before them in an output file?
- Assistant
Yes, it is possible to write a Python code that detects "Crutch Words" in a text file and highlights them by placing a "[{(CRUTCH)}]" suffix before them in an output file. Here's an example code that accomplishes this task:
def detect_crutch_words(file_path): crutch_words = ["like", "um", "uh", "you know"] # Example list of crutch words output = [] with open(file_path, 'r') as file: for line in file: words = line.split() for word in words: if word.lower() in crutch_words: word = "[{(CRUTCH)}]" + word output.append(word) return ' '.join(output) input_file = 'input.txt' # Specify the path to your input file output_file = 'output.txt' # Specify the path to your output file result = detect_crutch_words(input_file) with open(output_file, 'w') as file: file.write(result)In this code, the function reads each line from the input file and splits it into words. It then checks if each word matches any of the crutch words in the list (you can modify this list to include the specific crutch words you want to detect). If a crutch word is found, it prefixes the word with "[{(CRUTCH)}]". The modified text is stored in the list.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.