Bug 163346 - AutoCorrect Options; when the word "บรเพ็ชร" is entered, it becomes "บรเพชร"
Summary: AutoCorrect Options; when the word "บรเพ็ชร" is entered, it becomes "บรเพชร"
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.8.1.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Theppitak Karoonboonyanan
URL:
Whiteboard: target:25.2.0 target:24.8.3
Keywords:
Depends on:
Blocks: AutoCorrect-Complete
  Show dependency treegraph
 
Reported: 2024-10-08 10:25 UTC by jteera5
Modified: 2024-10-28 10:50 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jteera5 2024-10-08 10:25:02 UTC
When the word บรเพ็ชร is entered (typed) into a cell, it becomes บรเพชร.

บรเพ็ชร can be copied from another cell correctly. The original บรเพ็ชร was an old entry entered with an older version of LibreOffice.

The text บรเพ็ชร can be copied into a cell that's not in edit mode. If it's in edit mode บรเพ็ชร becomes บรเพชร after pressing Enter, Tab or space bar.
Comment 1 jteera5 2024-10-08 10:27:53 UTC
The problem occurs with or without Hunspell Spellchecker enabled.
No Thai Dictionary was loaded.
Comment 2 jteera5 2024-10-08 10:29:45 UTC
Same problem with the word เพ็ชร.
Comment 3 Julien Nabet 2024-10-08 18:44:47 UTC
Could you try to rename your LO directory profile? (see https://wiki.documentfoundation.org/QA/FirstSteps#Corrupted_user_profile)
Comment 4 ady 2024-10-08 20:32:08 UTC
Which font are you using in the specific cell where this problem is seen?

Please open the Fonts folder of your OS; is the specific font listed as installed in that Font folder? Please note that the fact that LO lists the font within its own UI does not necessarily imply that the specific font is actually installed in your OS.

What happens if you change the font of a specific cell and start the procedure again (i.e. typing-in the intended word from scratch on a new cell with a different font)? Is the problem present with _every_ font (i.e. on each test, start the original procedure again, on a new cell with a different font before you start typing the intended text in that cell)?

This should also be tested with a recent daily master alpha (LO 25.2, ATM).
Comment 5 jteera5 2024-10-10 10:01:53 UTC
(In reply to Julien Nabet from comment #3)
> Could you try to rename your LO directory profile? (see
> https://wiki.documentfoundation.org/QA/FirstSteps#Corrupted_user_profile)

I renamed the C:\Users\Teerapon\AppData\Roaming\LibreOffice\4 and restarted LO, it created a new profile folder. The problem still exists.
Comment 6 jteera5 2024-10-10 10:04:29 UTC
(In reply to ady from comment #4)
> Which font are you using in the specific cell where this problem is seen?
> 
> Please open the Fonts folder of your OS; is the specific font listed as
> installed in that Font folder? Please note that the fact that LO lists the
> font within its own UI does not necessarily imply that the specific font is
> actually installed in your OS.

The font I used is Angsana New which is a standard Windows Thai font. The font is present in C:\Windows\Fonts as angsana.ttc.

> 
> What happens if you change the font of a specific cell and start the
> procedure again (i.e. typing-in the intended word from scratch on a new cell
> with a different font)? Is the problem present with _every_ font (i.e. on
> each test, start the original procedure again, on a new cell with a
> different font before you start typing the intended text in that cell)?
> 

I changed the font of a specific cell to Tahoma and typed เพ็ชร and the word changed to เพชร as soon as I type space or Enter.
I started over on a new cell with some other fonts. The problem is present with Microsoft Sans Serif, Arial and Browallia New (another standard Windows Thai font). All font files are in C:\Windows\Fonts as micross.ttf, arial.ttf and browalia.ttc.

> This should also be tested with a recent daily master alpha (LO 25.2, ATM).
I couldn't find LO 25.2, so I tested with LO 24.8.2.1 (x86_64) which is the latest on LO download page.
Comment 7 ady 2024-10-10 18:40:19 UTC
(In reply to jteera5 from comment #6)

> I couldn't find LO 25.2, so I tested with LO 24.8.2.1 (x86_64) which is the
> latest on LO download page.

Please see <https://wiki.documentfoundation.org/Testing_Daily_Builds>


Additional points to test would be under menu Tools:

* Autoinput;
* Autocorrect Options (e.g. some wrongly-introduced "Replace");
* Auto-redact.

It might be worth testing what happens if _no_ dictionary at all is enabled (not even a custom dictionary).

Perhaps someone in the Localized users mailing list might be able to replicate the problem (or report that they do not reproduce it), or in <https://ask.libreoffice.org> (for the adequate language).
Comment 8 ady 2024-10-10 18:42:54 UTC
JIC, please try LO > menu Help > Restart in Safe mode > Continue in safe mode. Then repeat the original procedure, introducing the intended text in a cell and checking whether the problem is still reproduced.
Comment 9 jteera5 2024-10-12 09:14:38 UTC
(In reply to ady from comment #7)
> (In reply to jteera5 from comment #6)
> 
> > I couldn't find LO 25.2, so I tested with LO 24.8.2.1 (x86_64) which is the
> > latest on LO download page.
> 
> Please see <https://wiki.documentfoundation.org/Testing_Daily_Builds>
> 
> 
> Additional points to test would be under menu Tools:
> 
> * Autoinput;
> * Autocorrect Options (e.g. some wrongly-introduced "Replace");
> * Auto-redact.
> 
> It might be worth testing what happens if _no_ dictionary at all is enabled
> (not even a custom dictionary).
> 
> Perhaps someone in the Localized users mailing list might be able to
> replicate the problem (or report that they do not reproduce it), or in
> <https://ask.libreoffice.org> (for the adequate language).

I installed LO 25.2 and in Autocorrect Options, I found and entry to replace .*เพ็ชร.* with เพชร. After I deleted the entry the problem disapppeared.

The words เพชร and เพ็ชร are both used in Thai language. While เพชร is the correct spelling. เพ็ชร is also used in many names. I think the entry should be removed from future LO installation file. In the meantimes I will remove the entry from my LO installations.
Thank you very much.
Comment 10 Julien Nabet 2024-10-12 10:00:17 UTC
Ok I found the replacement for เพ็ชร here:
https://opengrok.libreoffice.org/xref/core/extras/source/autocorr/lang/th/DocumentList.xml?r=4c91770d#428

I haven't found one for "บรเพ็ชร".

Autocorrect entries added with 4c91770dde40d248af736436716994dc367a54a2
Add Thai AutoCorrect data
As part of tdf#158454

Ilmari: I put you in cc because I couldn't cc Theppitak Karoonboonyanan
Comment 11 Buovjaga 2024-10-12 10:33:09 UTC
(In reply to Julien Nabet from comment #10)
> Ok I found the replacement for เพ็ชร here:
> https://opengrok.libreoffice.org/xref/core/extras/source/autocorr/lang/th/
> DocumentList.xml?r=4c91770d#428
> 
> I haven't found one for "บรเพ็ชร".
> 
> Autocorrect entries added with 4c91770dde40d248af736436716994dc367a54a2
> Add Thai AutoCorrect data
> As part of tdf#158454
> 
> Ilmari: I put you in cc because I couldn't cc Theppitak Karoonboonyanan

I found Theppitak.
Comment 12 Theppitak Karoonboonyanan 2024-10-12 15:56:00 UTC
Indeed, proper names can be exceptions to many typos. Here's why:

For people who are not speaking Thai, even "บรเพ็ชร" itself is considered a typo
of "บอระเพ็ด". But I guess this must be some surname with old-style spelling.
"เพ็ชร" and even "เพ็ชร์" are also common typos. And many proper names are based on
common typos, which could potentially introduce more removals of AutoCorrect
patterns in the future.

While I'm OK with the removal in this case, I'd say do expect more to come.
Comment 13 Theppitak Karoonboonyanan 2024-10-14 05:27:39 UTC
Proposed gerrit commit to remove AutoCorrect pattern for "เพ็ชร":
https://gerrit.libreoffice.org/c/core/+/174878
Comment 14 Commit Notification 2024-10-14 09:28:52 UTC
Theppitak Karoonboonyanan committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7001d61fd7dc2dae5b8458b6d504cafb61fb2c76

tdf#163346 Remove Thai AutoCorrect for "เพ็ชร"

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Commit Notification 2024-10-14 14:15:49 UTC
Theppitak Karoonboonyanan committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/c9e604d2acc8e10f2e78c2be2924b4415c49642f

tdf#163346 Remove Thai AutoCorrect for "เพ็ชร"

It will be available in 24.8.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Theppitak Karoonboonyanan 2024-10-17 05:37:53 UTC
To check for other possible cases, I have tried 10,000 out of 500,000 Thai
personal names from lexicon-thai database [1], with courtesy of the PyThaiNLP 
project.

[1] https://github.com/PyThaiNLP/lexicon-thai/blob/master/thai-name/ThaiName_1_to_500000.txt

Here are the cases I have found in addition to the correction of "เพ็ชร":
- เกษร
- พานิช/วานิช/พานิชย์/วานิชย์
- รังษี
- รัสมี
- กังวาล
- ไข่มุกด์
- คำนวน
- คำภีร์
- จำนงค์
- ดำรงค์
- ดำริห์
- ธำรงค์
- สถิตย์
- สังวาลย์
- สำอางค์
- สิงห์โต
- ชะอุ่ม
- พยอม
- สพาน
- ตำหรับ
- บรรเทิง
- ผาสุข
- พิศดาร
- สังเกตุ
- กอร์ป
- ลำใย
- สังวรณ์
- อารมย์
- พุดตาล
- ชมภู่
- ไตรยางค์
- นาฑี
- เอนก

Most are very common typos, whose corrections are useful for general writings.

However, some cases can be considered too aggressive, as they can cause
false corrections for longer strings:

- เกษร -> เกสร; which falsely corrects another proper name เกษรา to เกสรา
- เอนก -> อเนก; which falsely corrects a phrase เอนกาย to อเนกาย

These two should be removed anyway.

For others, it could be discussed how to cope with them.

And more cases can be discovered as I try more names.
Comment 17 Theppitak Karoonboonyanan 2024-10-23 04:38:49 UTC
For the second lot of proper names, additional cases found are:

- บรรลือ
- จักร์
- ปาริชาติ
- เวียงจันทร์
- อุกฤษฎ์ (with ฎ [DO CHADA], not ฏ [TO PATAK])
- พิบูลย์
- เพิ่มพูล
- ปราณีต
- ธุระกิจ
- คธา (*)
- ชีวะประวัติ
- พรรณา (*)
- ลาวัลย์
- ปักษิณ

(*) Mandatory cases are
- คธา (wrongly correcting "โคธา" to "โคทา")
- พรรณา (arguably a valid Sanskrit-based transformation of "พรรณ")

However, having skimmed through bug#155087 for Romanian AutoCorrect problems,
I now think _all_ corrections for spelling variations should be removed
and let spell checker does it job. Only simple corrections like basic input 
sequence of combining characters and common obvious errors like "ฤา -> ฤๅ" 
should be done.
Comment 18 Theppitak Karoonboonyanan 2024-10-24 09:28:58 UTC
(In reply to Theppitak Karoonboonyanan from comment #17)
 
> However, having skimmed through bug#155087 for Romanian AutoCorrect problems,
> I now think _all_ corrections for spelling variations should be removed
> and let spell checker does it job.

I'm also questioning this approach, as certain classes of common typos are not 
caught by the spell checker, such as those with usage of wrong homonyms, or 
those that happen to be composable into valid words although the combined words
either mean different things or are just meaningless.

Some examples I found from sample data:

กระพง (กระ + พง)
กระเหรี่ยง (กระ + เห + รี่ + ยง)
กาชาติ (กา + ชาติ)
กินนรี (กิน + นรี)
ไข่มุข (ไข่ + มุข)
คริสต์กาล (คริสต์ + กาล)
คริสต์จักร (คริสต์ + จักร)
คุรุภัณฑ์ (คุรุ + ภัณฑ์)
จรเข้ (จร + เข้)
จักรสาน (จักร + สาน)
จารไน (จาร + ไน)
เจียรนัย (เจียร + นัย)
ฉะเพาะ (ฉะ + เพาะ)
ชีวะประวัติ (ชีวะ + ประวัติ)
ดอกจันท์ (ดอก + จันท์)
ดอกจันทน์ (ดอก + จันทน์)
ดอกจันทร์ (ดอก + จันทร์)
ดำหริ (ดำ + หริ)
ไตรยางค์ (ไต + รยางค์)
ทารุน (ทา + รุน)
เทิดทูล (เทิด + ทูล)
ธุระกิจ (ธุระ + กิจ)
นัยยะ (นัย + ยะ)
นิเทศน์ (นิ + เทศน์)
บันทัด (บัน + ทัด)
ปฏิมากรรม (ปฏิมากร + รม) -- the correct spelling is ประติมากรรม
ประกายพฤกษ์ (ประกาย + พฤกษ์)
ประจัญบาล (ประจัญ + บาล) -- correct: ประจัญบาน (wrong homonym)
ประจัญหน้า (ประจัญ + หน้า) -- correct: ประจันหน้า (wrong homonym)
ประจันบาน (ประจัน + บาน) -- correct: ประจัญบาน (wrong homonym)
ประจันบาล (ประจัน + บาล) -- correct: ประจัญบาน (wrong homonym)
ปราชญ์เปรื่อง (ปราชญ์ + เปรื่อง) -- correct: ปราดเปรื่อง
ผลานิสงค์ (ผลา + นิ + สงค์)
ผลานิสงฆ์ (ผลา + นิ + สงฆ์)
ผูกพันธ์ (ผูก + พันธ์)
พงพันธุ์ (พง + พันธุ์)
พะยุง (พะ + ยุง)
พาหุรัต (พาหุ + รัต)
พาหุรัตน์ (พาหุ + รัตน์)
พิศมัย (พิศ + มัย)
พิศวาท (พิศ + วาท)
พุดตาล (พุด + ตาล)
พุทธชาติ (พุทธ + ชาติ)
เพริดพราย (เพริด + พราย) -- correct: เพริศพราย (wrong homonym)
เพริดพริ้ง (เพริด + พริ้ง) -- correct: เพริศพริ้ง (wrong homonym)
เพริดแพร้ว (เพริด + แพร้ว) -- correct: เพริศแพร้ว (wrong homynym)
เพรียบพร้อม (เพรียบ + พร้อม) -- correct: เพียบพร้อม (improper homonym)
เพิ่มพูล (เพิ่ม + พูล) -- correct: เพิ่มพูน (wrong homonym)
โพธิ์ดำ (โพธิ์ + ดำ) -- correct: โพดำ
โพธิ์แดง (โพธิ์ + แดง) -- correct: โพแดง
โพธิ์ทะเล (โพธิ์ + ทะเล) -- correct: โพทะเล
ภู่กัน (ภู่ + กัน)
ภู่ระหง (ภู่ + ระหง)
มงกุฎราชกุมาร (มงกุฎ + ราชกุมาร) -- correct: มกุฎราชกุมาร
รนรงค์ (รน + รงค์)
ลาวัลย์ (ลา + วัลย์)
สมดุลย์ (สม + ดุลย์)
สมเพท (สม + เพท)
สมเพศ (สม + เพศ)
สมเพส (สม + เพส)
สรรเพชร (สรร + เพชร)
สะบาย (สะ + บาย)
สะบู่ (สะ + บู่)
สัตรู (สัต + รู)
สันฐาน (สัน + ฐาน)
สิงห์โต (สิงห์ + โต)
สีสรร (สี + สรร)
สีสรรค์ (สี + สรรค์)
สีสวาท (สี + สวาท)
สุขคติ (สุค + คติ)
อธิฐาน (อธิ + ฐาน)
อานิสงค์ (อา + นิ + สงค์)
อานิสงฆ์ (อา + นิ + สงฆ์)
อารมย์ (อา + รมย์)
อินธนู (อิน + ธนู)
อิสระภาพ (อิสระ + ภาพ)

All of these can be corrected with AutoCorrect. If we are to remove them
to allow proper names, I wonder if it's possible to cope with them with
the spell checker.
Comment 19 Theppitak Karoonboonyanan 2024-10-28 10:50:32 UTC
Some of the typos uncaught by the spell checker might be caused by inclusion of spelling variations taken from libthai data, where some common typos are provided to tolerate misspelled words in word segmentation.

I've filed bug#163657 to remove them.