我会使用正则表达式。这个小脚本搜索带有连字符的单词并将连字符替换为空。
import re
def replaceHyphenated(s):
matchList = re.findall(r"\w+-\w+",s) # find combination of word-word
sOut = s
for m in matchList:
new = m.replace("-","")
sOut = sOut.replace(m,new)
return sOut
if __name__ == "__main__":
s = """After the symposium, the Foundation and the FCF steering team continued their work and created the Func-tional Check Flight Compendium. This compendium contains information that can be used to reduce the risk of functional check flights. The information contained in the guidance document is generic, and may need to be adjusted to apply to your specific aircraft. If there are questions on any of the information in the compendi-um, contact your manufacturer for further guidance."""
print(replaceHyphenated(s))
输出将是:
研讨会结束后,基金会和 FCF 指导团队继续他们的工作,并创建了功能检查飞行纲要。本纲要包含可用于降低功能检查飞行风险的信息。指南文件中包含的信息是通用的,可能需要进行调整以适用于您的特定飞机。如果对纲要中的任何信息有疑问,请联系您的制造商以获得进一步的指导。
如果你不习惯 RegExp,我推荐这个网站:
https ://regex101.com/