Spaces:
Runtime error
Runtime error
"""Detcet chinese. | |
True if containing any of [一-﨩] | |
'\u4e00' <= char <= '\u9fff', False otherwise | |
""" | |
def detect_chinese(text): | |
"""Detcet chinese. | |
Args: | |
text: string | |
True if containing any of [一-﨩], False otherwise | |
'\u4e00' <= char <= '\u9fff', False otherwise | |
if punctuation needs to be considered: | |
from zhon.hanzi import punctuation | |
'\u4e00' <= char <= '\u9fff' or char in punctuation | |
""" | |
return any("\u4e00" <= char <= "\u9fff" for char in str(text)) | |