def is_traditional(text): u""" Determine whether a text is simplified Chinese Returns True if written in Simplified, False otherwise. Note: This assumes the text is known to be one or the other. >>> is_traditional(u'Hello,這是麻煩啦') True """ return hanzidentifier.identify(text) is TRADITIONAL
def is_simplified(text): u""" Determine whether a text is simplified Chinese Returns True if written in Simplified, False otherwise. Note: This assumes the text is known to be one or the other. >>> is_simplified(u'这是麻烦啦') True """ return hanzidentifier.identify(text) is SIMPLIFIED
def identify(text): u""" Wrapper for hanzidentifier identify function Returns: None: if there are no recognizd Chinese characters. EITHER: if the test is inconclusive. TRADITIONAL: if the text is traditional. SIMPLIFIED: if the text is simplified. BOTH: the text has characters recognized as being solely traditional and other characters recognized as being solely simplified. NEITHER: (or None) It's neither simplified nor traditional Chinese text. >>> identify(u'这是麻烦啦') is SIMPLIFIED True >>> identify(u'這是麻煩啦') is TRADITIONAL True >>> identify(u'这是麻烦啦! 這是麻煩啦') is BOTH True >>> identify(u'This is so mafan.') is NEITHER True """ return hanzidentifier.identify(text)