Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newmm-safe is inconsistence #755

Open
chameleonTK opened this issue Nov 2, 2022 · 3 comments
Open

Newmm-safe is inconsistence #755

chameleonTK opened this issue Nov 2, 2022 · 3 comments
Labels
bug bugs in the library Hacktoberfest for Hacktoberfest event
Projects
Milestone

Comments

@chameleonTK
Copy link
Contributor

I tried newmm-safe engine but it gave inconsistent results. It sometimes tokenized correctly but sometimes not.

Description

Example:
"ในฐานข้อมูลกฎหมายของเว็บไซต์ ทส. ข้อมูลและทรัพยากร ข้อมูลกฎหมายว่าด้วยป่าชุมชน CSV downloads กฎหมายแม่บท และกฎหมายลำดับรอง ของพระราชบัญญัติป่าชุมชน พ.ศ. 2562..."

It can correctly tokenize "ข้อมูลกฎหมายว่าด้วยป่าชุมชน" into ['ข้อมูล', 'กฎหมาย', 'ว่าด้วย', 'ป่าชุมชน']

If I changed the input into
"ในฐานข้อมูลกฎหมายของเว็บไซต์ ทส. ข้อมูลและทรัพยากร ข้อมูลกฎหมายว่าด้วยป่าชุมชน CSV downloads กฎหมายแม่บท และกฎหมายลำดับรอง ของพระราชบัญญัติป่าชุมชน พ.ศ. 2562... สำรวจ"

It tokenizes "ข้อมูลกฎหมายว่าด้วยป่าชุมชน" into ['ข้อมูล', 'กฎ', 'หม', 'าย', 'ว่าด้วย', 'ป่าชุมชน']

Expected results

It should produce the same results for both inputs.

Steps to reproduce

from pythainlp.tokenize import word_tokenize
docs = '''ในฐานข้อมูลกฎหมายของเว็บไซต์ ทส. ข้อมูลและทรัพยากร ข้อมูลกฎหมายว่าด้วยป่าชุมชน CSV downloads กฎหมายแม่บท และกฎหมายลำดับรอง ของพระราชบัญญัติป่าชุมชน พ.ศ. 2562... สำรวจ
'''
words = word_tokenize(docs, engine="newmm-safe", keep_whitespace=False)

print(words)

Your environment

  • PyThaiNLP version: 3.1.0
  • Python version: 3.9.7
  • Operating system and version: MacOS
@github-actions
Copy link

github-actions bot commented Nov 2, 2022

Hello @chameleonTK, thank you for your interest in our work!

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

@wannaphong wannaphong added the bug bugs in the library label Nov 2, 2022
@bact bact added this to the Future milestone Feb 22, 2023
@tongplw
Copy link

tongplw commented Aug 16, 2023

https://github.com/PyThaiNLP/pythainlp/blob/dev/pythainlp/tokenize/newmm.py#L193

Adding _TEXT_SCAN_BEGIN to cut_pos could help.
cut_pos = space_idx + 1 + _TEXT_SCAN_BEGIN

@bact
Copy link
Member

bact commented Aug 18, 2023

Thx @chameleonTK for reporting and @tongplw for pointing out possible solution.
Let me take a look at this closely.

@bact bact added the Hacktoberfest for Hacktoberfest event label Oct 4, 2023
@bact bact added this to To do in PyThaiNLP Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs in the library Hacktoberfest for Hacktoberfest event
Projects
PyThaiNLP
  
To do
Development

No branches or pull requests

4 participants