Comments (4)
And the problem also exists for Russian:
>>> import sacremoses
>>> TEXT_RUS = 'Ру́сский язы́к ([ˈruskʲɪi̯ jɪˈzɨk] Информация о файле слушать)[~ 3][⇨] — один из восточнославянских языков, национальный язык русского народа.'
>>> EXPECTED_TOKENS = ['Ру́сский', 'язы́к', '(', '[', 'ˈruskʲɪi̯', 'jɪˈzɨk', ']', 'Информация', 'о', 'файле', 'слушать', ')', '[', '~', '3', ']', '[', '⇨', ']', '—', 'один', 'из', 'восточнославянских', 'языков', ',', 'национальный', 'язык', 'русского', 'народа', '.']
>>> t = sacremoses.MosesTokenizer(lang = 'ru')
>>> t.tokenize(TEXT_RUS)
['Ру', '́', 'сский', 'язы', '́', 'к', '(', '[', 'ˈruskʲɪi', '̯', 'jɪˈzɨk', ']', 'Информация', 'о', 'файле', 'слушать', ')', '[', '~', '3', ']', '[', '⇨', ']', '—', 'один', 'из', 'восточнославянских', 'языков', ',', 'национальный', 'язык', 'русского', 'народа', '.']
>>> assert t.tokenize(TEXT_RUS) == EXPECTED_TOKENS
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
assert t.tokenize(TEXT_RUS) == EXPECTED_TOKENS
AssertionError
from sacremoses.
Just a note: Moses tokenizer has the same behavior:
$ echo "தமிழ் மொழி (Tamil language) தமிழர்களினதும், தமிழ் பேசும் பலரதும் தாய்மொழி ஆகும்." | tokenizer.perl -q -no-escape -l ta
தமிழ ் மொழி ( Tamil language ) தமிழர ் களினதும ் , தமிழ ் பேசும ் பலரதும ் தாய ் மொழி ஆகும ் .
from sacremoses.
Yes actually this is the same as the Hindi problem at #42
There's a way to resolve this but it requires a little more digging and understanding of Indian languages in the unicode charset =(
This is caused by https://github.com/alvations/sacremoses/blob/master/sacremoses/tokenize.py#L41 padding spaces to characters which it this isn't alphanumeric from https://github.com/alvations/sacremoses/blob/master/sacremoses/tokenize.py#L24
Adding the ்
character to the IsAlnum list and uncommenting the character will fix this issue partially but there's actually more problems than that unicode character.
from sacremoses.
Same outputs from default mosesdecoder
(Commit: moses-smt/mosesdecoder@0578892) :
$ echo "Ру́сский язы́к ([ˈruskʲɪi̯ jɪˈzɨk] Информация о файле слушать)[~ 3][⇨] — один из восточнославянских языков, национальный язык русского народа." | perl tokenizer.perl -l ru
Tokenizer Version 1.1
Language: ru
Number of threads: 1
Ру ́ сский язы ́ к ( [ ˈruskʲɪi ̯ jɪˈzɨk ] Информация о файле слушать ) [ ~ 3 ] [ ⇨ ] — один из восточнославянских языков , национальный язык русского народа .
from sacremoses.
Related Issues (20)
- error: loading model for detruecaser
- Bug: normalize prints extra newline HOT 1
- Is this normal to tokenize "His number is No.123." to ['His', 'number', 'is', 'No.123.']. Should it be ['His', 'number', 'is', 'No.123', '.']?
- bug report
- Truecaser seems do not process sentences beginning with quotation marks
- update release on github
- No detokenize_penn?
- can't tokenise the period properly
- deep detokenizer
- Chinese full stop “。” can't be split. HOT 1
- Trying to get in touch regarding a security issue HOT 2
- Is there a way to use sacremoses in java? HOT 1
- Cache downloaded tokenizer files HOT 1
- Which of the 100 languages used in mBERT are not supported by this tokenizer? HOT 1
- distutils is deprecated in Python 3.10 HOT 1
- New release? HOT 4
- Error with CLI `tokenize` using `click==8.1.3` HOT 10
- Is this package multi-threaded? HOT 1
- [Question] Why is <unk> token tokenized into 3 items? HOT 1
- Quiet flag has no effect on the detokenizer HOT 1
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 sacremoses.