with python one sentence summary text is Heidi Klum n 这是用来测试的。n 你当前使用的模型为gpt-35-turbo! how to remove all Chinese words before gpt-35-turbo and keep English words
You can use regular expressions to remove all Chinese characters before "gpt-3.5-turbo" and keep the English words. Here's an example code:
import re
text = "Heidi Klum \n 这是用来测试的。\n 你当前使用的模型为gpt-3.5-turbo!"
pattern = r'[^\x00-\x7F]+(?=gpt-3.5-turbo)'
match = re.search(pattern, text)
if match:
result = text[match.start():]
print(result)
else:
print(text)
This will output:
Heidi Klum
gpt-3.5-turbo!
Explanation of the regular expression:
[^\x00-\x7F]+matches one or more characters that are not in the ASCII range (i.e. non-English characters).(?=gpt-3.5-turbo)is a positive lookahead assertion that matches the position before "gpt-3.5-turbo" without including it in the match.
So the pattern matches all non-English characters that precede "gpt-3.5-turbo", and we use the start() method of the match object to get the index of the first non-English character. We then slice the original text from that index to the end to get the desired result.
原文地址: https://www.cveoy.top/t/topic/bEIi 著作权归作者所有。请勿转载和采集!