pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15347: Unaccent for greek characters does not work
16+ messages / 6 participants
[nested] [flat]

Commits from this thread:
  2018-09-01 5e8d670c31  Add Greek characters to unaccent.rules.
* BUG #15347: Unaccent for greek characters does not work
@ 2018-08-22 15:08 PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 16+ messages in thread

From: PG Bug reporting form @ 2018-08-22 15:08 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: tas.o.s@hotmail.com

The following bug has been logged on the website:

Bug reference:      15347
Logged by:          Tasos Maschalidis
Email address:      tas.o.s@hotmail.com
PostgreSQL version: 9.3.18
Operating system:   Ubuntu 4.8.4
Description:        

Call to unaccent function with greek characters does not return the greek
characters without the accents as expected (not even just the few diacritics
used in modern Greek). While the customization of unaccent.rules is an
option for dedicated servers, most cloud services do not provide write
access to the file system and thus this is limiting the unaccent feature for
greek characters. This forces us to find workarounds for something
relatively simple (just some extra characters with diacritics in the
official dictionary). Please find more details in this answer of Stack
Overflow: https://stackoverflow.com/a/49849260/5909738

Thank you,
Tasos Maschalidis



^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
@ 2018-08-23 05:22 ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 05:36   ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  0 siblings, 2 replies; 16+ messages in thread

From: Thomas Munro @ 2018-08-23 05:22 UTC (permalink / raw)
  To: tas.o.s@hotmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Thu, Aug 23, 2018 at 3:08 AM, PG Bug reporting form
<noreply@postgresql.org> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      15347
> Logged by:          Tasos Maschalidis
> Email address:      tas.o.s@hotmail.com
> PostgreSQL version: 9.3.18
> Operating system:   Ubuntu 4.8.4
> Description:
>
> Call to unaccent function with greek characters does not return the greek
> characters without the accents as expected (not even just the few diacritics
> used in modern Greek).

Hello Tasos,

Right.  We generate the unaccent.rules file from the Unicode data file
using the Python script contrib/unaccent/generate_unaccent_rules.py in
the PostgreSQL source tree.  The script currently limits itself to
Latin characters here:

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'))

I was not brave enough to support other kinds of characters, because I
can't read 'em and check if the results are garbage (if you remove the
diacritics from Klingon, it might change the meaning of any word into
a declaration of war for all I know).  If you know Python and would
like to have a go at modifying that script to support Greek, please
do!  Otherwise perhaps I could try to do it and you could review the
results.

There is a precedent already that it knows how to remove a diacritic
from at least one Cyrillic character.  I think there is no reason at
all we shouldn't take a patch to support Greek or any other alphabet
that a native speaker can advise us on.

I think the chances of squeaking a change into PostgreSQL 11 are slim,
since it would require a special exception from the Release Management
Team at this point.  Failing that, it'd be for PostgreSQL 12.  We
don't usually back-patch unaccent.rules changes because they can
affect in indexed data, and we don't want minor version upgrades to
break stuff.

[1] https://www.postgresql.org/message-id/CAEepm%3D1KRVinFtuDao4L%2BqSBh4T4k3z996EwD5-zgytu4Qa5Fw%40mail...

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-23 05:36   ` Michael Paquier <michael@paquier.xyz>
  1 sibling, 0 replies; 16+ messages in thread

From: Michael Paquier @ 2018-08-23 05:36 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: tas.o.s@hotmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Thu, Aug 23, 2018 at 05:22:21PM +1200, Thomas Munro wrote:
> There is a precedent already that it knows how to remove a diacritic
> from at least one Cyrillic character.  I think there is no reason at
> all we shouldn't take a patch to support Greek or any other alphabet
> that a native speaker can advise us on.

+1.  ec0a69e4 has added recently support for Vietnamese characters.
Once you get into it hacking this python code is not that difficult.

> I think the chances of squeaking a change into PostgreSQL 11 are slim,
> since it would require a special exception from the Release Management
> Team at this point.  Failing that, it'd be for PostgreSQL 12.  We
> don't usually back-patch unaccent.rules changes because they can
> affect in indexed data, and we don't want minor version upgrades to
> break stuff.

Getting that into v11 would be too late :(
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-23 12:22   ` Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  1 sibling, 1 reply; 16+ messages in thread

From: Tasos Maschalidis @ 2018-08-23 12:22 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Hi Thomas,



Your concerns are understandable, especially when Klingon is taken into consideration.

I am not familiar enough with python to set up something to run the script and check the result, but I am more than willing to review the results! If you need any more input from my part (being a native Greek speaker) please ask away!



If I understood correctly, I guess to include the greek characters the method would need to change to this?:

