Add Greek characters to unaccent.rules.

Author: Tasos Maschalidis
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/153495048900.1368.11566580687623014380%40wrigleys.postgresql.org
Discussion: https://postgr.es/m/VI1PR01MB38537EBD529FE5EE3FE9A5FEB5370%40VI1PR01MB3853.eurprd01.prod.exchangelabs.com
This commit is contained in:
Thomas Munro 2018-09-02 07:12:24 +12:00
parent ec74369931
commit 5e8d670c31
2 changed files with 236 additions and 4 deletions

View File

@ -29,6 +29,15 @@ import argparse
import sys
import xml.etree.ElementTree as ET
# The ranges of Unicode characters that we consider to be "plain letters".
# For now we are being conservative by including only Latin and Greek. This
# could be extended in future based on feedback from people with relevant
# language knowledge.
PLAIN_LETTER_RANGES = ((ord('a'), ord('z')), # Latin lower case
(ord('A'), ord('Z')), # Latin upper case
(0x03b1, 0x03c9), # GREEK SMALL LETTER ALPHA, GREEK SMALL LETTER OMEGA
(0x0391, 0x03a9)) # GREEK CAPITAL LETTER ALPHA, GREEK CAPITAL LETTER OMEGA
def print_record(codepoint, letter):
print (unichr(codepoint) + "\t" + letter).encode("UTF-8")
@ -39,9 +48,11 @@ class Codepoint:
self.combining_ids = combining_ids
def is_plain_letter(codepoint):
"""Return true if codepoint represents a plain ASCII letter."""
return (codepoint.id >= ord('a') and codepoint.id <= ord('z')) or \
(codepoint.id >= ord('A') and codepoint.id <= ord('Z'))
"""Return true if codepoint represents a "plain letter"."""
for begin, end in PLAIN_LETTER_RANGES:
if codepoint.id >= begin and codepoint.id <= end:
return True
return False
def is_mark(codepoint):
"""Returns true for diacritical marks (combining codepoints)."""
@ -184,7 +195,7 @@ def main(args):
len(codepoint.combining_ids) > 1:
if is_letter_with_marks(codepoint, table):
charactersSet.add((codepoint.id,
chr(get_plain_letter(codepoint, table).id)))
unichr(get_plain_letter(codepoint, table).id)))
elif args.noLigaturesExpansion is False and is_ligature(codepoint, table):
charactersSet.add((codepoint.id,
"".join(unichr(combining_codepoint.id)

View File

@ -399,6 +399,26 @@
ʦ ts
ʪ ls
ʫ lz
Ά Α
Έ Ε
Ή Η
Ί Ι
Ό Ο
Ύ Υ
Ώ Ω
ΐ ι
Ϊ Ι
Ϋ Υ
ά α
έ ε
ή η
ί ι
ΰ υ
ϊ ι
ϋ υ
ό ο
ύ υ
ώ ω
Ё Е
ё е
ᴀ A
@ -709,6 +729,207 @@
ỽ v
Ỿ Y
ỿ y
α
α
α
α
α
α
α
α
Α
Α
Α
Α
Α
Α
Α
Α
ἐ ε
ἑ ε
ἒ ε
ἓ ε
ἔ ε
ἕ ε
Ε
Ε
Ε
Ε
Ε
Ε
ἠ η
ἡ η
ἢ η
ἣ η
ἤ η
ἥ η
ἦ η
ἧ η
Η
Η
Η
Η
Η
Η
Η
Η
ι
ι
ι
ι
ι
ι
ι
ι
Ι
Ι
Ι
Ι
Ι
Ι
Ι
Ἷ Ι
ο
ο
ο
ο
ο
ο
Ο
Ο
Ο
Ο
Ο
Ο
υ
υ
υ
υ
υ
υ
υ
υ
Υ
Υ
Υ
Υ
ὠ ω
ὡ ω
ὢ ω
ὣ ω
ὤ ω
ὥ ω
ὦ ω
ὧ ω
Ὠ Ω
Ὡ Ω
Ὢ Ω
Ὣ Ω
Ὤ Ω
Ὥ Ω
Ὦ Ω
Ὧ Ω
α
ὲ ε
ὴ η
ι
ο
υ
ὼ ω
α
α
α
α
α
α
α
α
Α
Α
Α
Α
Α
Α
Α
Α
ᾐ η
ᾑ η
ᾒ η
ᾓ η
ᾔ η
ᾕ η
ᾖ η
ᾗ η
Η
Η
Η
Η
Η
Η
Η
Η
ᾠ ω
ᾡ ω
ᾢ ω
ᾣ ω
ᾤ ω
ᾥ ω
ᾦ ω
ᾧ ω
ᾨ Ω
ᾩ Ω
ᾪ Ω
ᾫ Ω
ᾬ Ω
ᾭ Ω
ᾮ Ω
ᾯ Ω
α
α
α
α
α
α
α
Α
Α
Α
Α
ῂ η
ῃ η
ῄ η
ῆ η
ῇ η
Ε
Η
Η
ι
ι
ι
ι
ι
Ι
Ι
Ι
υ
υ
υ
ρ
ρ
υ
υ
Υ
Υ
Υ
Ρ
ῲ ω
ῳ ω
ῴ ω
ῶ ω
ῷ ω
Ο
Ὼ Ω
ῼ Ω
-
-
-