eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

printdata.py 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/usr/bin/python
  2. # Copyright (C) 2012-2017 Reece H. Dunn
  3. #
  4. # This file is part of ucd-tools.
  5. #
  6. # ucd-tools is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # ucd-tools is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with ucd-tools. If not, see <http://www.gnu.org/licenses/>.
  18. import os
  19. import sys
  20. import ucd
  21. ucd_rootdir = sys.argv[1]
  22. csur_rootdir = 'data/csur'
  23. null = ucd.CodePoint('0000')
  24. unicode_chars = {}
  25. for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'):
  26. for codepoint in data['CodePoint']:
  27. unicode_chars[codepoint] = data
  28. for propfile in ['PropList', 'DerivedCoreProperties']:
  29. for data in ucd.parse_ucd_data(ucd_rootdir, propfile):
  30. for codepoint in data['Range']:
  31. try:
  32. unicode_chars[codepoint][data['Property']] = 1
  33. except KeyError:
  34. unicode_chars[codepoint] = {'CodePoint': codepoint}
  35. unicode_chars[codepoint][data['Property']] = 1
  36. for data in ucd.parse_ucd_data(ucd_rootdir, 'Scripts'):
  37. for codepoint in data['Range']:
  38. unicode_chars[codepoint]['Script'] = data['Script']
  39. if '--with-csur' in sys.argv:
  40. for csur in ['Klingon']:
  41. for data in ucd.parse_ucd_data('data/csur', csur):
  42. for codepoint in data['CodePoint']:
  43. unicode_chars[codepoint] = data
  44. def iscntrl(data):
  45. return 1 if data.get('Name', '') == '<control>' else 0
  46. def isdigit(data):
  47. return 1 if data['CodePoint'].char() in '0123456789' else 0
  48. def isxdigit(data):
  49. return 1 if data['CodePoint'].char() in '0123456789ABCDEFabcdef' else 0
  50. def isspace(data):
  51. if data.get('White_Space', 0):
  52. dt = data.get('DecompositionType', '')
  53. return 1 if dt == None or not dt.startswith('<noBreak>') else 0
  54. else:
  55. return 0
  56. def isblank(data): # word separator
  57. if data.get('GeneralCategory', 'Cn') == 'Zs' or data['CodePoint'].char() == '\t':
  58. dt = data.get('DecompositionType', '')
  59. return 1 if dt == None or not dt.startswith('<noBreak>') else 0
  60. else:
  61. return 0
  62. def ispunct(data):
  63. if data.get('GeneralCategory', 'Cn')[0] in 'P':
  64. return 1
  65. else:
  66. return 0
  67. def isprint(data):
  68. if data.get('GeneralCategory', 'Cn')[0] in 'LMNPSZ': # not in 'CI'
  69. return 1
  70. else:
  71. return 0
  72. def isgraph(data):
  73. if data.get('GeneralCategory', 'Cn')[0] in 'LMNPS': # not in 'CZI'
  74. return 1
  75. else:
  76. return 0
  77. def isalnum(data):
  78. if data.get('GeneralCategory', 'Cn')[0] in 'N':
  79. return 1
  80. else:
  81. return data.get('Alphabetic', 0)
  82. def isalpha(data):
  83. return data.get('Alphabetic', 0)
  84. def isupper(data):
  85. if data.get('Uppercase', 0):
  86. return 1
  87. elif data.get('LowerCase', null) != null: # Some Lt characters have lowercase forms.
  88. return 1
  89. else:
  90. return 0
  91. def islower(data):
  92. if data.get('Lowercase', 0):
  93. return 1
  94. elif data.get('UpperCase', null) != null:
  95. return 1
  96. else:
  97. return 0
  98. if __name__ == '__main__':
  99. for codepoint in ucd.CodeRange('000000..10FFFF'):
  100. try:
  101. data = unicode_chars[codepoint]
  102. except KeyError:
  103. data = {'CodePoint': codepoint}
  104. script = data.get('Script', 'Zzzz')
  105. title = data.get('TitleCase', codepoint)
  106. upper = data.get('UpperCase', codepoint)
  107. lower = data.get('LowerCase', codepoint)
  108. if title == null: title = codepoint
  109. if upper == null: upper = codepoint
  110. if lower == null: lower = codepoint
  111. print('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s' % (
  112. codepoint, script,
  113. data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
  114. upper, lower, title,
  115. isdigit(data), isxdigit(data),
  116. iscntrl(data), isspace(data), isblank(data), ispunct(data),
  117. isprint(data), isgraph(data), isalnum(data), isalpha(data), isupper(data), islower(data)))