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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 data in ucd.parse_ucd_data(ucd_rootdir, 'PropList'):
  29. if data['Property'] in ['White_Space']:
  30. for codepoint in data['Range']:
  31. unicode_chars[codepoint][data['Property']] = 1
  32. for data in ucd.parse_ucd_data(ucd_rootdir, 'Scripts'):
  33. for codepoint in data['Range']:
  34. unicode_chars[codepoint]['Script'] = data['Script']
  35. if '--with-csur' in sys.argv:
  36. for csur in ['Klingon']:
  37. for data in ucd.parse_ucd_data('data/csur', csur):
  38. for codepoint in data['CodePoint']:
  39. unicode_chars[codepoint] = data
  40. def iscntrl(data):
  41. return 1 if data.get('Name', '') == '<control>' else 0
  42. def isdigit(data):
  43. return 1 if data['CodePoint'].char() in '0123456789' else 0
  44. def isxdigit(data):
  45. return 1 if data['CodePoint'].char() in '0123456789ABCDEFabcdef' else 0
  46. def isspace(data):
  47. if data.get('White_Space', 0):
  48. dt = data.get('DecompositionType', '')
  49. return 1 if dt == None or not dt.startswith('<noBreak>') else 0
  50. else:
  51. return 0
  52. def isblank(data): # word separator
  53. if data.get('GeneralCategory', 'Cn') == 'Zs' or data['CodePoint'].char() == '\t':
  54. dt = data.get('DecompositionType', '')
  55. return 1 if dt == None or not dt.startswith('<noBreak>') else 0
  56. else:
  57. return 0
  58. def ispunct(data):
  59. if data.get('GeneralCategory', 'Cn')[0] in 'P':
  60. return 1
  61. else:
  62. return 0
  63. def isprint(data):
  64. if data.get('GeneralCategory', 'Cn')[0] in 'LMNPSZ': # not in 'CI'
  65. return 1
  66. else:
  67. return 0
  68. def isgraph(data):
  69. if data.get('GeneralCategory', 'Cn')[0] in 'LMNPS': # not in 'CZI'
  70. return 1
  71. else:
  72. return 0
  73. def isalnum(data):
  74. if data.get('GeneralCategory', 'Cn')[0] in 'LN':
  75. return 1
  76. else:
  77. return 0
  78. def isalpha(data):
  79. if data.get('GeneralCategory', 'Cn')[0] in 'L':
  80. return 1
  81. else:
  82. return 0
  83. def isupper(data):
  84. if data.get('LowerCase', null) != null:
  85. return 1
  86. elif data.get('GeneralCategory', 'Cn') == 'Lu':
  87. return 1
  88. else:
  89. return 0
  90. def islower(data):
  91. if data.get('UpperCase', null) != null:
  92. return 1
  93. elif data.get('GeneralCategory', 'Cn') == 'Ll':
  94. return 1
  95. else:
  96. return 0
  97. if __name__ == '__main__':
  98. for codepoint in ucd.CodeRange('000000..10FFFF'):
  99. try:
  100. data = unicode_chars[codepoint]
  101. except KeyError:
  102. data = {'CodePoint': codepoint}
  103. script = data.get('Script', 'Zzzz')
  104. title = data.get('TitleCase', codepoint)
  105. upper = data.get('UpperCase', codepoint)
  106. lower = data.get('LowerCase', codepoint)
  107. if title == null: title = codepoint
  108. if upper == null: upper = codepoint
  109. if lower == null: lower = codepoint
  110. print('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s' % (
  111. codepoint, script,
  112. data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
  113. upper, lower, title,
  114. isdigit(data), isxdigit(data),
  115. iscntrl(data), isspace(data), isblank(data), ispunct(data),
  116. isprint(data), isgraph(data), isalnum(data), isalpha(data), isupper(data), islower(data)))