with open('/usr/share/dict/words') as f:
words = set(word.lower() for word in f.read().split()
# Really short words aren't much of an indication
if len(word) > 3)
def is_english(text):
return bool(words.intersection(text.lower().split()))
# or
return any(word in words for word in text.lower().split())
print(is_english('usfdbg dsuyfbg cat'))
print(is_english('Science & Literature'))
相关问题 更多 >
编程相关推荐