return (codepoint.id >= ord('a') and codepoint.id <= ord('z')) or \
           (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \

           (codepoint.id >= ord('á') and codepoint.id <= ord('ù')) or \
           (codepoint.id >= ord('Á') and codepoint.id <= ord('Ù'))



Thanks,

Tasos Maschalidis



Ps: This gist is what the results should look like, considering greek characters (lines 190-409).





________________________________
Áðü: Thomas Munro <thomas.munro@enterprisedb.com>
ÓôÜëèçêå: Thursday, August 23, 2018 8:22:21 AM
Ðñïò: tas.o.s@hotmail.com; PostgreSQL mailing lists
ÈÝìá: Re: BUG #15347: Unaccent for greek characters does not work

On Thu, Aug 23, 2018 at 3:08 AM, PG Bug reporting form
<noreply@postgresql.org> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      15347
> Logged by:          Tasos Maschalidis
> Email address:      tas.o.s@hotmail.com
> PostgreSQL version: 9.3.18
> Operating system:   Ubuntu 4.8.4
> Description:
>
> Call to unaccent function with greek characters does not return the greek
> characters without the accents as expected (not even just the few diacritics
> used in modern Greek).

Hello Tasos,

Right.  We generate the unaccent.rules file from the Unicode data file
using the Python script contrib/unaccent/generate_unaccent_rules.py in
the PostgreSQL source tree.  The script currently limits itself to
Latin characters here:

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'))

I was not brave enough to support other kinds of characters, because I
can't read 'em and check if the results are garbage (if you remove the
diacritics from Klingon, it might change the meaning of any word into
a declaration of war for all I know).  If you know Python and would
like to have a go at modifying that script to support Greek, please
do!  Otherwise perhaps I could try to do it and you could review the
results.

There is a precedent already that it knows how to remove a diacritic
from at least one Cyrillic character.  I think there is no reason at
all we shouldn't take a patch to support Greek or any other alphabet
that a native speaker can advise us on.

I think the chances of squeaking a change into PostgreSQL 11 are slim,
since it would require a special exception from the Release Management
Team at this point.  Failing that, it'd be for PostgreSQL 12.  We
don't usually back-patch unaccent.rules changes because they can
affect in indexed data, and we don't want minor version upgrades to
break stuff.

[1] https://www.postgresql.org/message-id/CAEepm%3D1KRVinFtuDao4L%2BqSBh4T4k3z996EwD5-zgytu4Qa5Fw%40mail...

--
Thomas Munro
http://www.enterprisedb.com

^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
@ 2018-08-23 22:16     ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 22:47       ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <tas.o.s@hotmail.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  0 siblings, 2 replies; 16+ messages in thread

From: Thomas Munro @ 2018-08-23 22:16 UTC (permalink / raw)
  To: Tasos Maschalidis <TaS.O.S@hotmail.com>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 12:22 AM, Tasos Maschalidis <TaS.O.S@hotmail.com> wrote:
> return (codepoint.id >= ord('a') and codepoint.id <= ord('z')) or \
>            (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \
>
>            (codepoint.id >= ord('α') and codepoint.id <= ord('ω')) or \
>            (codepoint.id >= ord('Α') and codepoint.id <= ord('Ω'))

Thank you.  Here it is in the form of a patch that I propose to commit
to PostgreSQL 12.  It adds 221 lines to unaccent.rules.  They look
sane to my untrained eye.  Do you agree?

Example of use:

postgres=# select unaccent('Θέμα: Re: BUG #15347: Unaccent for greek ...');
                   unaccent
----------------------------------------------
 Θεμα: Re: BUG #15347: Unaccent for greek ...
(1 row)

I wondered if the documentation might need a change, but it already
says something broad enough: "A more complete example, which is
directly useful for most European languages, can be found in
unaccent.rules, ...".

-- 
Thomas Munro
http://www.enterprisedb.com

Attachments:

0001-Add-Greek-characters-to-unaccent.rules.patch (application/octet-stream, 4.1K) download From 1c8071379aef574057746ad2fb4a26adc1be2281 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.munro@enterprisedb.com> Date: Fri, 24 Aug 2018 09:41:06 +1200 Subject: [PATCH] Add Greek characters to unaccent.rules. Author: Tasos Maschalidis Discussion: https://postgr.es/m/153495048900.1368.11566580687623014380%40wrigleys.postgresql.org Discussion: https://postgr.es/m/VI1PR01MB38537EBD529FE5EE3FE9A5FEB5370%40VI1PR01MB3853.eurprd01.prod.exchangelabs.com --- contrib/unaccent/generate_unaccent_rules.py | 8 +- contrib/unaccent/unaccent.rules | 221 ++++++++++++++++++++ 2 files changed, 226 insertions(+), 3 deletions(-) diff --git a/contrib/unaccent/generate_unaccent_rules.py b/contrib/unaccent/generate_unaccent_rules.py index 4b1b011861..429c252d19 100644 --- a/contrib/unaccent/generate_unaccent_rules.py +++ b/contrib/unaccent/generate_unaccent_rules.py @@ -39,9 +39,11 @@ class Codepoint: self.combining_ids = combining_ids def is_plain_letter(codepoint): - """Return true if codepoint represents a plain ASCII letter.""" + """Return true if codepoint represents a plain Latin or Greek letter.""" return (codepoint.id >= ord('a') and codepoint.id <= ord('z')) or \ - (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) + (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \ + (codepoint.id >= ord(u'α') and codepoint.id <= ord(u'ω')) or \ + (codepoint.id >= ord(u'Α') and codepoint.id <= ord(u'Ω')) def is_mark(codepoint): """Returns true for diacritical marks (combining codepoints).""" @@ -184,7 +186,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) diff --git a/contrib/unaccent/unaccent.rules b/contrib/unaccent/unaccent.rules index 97f9ed47cf..76e4e69beb 100644 --- a/contrib/unaccent/unaccent.rules +++ b/contrib/unaccent/unaccent.rules @@ -399,6 +399,26 @@ ʥ dz ʦ ts ʪ ls ʫ lz +Ά Α +Έ Ε +Ή Η +Ί Ι +Ό Ο +Ύ Υ +Ώ Ω +ΐ ι +Ϊ Ι +Ϋ Υ +ά α +έ ε +ή η +ί ι +ΰ υ +ϊ ι +ϋ υ +ό ο +ύ υ +ώ ω Ё Е ё е ᴀ A @@ -709,6 +729,207 @@ Ỽ V ỽ v Ỿ Y ỿ y +ἀ α +ἁ α +ἂ α +ἃ α +ἄ α +ἅ α +ἆ α +ἇ α +Ἀ Α +Ἁ Α +Ἂ Α +Ἃ Α +Ἄ Α +Ἅ Α +Ἆ Α +Ἇ Α +ἐ ε +ἑ ε +ἒ ε +ἓ ε +ἔ ε +ἕ ε +Ἐ Ε +Ἑ Ε +Ἒ Ε +Ἓ Ε +Ἔ Ε +Ἕ Ε +ἠ η +ἡ η +ἢ η +ἣ η +ἤ η +ἥ η +ἦ η +ἧ η +Ἠ Η +Ἡ Η +Ἢ Η +Ἣ Η +Ἤ Η +Ἥ Η +Ἦ Η +Ἧ Η +ἰ ι +ἱ ι +ἲ ι +ἳ ι +ἴ ι +ἵ ι +ἶ ι +ἷ ι +Ἰ Ι +Ἱ Ι +Ἲ Ι +Ἳ Ι +Ἴ Ι +Ἵ Ι +Ἶ Ι +Ἷ Ι +ὀ ο +ὁ ο +ὂ ο +ὃ ο +ὄ ο +ὅ ο +Ὀ Ο +Ὁ Ο +Ὂ Ο +Ὃ Ο +Ὄ Ο +Ὅ Ο +ὐ υ +ὑ υ +ὒ υ +ὓ υ +ὔ υ +ὕ υ +ὖ υ +ὗ υ +Ὑ Υ +Ὓ Υ +Ὕ Υ +Ὗ Υ +ὠ ω +ὡ ω +ὢ ω +ὣ ω +ὤ ω +ὥ ω +ὦ ω +ὧ ω +Ὠ Ω +Ὡ Ω +Ὢ Ω +Ὣ Ω +Ὤ Ω +Ὥ Ω +Ὦ Ω +Ὧ Ω +ὰ α +ὲ ε +ὴ η +ὶ ι +ὸ ο +ὺ υ +ὼ ω +ᾀ α +ᾁ α +ᾂ α +ᾃ α +ᾄ α +ᾅ α +ᾆ α +ᾇ α +ᾈ Α +ᾉ Α +ᾊ Α +ᾋ Α +ᾌ Α +ᾍ Α +ᾎ Α +ᾏ Α +ᾐ η +ᾑ η +ᾒ η +ᾓ η +ᾔ η +ᾕ η +ᾖ η +ᾗ η +ᾘ Η +ᾙ Η +ᾚ Η +ᾛ Η +ᾜ Η +ᾝ Η +ᾞ Η +ᾟ Η +ᾠ ω +ᾡ ω +ᾢ ω +ᾣ ω +ᾤ ω +ᾥ ω +ᾦ ω +ᾧ ω +ᾨ Ω +ᾩ Ω +ᾪ Ω +ᾫ Ω +ᾬ Ω +ᾭ Ω +ᾮ Ω +ᾯ Ω +ᾰ α +ᾱ α +ᾲ α +ᾳ α +ᾴ α +ᾶ α +ᾷ α +Ᾰ Α +Ᾱ Α +Ὰ Α +ᾼ Α +ῂ η +ῃ η +ῄ η +ῆ η +ῇ η +Ὲ Ε +Ὴ Η +ῌ Η +ῐ ι +ῑ ι +ῒ ι +ῖ ι +ῗ ι +Ῐ Ι +Ῑ Ι +Ὶ Ι +ῠ υ +ῡ υ +ῢ υ +ῤ ρ +ῥ ρ +ῦ υ +ῧ υ +Ῠ Υ +Ῡ Υ +Ὺ Υ +Ῥ Ρ +ῲ ω +ῳ ω +ῴ ω +ῶ ω +ῷ ω +Ὸ Ο +Ὼ Ω +ῼ Ω ‐ - ‑ - ‒ - -- 2.17.0
^ permalink raw reply [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-23 22:47       ` Tasos Maschalidis <tas.o.s@hotmail.com>
  2018-08-23 23:22         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  1 sibling, 1 reply; 16+ messages in thread

From: Tasos Maschalidis @ 2018-08-23 22:47 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Hi Thomas,

The results are legit for all vowels. There is only one thing missing which I guess does fall into unaccent functionality. When an "ó" is used as the last letter of any word, it changes to "s" grammatically, unless the whole word is capitals, then it stays the same ("Ó"), even at the end of the word. In searches it s useful to convert any "ò" to "ó". I had included it to a custom unaccent.rules file I was using and brought desired results. For example searching for "ÈùìÜò" would not match "ÈÙÌÁÓ", unless such a convertion exists. Not sure if that should be taken care of somewhere else, but in my case (and also in the gist I sent you, check the last comments) it proved useful and made sense.

Thank you,
Tasos Maschalidis
________________________________
From: Thomas Munro <thomas.munro@enterprisedb.com>
Sent: Friday, August 24, 2018 1:16:14 AM
To: Tasos Maschalidis
Cc: PostgreSQL mailing lists
Subject: Re: BUG #15347: Unaccent for greek characters does not work

On Fri, Aug 24, 2018 at 12:22 AM, Tasos Maschalidis <TaS.O.S@hotmail.com> wrote:
> return (codepoint.id >= ord('a') and codepoint.id <= ord('z')) or \
>            (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \
>
>            (codepoint.id >= ord('á') and codepoint.id <= ord('ù')) or \
>            (codepoint.id >= ord('Á') and codepoint.id <= ord('Ù'))

Thank you.  Here it is in the form of a patch that I propose to commit
to PostgreSQL 12.  It adds 221 lines to unaccent.rules.  They look
sane to my untrained eye.  Do you agree?

Example of use:

postgres=# select unaccent('ÈÝìá: Re: BUG #15347: Unaccent for greek ...');
                   unaccent
----------------------------------------------
 Èåìá: Re: BUG #15347: Unaccent for greek ...
(1 row)

I wondered if the documentation might need a change, but it already
says something broad enough: "A more complete example, which is
directly useful for most European languages, can be found in
unaccent.rules, ...".

--
Thomas Munro
http://www.enterprisedb.com

^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 22:47       ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <tas.o.s@hotmail.com>
@ 2018-08-23 23:22         ` Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 0 replies; 16+ messages in thread

From: Thomas Munro @ 2018-08-23 23:22 UTC (permalink / raw)
  To: Tasos Maschalidis <tas.o.s@hotmail.com>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 10:47 AM, Tasos Maschalidis <tas.o.s@hotmail.com> wrote:
> The results are legit for all vowels.

Cool.

> There is only one thing missing which
> I guess does fall into unaccent functionality. When an "σ" is used as the
> last letter of any word, it changes to "s" grammatically, unless the whole
> word is capitals, then it stays the same ("Σ"), even at the end of the word.
> In searches it s useful to convert any "ς" to "σ". I had included it to a
> custom unaccent.rules file I was using and brought desired results. For
> example searching for "Θωμάς" would not match "ΘΩΜΑΣ", unless such a
> convertion exists. Not sure if that should be taken care of somewhere else,
> but in my case (and also in the gist I sent you, check the last comments) it
> proved useful and made sense.

Hmm, I see.  Also described here:

https://en.wikipedia.org/wiki/Sigma

I take it you are making searches case insensitive by converting
everything to lower case.  Since you have a distinction that exists in
lower case but not in upper case, wouldn't it make more sense to
converting everything to upper case?

postgres=# select upper('Θωμάς'), upper('Θωμάσ'), upper('Θωμάσ') =
upper('Θωμάς');
 upper | upper | ?column?
-------+-------+----------
 ΘΩΜΆΣ | ΘΩΜΆΣ | t
(1 row)

PS On PostgreSQL mailing lists, we try to avoid "top posting" (=
leaving the message we're replying to below our reply), because it
makes the archive of email threads harder to read.

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-24 00:12       ` Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  1 sibling, 1 reply; 16+ messages in thread

From: Michael Paquier @ 2018-08-24 00:12 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 10:16:14AM +1200, Thomas Munro wrote:
> I wondered if the documentation might need a change, but it already
> says something broad enough: "A more complete example, which is
> directly useful for most European languages, can be found in
> unaccent.rules, ...".

Perhaps it would be better to avoid non-ASCII characters in this script?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
@ 2018-08-24 00:16         ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 16+ messages in thread

From: Thomas Munro @ 2018-08-24 00:16 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 12:12 PM, Michael Paquier <michael@paquier.xyz> wrote:
> On Fri, Aug 24, 2018 at 10:16:14AM +1200, Thomas Munro wrote:
>> I wondered if the documentation might need a change, but it already
>> says something broad enough: "A more complete example, which is
>> directly useful for most European languages, can be found in
>> unaccent.rules, ...".
>
> Perhaps it would be better to avoid non-ASCII characters in this script?

You mean in the Python script?  Why?  At the top it has a PEP-263
encoding declaration:

# -*- coding: utf-8 -*-

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-24 02:07           ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-24 03:32             ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 16+ messages in thread

From: Tom Lane @ 2018-08-24 02:07 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Thomas Munro <thomas.munro@enterprisedb.com> writes:
> On Fri, Aug 24, 2018 at 12:12 PM, Michael Paquier <michael@paquier.xyz> wrote:
>> Perhaps it would be better to avoid non-ASCII characters in this script?

> You mean in the Python script?  Why?  At the top it has a PEP-263
> encoding declaration:
> # -*- coding: utf-8 -*-

What happens if someone tries to view this in a non-UTF8 encoding?

As a comparison point, we generally avoid using non-ASCII characters
directly in the SGML docs; we write out the appropriate SGML entity
instead.  I think we should try to do the equivalent thing here ---
I assume python has some way to write "U+nnnn" or some such.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-08-24 03:32             ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 11:35               ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 16+ messages in thread

From: Thomas Munro @ 2018-08-24 03:32 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael@paquier.xyz>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 2:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <thomas.munro@enterprisedb.com> writes:
>> On Fri, Aug 24, 2018 at 12:12 PM, Michael Paquier <michael@paquier.xyz> wrote:
>>> Perhaps it would be better to avoid non-ASCII characters in this script?
>
>> You mean in the Python script?  Why?  At the top it has a PEP-263
>> encoding declaration:
>> # -*- coding: utf-8 -*-
>
> What happens if someone tries to view this in a non-UTF8 encoding?
>
> As a comparison point, we generally avoid using non-ASCII characters
> directly in the SGML docs; we write out the appropriate SGML entity
> instead.  I think we should try to do the equivalent thing here ---
> I assume python has some way to write "U+nnnn" or some such.

Ok, 2 against 1.  Done.

I'll wait for other opinions on what to do about lower case sigma
before committing.  I'm not keen on adding that special case because:

1.  It's a new kind of thing: previously we did only accent and
ligature removal, but this is removal of variants that exist in only
one case.  It's admittedly a bit like the German ß, which lacks an
upper case version according to some German speakers and undergoes a
lossy conversion to double-S, but that was already handled without a
special case by ligature expansion, so it's not the same thing.

2.  We are down to only 5 hardcoded special cases: two Cyrillic
characters which I suspect will go away if we allow Cyrillic to be
processed via the general mechanism as we are doing here with Greek,
and 3 oddballs that we inherited from the old hand-maintained
unaccent.rules files: DEGREE CELSIUS, DEGREE FAHRENHEIT, and SOUND
RECORDING COPYRIGHT.  I think the degrees signs can be done
automatically with just a bit more Unicode smarts, and I might try
reporting SOUND RECORDING COPYRIGHT as missing from
<character-fallback> to the CLDR project whose data we're using.

3.  The problem seems to go away by itself if you convert to upper case.

-- 
Thomas Munro
http://www.enterprisedb.com

Attachments:

0001-Add-Greek-characters-to-unaccent.rules-v2.patch (application/octet-stream, 4.2K) download From fc17ab73b8c088494cec71ebd0ece4ef1187586c Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.munro@enterprisedb.com> Date: Fri, 24 Aug 2018 09:41:06 +1200 Subject: [PATCH] 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 --- contrib/unaccent/generate_unaccent_rules.py | 8 +- contrib/unaccent/unaccent.rules | 221 ++++++++++++++++++++ 2 files changed, 226 insertions(+), 3 deletions(-) diff --git a/contrib/unaccent/generate_unaccent_rules.py b/contrib/unaccent/generate_unaccent_rules.py index 4b1b011861..0f7a035580 100644 --- a/contrib/unaccent/generate_unaccent_rules.py +++ b/contrib/unaccent/generate_unaccent_rules.py @@ -39,9 +39,11 @@ class Codepoint: self.combining_ids = combining_ids def is_plain_letter(codepoint): - """Return true if codepoint represents a plain ASCII letter.""" + """Return true if codepoint represents a plain Latin or Greek letter.""" return (codepoint.id >= ord('a') and codepoint.id <= ord('z')) or \ - (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) + (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \ + (codepoint.id >= 0x03b1 and codepoint.id <= 0x03c9) or \ + (codepoint.id >= 0x0391 and codepoint.id <= 0x03a9) def is_mark(codepoint): """Returns true for diacritical marks (combining codepoints).""" @@ -184,7 +186,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) diff --git a/contrib/unaccent/unaccent.rules b/contrib/unaccent/unaccent.rules index 97f9ed47cf..76e4e69beb 100644 --- a/contrib/unaccent/unaccent.rules +++ b/contrib/unaccent/unaccent.rules @@ -399,6 +399,26 @@ ʥ dz ʦ ts ʪ ls ʫ lz +Ά Α +Έ Ε +Ή Η +Ί Ι +Ό Ο +Ύ Υ +Ώ Ω +ΐ ι +Ϊ Ι +Ϋ Υ +ά α +έ ε +ή η +ί ι +ΰ υ +ϊ ι +ϋ υ +ό ο +ύ υ +ώ ω Ё Е ё е ᴀ A @@ -709,6 +729,207 @@ Ỽ V ỽ v Ỿ Y ỿ y +ἀ α +ἁ α +ἂ α +ἃ α +ἄ α +ἅ α +ἆ α +ἇ α +Ἀ Α +Ἁ Α +Ἂ Α +Ἃ Α +Ἄ Α +Ἅ Α +Ἆ Α +Ἇ Α +ἐ ε +ἑ ε +ἒ ε +ἓ ε +ἔ ε +ἕ ε +Ἐ Ε +Ἑ Ε +Ἒ Ε +Ἓ Ε +Ἔ Ε +Ἕ Ε +ἠ η +ἡ η +ἢ η +ἣ η +ἤ η +ἥ η +ἦ η +ἧ η +Ἠ Η +Ἡ Η +Ἢ Η +Ἣ Η +Ἤ Η +Ἥ Η +Ἦ Η +Ἧ Η +ἰ ι +ἱ ι +ἲ ι +ἳ ι +ἴ ι +ἵ ι +ἶ ι +ἷ ι +Ἰ Ι +Ἱ Ι +Ἲ Ι +Ἳ Ι +Ἴ Ι +Ἵ Ι +Ἶ Ι +Ἷ Ι +ὀ ο +ὁ ο +ὂ ο +ὃ ο +ὄ ο +ὅ ο +Ὀ Ο +Ὁ Ο +Ὂ Ο +Ὃ Ο +Ὄ Ο +Ὅ Ο +ὐ υ +ὑ υ +ὒ υ +ὓ υ +ὔ υ +ὕ υ +ὖ υ +ὗ υ +Ὑ Υ +Ὓ Υ +Ὕ Υ +Ὗ Υ +ὠ ω +ὡ ω +ὢ ω +ὣ ω +ὤ ω +ὥ ω +ὦ ω +ὧ ω +Ὠ Ω +Ὡ Ω +Ὢ Ω +Ὣ Ω +Ὤ Ω +Ὥ Ω +Ὦ Ω +Ὧ Ω +ὰ α +ὲ ε +ὴ η +ὶ ι +ὸ ο +ὺ υ +ὼ ω +ᾀ α +ᾁ α +ᾂ α +ᾃ α +ᾄ α +ᾅ α +ᾆ α +ᾇ α +ᾈ Α +ᾉ Α +ᾊ Α +ᾋ Α +ᾌ Α +ᾍ Α +ᾎ Α +ᾏ Α +ᾐ η +ᾑ η +ᾒ η +ᾓ η +ᾔ η +ᾕ η +ᾖ η +ᾗ η +ᾘ Η +ᾙ Η +ᾚ Η +ᾛ Η +ᾜ Η +ᾝ Η +ᾞ Η +ᾟ Η +ᾠ ω +ᾡ ω +ᾢ ω +ᾣ ω +ᾤ ω +ᾥ ω +ᾦ ω +ᾧ ω +ᾨ Ω +ᾩ Ω +ᾪ Ω +ᾫ Ω +ᾬ Ω +ᾭ Ω +ᾮ Ω +ᾯ Ω +ᾰ α +ᾱ α +ᾲ α +ᾳ α +ᾴ α +ᾶ α +ᾷ α +Ᾰ Α +Ᾱ Α +Ὰ Α +ᾼ Α +ῂ η +ῃ η +ῄ η +ῆ η +ῇ η +Ὲ Ε +Ὴ Η +ῌ Η +ῐ ι +ῑ ι +ῒ ι +ῖ ι +ῗ ι +Ῐ Ι +Ῑ Ι +Ὶ Ι +ῠ υ +ῡ υ +ῢ υ +ῤ ρ +ῥ ρ +ῦ υ +ῧ υ +Ῠ Υ +Ῡ Υ +Ὺ Υ +Ῥ Ρ +ῲ ω +ῳ ω +ῴ ω +ῶ ω +ῷ ω +Ὸ Ο +Ὼ Ω +ῼ Ω ‐ - ‑ - ‒ - -- 2.17.0
^ permalink raw reply [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-24 03:32             ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-24 11:35               ` Michael Paquier <michael@paquier.xyz>
  2018-08-27 22:50                 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 16+ messages in thread

From: Michael Paquier @ 2018-08-24 11:35 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 03:32:28PM +1200, Thomas Munro wrote:
> Ok, 2 against 1.  Done.

Thanks for considering it.  I have not gone in details through the patch
but...

+           (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \
+           (codepoint.id >= 0x03b1 and codepoint.id <= 0x03c9) or \
+           (codepoint.id >= 0x0391 and codepoint.id <= 0x03a9)

...  If you could add notes about what those codepoints are, or just
allocate them in a variable with a proper name, that would help with the
readability.  My apologies for the nits on this thread.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-24 03:32             ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 11:35               ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
@ 2018-08-27 22:50                 ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-28 03:20                   ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 16+ messages in thread

From: Thomas Munro @ 2018-08-27 22:50 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Fri, Aug 24, 2018 at 11:35 PM Michael Paquier <michael@paquier.xyz> wrote:
> On Fri, Aug 24, 2018 at 03:32:28PM +1200, Thomas Munro wrote:
> Thanks for considering it.  I have not gone in details through the patch
> but...
>
> +           (codepoint.id >= ord('A') and codepoint.id <= ord('Z')) or \
> +           (codepoint.id >= 0x03b1 and codepoint.id <= 0x03c9) or \
> +           (codepoint.id >= 0x0391 and codepoint.id <= 0x03a9)
>
> ...  If you could add notes about what those codepoints are, or just
> allocate them in a variable with a proper name, that would help with the
> readability.  My apologies for the nits on this thread.

Fair criticism, here's a version with comments.

-- 
Thomas Munro
http://www.enterprisedb.com

Attachments:

0001-Add-Greek-characters-to-unaccent.rules-v3.patch (application/octet-stream, 4.8K) download From f958cc6738d711aa963023f224ce55c7e5dcb550 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.munro@enterprisedb.com> Date: Fri, 24 Aug 2018 09:41:06 +1200 Subject: [PATCH] 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 --- contrib/unaccent/generate_unaccent_rules.py | 19 +- contrib/unaccent/unaccent.rules | 221 ++++++++++++++++++++ 2 files changed, 236 insertions(+), 4 deletions(-) diff --git a/contrib/unaccent/generate_unaccent_rules.py b/contrib/unaccent/generate_unaccent_rules.py index 4b1b011861..148d06cfae 100644 --- a/contrib/unaccent/generate_unaccent_rules.py +++ b/contrib/unaccent/generate_unaccent_rules.py @@ -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 lower case (alpha-omega) + (0x0391, 0x03a9)) # Greek upper case (ALPHA-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) diff --git a/contrib/unaccent/unaccent.rules b/contrib/unaccent/unaccent.rules index 97f9ed47cf..76e4e69beb 100644 --- a/contrib/unaccent/unaccent.rules +++ b/contrib/unaccent/unaccent.rules @@ -399,6 +399,26 @@ ʥ dz ʦ ts ʪ ls ʫ lz +Ά Α +Έ Ε +Ή Η +Ί Ι +Ό Ο +Ύ Υ +Ώ Ω +ΐ ι +Ϊ Ι +Ϋ Υ +ά α +έ ε +ή η +ί ι +ΰ υ +ϊ ι +ϋ υ +ό ο +ύ υ +ώ ω Ё Е ё е ᴀ A @@ -709,6 +729,207 @@ Ỽ V ỽ v Ỿ Y ỿ y +ἀ α +ἁ α +ἂ α +ἃ α +ἄ α +ἅ α +ἆ α +ἇ α +Ἀ Α +Ἁ Α +Ἂ Α +Ἃ Α +Ἄ Α +Ἅ Α +Ἆ Α +Ἇ Α +ἐ ε +ἑ ε +ἒ ε +ἓ ε +ἔ ε +ἕ ε +Ἐ Ε +Ἑ Ε +Ἒ Ε +Ἓ Ε +Ἔ Ε +Ἕ Ε +ἠ η +ἡ η +ἢ η +ἣ η +ἤ η +ἥ η +ἦ η +ἧ η +Ἠ Η +Ἡ Η +Ἢ Η +Ἣ Η +Ἤ Η +Ἥ Η +Ἦ Η +Ἧ Η +ἰ ι +ἱ ι +ἲ ι +ἳ ι +ἴ ι +ἵ ι +ἶ ι +ἷ ι +Ἰ Ι +Ἱ Ι +Ἲ Ι +Ἳ Ι +Ἴ Ι +Ἵ Ι +Ἶ Ι +Ἷ Ι +ὀ ο +ὁ ο +ὂ ο +ὃ ο +ὄ ο +ὅ ο +Ὀ Ο +Ὁ Ο +Ὂ Ο +Ὃ Ο +Ὄ Ο +Ὅ Ο +ὐ υ +ὑ υ +ὒ υ +ὓ υ +ὔ υ +ὕ υ +ὖ υ +ὗ υ +Ὑ Υ +Ὓ Υ +Ὕ Υ +Ὗ Υ +ὠ ω +ὡ ω +ὢ ω +ὣ ω +ὤ ω +ὥ ω +ὦ ω +ὧ ω +Ὠ Ω +Ὡ Ω +Ὢ Ω +Ὣ Ω +Ὤ Ω +Ὥ Ω +Ὦ Ω +Ὧ Ω +ὰ α +ὲ ε +ὴ η +ὶ ι +ὸ ο +ὺ υ +ὼ ω +ᾀ α +ᾁ α +ᾂ α +ᾃ α +ᾄ α +ᾅ α +ᾆ α +ᾇ α +ᾈ Α +ᾉ Α +ᾊ Α +ᾋ Α +ᾌ Α +ᾍ Α +ᾎ Α +ᾏ Α +ᾐ η +ᾑ η +ᾒ η +ᾓ η +ᾔ η +ᾕ η +ᾖ η +ᾗ η +ᾘ Η +ᾙ Η +ᾚ Η +ᾛ Η +ᾜ Η +ᾝ Η +ᾞ Η +ᾟ Η +ᾠ ω +ᾡ ω +ᾢ ω +ᾣ ω +ᾤ ω +ᾥ ω +ᾦ ω +ᾧ ω +ᾨ Ω +ᾩ Ω +ᾪ Ω +ᾫ Ω +ᾬ Ω +ᾭ Ω +ᾮ Ω +ᾯ Ω +ᾰ α +ᾱ α +ᾲ α +ᾳ α +ᾴ α +ᾶ α +ᾷ α +Ᾰ Α +Ᾱ Α +Ὰ Α +ᾼ Α +ῂ η +ῃ η +ῄ η +ῆ η +ῇ η +Ὲ Ε +Ὴ Η +ῌ Η +ῐ ι +ῑ ι +ῒ ι +ῖ ι +ῗ ι +Ῐ Ι +Ῑ Ι +Ὶ Ι +ῠ υ +ῡ υ +ῢ υ +ῤ ρ +ῥ ρ +ῦ υ +ῧ υ +Ῠ Υ +Ῡ Υ +Ὺ Υ +Ῥ Ρ +ῲ ω +ῳ ω +ῴ ω +ῶ ω +ῷ ω +Ὸ Ο +Ὼ Ω +ῼ Ω ‐ - ‑ - ‒ - -- 2.17.0
^ permalink raw reply [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-24 03:32             ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 11:35               ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-27 22:50                 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-08-28 03:20                   ` Michael Paquier <michael@paquier.xyz>
  2018-09-01 19:17                     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 16+ messages in thread

From: Michael Paquier @ 2018-08-28 03:20 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Tue, Aug 28, 2018 at 10:50:38AM +1200, Thomas Munro wrote:
> Fair criticism, here's a version with comments.

Thanks, that's way better in my opinion.  In the range of fancy things,
I have discovered today the python module unicodedata which can replace
for example 0x03b1 with ord("\N{GREEK SMALL LETTER ALPHA}"), leading to
perhaps more readable code.

Jokes apart, I would have preferred if you used directly the unicode
points as those are easier to look after in UnicodeData.txt, say
'\u03B1' for small alpha.  If you want to go with the hex code, it would
be a better reference to copy/paste directly the character name from
UnicodeData.txt as those are easier to search in the future, perhaps
with their unicode points:
- GREEK SMALL LETTER ALPHA
- GREEK SMALL LETTER OMEGA
- GREEK CAPITAL LETTER ALPHA
- GREEK CAPITAL LETTER OMEGA

Running generate_unaccent_rules.py, I get the same result for
unaccent.rules as you do.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-24 03:32             ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 11:35               ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-27 22:50                 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-28 03:20                   ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
@ 2018-09-01 19:17                     ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-09-01 23:22                       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 16+ messages in thread

From: Thomas Munro @ 2018-09-01 19:17 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Tue, Aug 28, 2018 at 3:20 PM Michael Paquier <michael@paquier.xyz> wrote:
> Jokes apart, I would have preferred if you used directly the unicode
> points as those are easier to look after in UnicodeData.txt, say
> '\u03B1' for small alpha.  If you want to go with the hex code, it would
> be a better reference to copy/paste directly the character name from
> UnicodeData.txt as those are easier to search in the future, perhaps
> with their unicode points:
> - GREEK SMALL LETTER ALPHA
> - GREEK SMALL LETTER OMEGA
> - GREEK CAPITAL LETTER ALPHA
> - GREEK CAPITAL LETTER OMEGA

Ok, I add the full code point names "GREEK ..." in comments, and
pushed this to master.  Thanks Tasos for the report, and Michael for
the review.

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 16+ messages in thread

* Re: BUG #15347: Unaccent for greek characters does not work
  2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
  2018-08-23 05:22 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-23 12:22   ` Re: BUG #15347: Unaccent for greek characters does not work Tasos Maschalidis <TaS.O.S@hotmail.com>
  2018-08-23 22:16     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 00:12       ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-24 00:16         ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 02:07           ` Re: BUG #15347: Unaccent for greek characters does not work Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-24 03:32             ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-24 11:35               ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-08-27 22:50                 ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
  2018-08-28 03:20                   ` Re: BUG #15347: Unaccent for greek characters does not work Michael Paquier <michael@paquier.xyz>
  2018-09-01 19:17                     ` Re: BUG #15347: Unaccent for greek characters does not work Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-09-01 23:22                       ` Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 16+ messages in thread

From: Michael Paquier @ 2018-09-01 23:22 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Tasos Maschalidis <TaS.O.S@hotmail.com>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Sun, Sep 02, 2018 at 07:17:59AM +1200, Thomas Munro wrote:
> Ok, I add the full code point names "GREEK ..." in comments, and
> pushed this to master.  Thanks Tasos for the report, and Michael for
> the review.

Thanks Thomas for taking care of this!
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 16+ messages in thread


end of thread, other threads:[~2018-09-01 23:22 UTC | newest]

Thread overview: 16+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22 15:08 BUG #15347: Unaccent for greek characters does not work PG Bug reporting form <noreply@postgresql.org>
2018-08-23 05:22 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-08-23 05:36   ` Michael Paquier <michael@paquier.xyz>
2018-08-23 12:22   ` Tasos Maschalidis <TaS.O.S@hotmail.com>
2018-08-23 22:16     ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-08-23 22:47       ` Tasos Maschalidis <tas.o.s@hotmail.com>
2018-08-23 23:22         ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-08-24 00:12       ` Michael Paquier <michael@paquier.xyz>
2018-08-24 00:16         ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-08-24 02:07           ` Tom Lane <tgl@sss.pgh.pa.us>
2018-08-24 03:32             ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-08-24 11:35               ` Michael Paquier <michael@paquier.xyz>
2018-08-27 22:50                 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-08-28 03:20                   ` Michael Paquier <michael@paquier.xyz>
2018-09-01 19:17                     ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-09-01 23:22                       ` Michael Paquier <michael@paquier.xyz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox