<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Analysis of Unicode Character Names
Character data from Python unicodedata module
Step1:  Character data from UnicodeData.txt
Step2:  Difference between names from unicodedata module and UnicodeData.txt
Note
<ASSISTANT_TASK:>
Python Code:
import sys
import unicodedata
sys.maxunicode
unicodedata.unidata_version
def python_named_chars():
    for code in range(sys.maxunicode):
        char = chr(code)
        try:
            yield char, unicodedata.name(char)
        except ValueError: # no such name
            continue
l_py = list(python_named_chars())
len(l_py)
l_py[0]
l_py[:5], l_py[-5:]
set_py = {name for _, name in l_py}
import collections
words = collections.Counter()
for _, name in l_py:
    parts = name.replace('-', ' ').split()
    words.update(parts)
    
len(words)
for word, count in words.most_common(10):
    print(f'{count:6d} {word}')
mc = [(w, c) for w, c in words.most_common() if c > 1]
len(mc)
mc[len(mc)//100]
Explanation: Analysis of Unicode Character Names
Character data from Python unicodedata module
End of explanation
len(list(open('UnicodeData.txt')))
import ucd  # local module
l_ucd = list(ucd.parser())
len(l_ucd)
l_ucd[:5], l_ucd[-5:]
set_ucd = {rec.name for rec in l_ucd}
Explanation: Character data from UnicodeData.txt
End of explanation
set_py > set_ucd
set_ucd > set_py
ucd_only = sorted(set_ucd - set_py)
len(ucd_only)
ucd_only[:7], ucd_only[-7:]
py_only = sorted(set_py - set_ucd)
len(py_only)
py_only[:7], py_only[-7:]
import collections
words = collections.Counter()
for name in py_only:
    if 'CJK UNIFIED IDEOGRAPH' in name:
        continue
    parts = name.replace('-', ' ').split()
    words.update(parts)
    
len(words)
for word, count in words.most_common(10):
    print(f'{count:6d} {word}')
words = collections.Counter()
for name in sorted(set_ucd):
    parts = name.replace('-', ' ').split()
    words.update(parts)
    
len(words)
for word, count in words.most_common(100):
    print(f'{count:6d} {word}')
max(words, key=len)
singles = sorted((count, word) for word, count in words.items() if len(word)==1)
len(singles)
for count, word in reversed(singles):
    print(f'{count:6d} {word}')    
unique = sorted(word for word, count in words.items() if count==1)
len(unique)
unique[:50], unique[-50:]
Explanation: Difference between names from unicodedata module and UnicodeData.txt
Note: UnicodeData.txt does not contain algorthmically derived names such as 'CJK UNIFIED IDEOGRAPH-20004'
End of explanation
<END_TASK>