Comments (6)
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.
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.
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.
- use the -N option of ucto.
- adapt the text-checking in libfolia and folia.py to use normalization too
- adapt libfolia and folio.py to normalize all incoming/outgoing UTF8 to NFC or NFD
Discussion:
- Seems unwise, the consequences on other programs like Frog and Tscan are unclear.
- this could be done quite easy, I thought. But see my puzzle above..
- 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.
Well,
I did find the code to implement solution 2 in libfolia. Using the ICU function:
Normalizer::compare( s1, s2, opts, Err )
from ucto.
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.
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)
- problems with 'complex' file names using the -c option HOT 3
- add a rule for ROMAN numbers
- interactive ucto seems broken
- passthru mode should not be combined with other language options
- ucto creates invalid folia HOT 2
- Update debian package for v0.21
- Byte-order mark followed by space or tab results in Folia error HOT 7
- is this correct handling of FoLiA paragraphs with embedded Part nodes? HOT 4
- -T full option produces invalid FoLiA HOT 1
- Tokenization of t-style element that has font_typeface Feature HOT 19
- Validation of ucto output fails due to space character in FoLiA output from Piereling HOT 7
- ucto sometimes misses out on the <t> for <p> HOT 3
- IDs in UCTO in concert with tei2folia HOT 3
- Language detection default for 'unknown' language HOT 9
- Ucto with 'detectlanguages' : failure HOT 3
- remove some deprecated options HOT 6
- Ucto aborts on FoLiA creation
- Question: Concatenating word parts at soft hyphens HOT 77
- Develop a tokenizer for Premodern Slavic
- Implement (soft)hyphen handling in Ucto analogues to foliautils
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ucto.