Spaces:
Runtime error
Runtime error
File size: 511 Bytes
94e5748 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
"""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))
|