GithubHelp home page GithubHelp logo

Greek encoding about ucto HOT 6 CLOSED

languagemachines avatar languagemachines commented on June 4, 2024
Greek encoding

from ucto.

Comments (6)

proycon avatar proycon commented on June 4, 2024

Very interesting indeed! I suspect it has something to do with unicode normalisation (https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms), there are several "unicode normal forms". I doubt this is something ucto deliberately did, but was rather handled in the underlying libicu. We either implicitly or explicitly opt for one of the normal forms I guess (@kosloot)?

In comparions, unicode libraries should treat these two strings as equivalent under the normal forms.

from ucto.

JessedeDoes avatar JessedeDoes commented on June 4, 2024

The problem disappears when I apply unicode normalization to the files after tokenization (but before final validation)

I suppose the Nederlab files will not be harmed by applying option 2. Anyway, it seems only greek text is affected.

1 Normalization Form D (NFD) Canonical Decomposition
2 Normalization Form C (NFC) Canonical Decomposition, followed by Canonical Composition
3 Normalization Form KD (NFKD) Compatibility Decomposition
4 Normalization Form KC (NFKC) Compatibility Decomposition, followed by Canonical Composition

from ucto.

kosloot avatar kosloot commented on June 4, 2024

it seems indeed a normalization 'problem'.
Ucto puts all UTF-8 in the NFC form deliberately. This to weed out the differences per OS (Linux, OSX, M$) and applications even. It is not uncommon for one document to have this intermixed!

==> A quick solution might be to run ucto with the option -N NONE. which should disable normalization.

Background:
This was done to make string comparison in later stages easy. But it look like ucto bites its own tail now.
(since we introduced a more strict text handling)

Internally, ucto and libfolia use Unicode strings, where this problem should be non-existent (folia.py too I assume) Only on conversion too/from UTF8 the problem arises.
But that puzzles me, because libfolia chokes on the file too. Although is uses Unicode String comparison. That needs more research... But is seems that Abstract Characters are handled differently (Or not at all?) by ICU. But converting to a UTF8 form an back to unicode seems help. Odd

Solutions:
There are several solutions I think.

  1. use the -N option of ucto.
  2. adapt the text-checking in libfolia and folia.py to use normalization too
  3. adapt libfolia and folio.py to normalize all incoming/outgoing UTF8 to NFC or NFD

Discussion:

  1. Seems unwise, the consequences on other programs like Frog and Tscan are unclear.
  2. this could be done quite easy, I thought. But see my puzzle above..
  3. this might be a good idea on the long run. But do you want that configurable? etc.
    better let it external, using iconv or such ?

So more questions then answers.

from ucto.

kosloot avatar kosloot commented on June 4, 2024

Well,
I did find the code to implement solution 2 in libfolia. Using the ICU function:
Normalizer::compare( s1, s2, opts, Err )

from ucto.

kosloot avatar kosloot commented on June 4, 2024

That function is part of a deprecated module, so let's not go there.

I think that the best solution is to go with option 3. and adapting libfolia AND follia.py.
I tested this for libfolia, and it is almost a no-brainer.
In this way we assure that all UTF8 produced with the library is in 1 normalization,
all software build upon libfolia will benefit from this.

For Python there is unicodedata.normalize()

from ucto.

proycon avatar proycon commented on June 4, 2024

Since this is solved in other packages and yet-to-be solved in issue proycon/pynlpl#37, closing this one.

from ucto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.