[Solved] Spell check using ONLY custom dictionary

Writing a book, Automating Document Production - Discuss your special needs here

[Solved] Spell check using ONLY custom dictionary

Postby Doranwen » Thu Dec 17, 2020 5:48 am

I suspect this qualifies for "advanced uses" because it's definitely not a typical use situation, but if not, I greatly apologize.
Technical note: I use LibreOffice 5.1.6.2 (I'm on an old LTS version of Linux Mint) but I hope OO and LO are similar enough that a solution for one will work with the other.

I'm wanting to create something similar to the Up Goer Five editor: https://www.splasho.com/upgoer5/
Basically, I'd like to be able to type or paste text in, and have that text automatically be spell-checked against a custom dictionary only, and every word not in that dictionary to be flagged for editing so I can edit it down to make the text match only the words in the dictionary. The red squiggles will be my guide to "oops! I used a word I'm not allowed to" so I know to change it.

I've figured out how to create a custom dictionary, and it seems to be easy enough to dump a list of words in the dic file itself when opened with a text editor (though I suspect I have to restart LO entirely to get it to re-read the dictionary properly because when I open it in the program it doesn't see any new words I added into the dictionary via the text editor). However, when I try to spell check a simple sentence of five words, two of which were not in either list (but are valid words), one of which was in the dictionary before I tried adding words in via text editor, and two more that were added via text editor… it just says spell check complete, and that's that. I tested by adding a nonsense word and it did catch that as a misspelling/typo, so it clearly is using the regular English dictionary that comes with it. Which, in most situations, would be exactly what I want! But here, I want to turn off the use of the regular dictionary and limit it to the custom one only. Is this possible?

I'd be OK with creating a fake language and setting the document to that, but that is beyond my knowledge as well. (I honestly don't care if I even use LibreOffice for this but writing a plugin for gedit or something like that is way beyond my skills, and LO has enough features that I hoped this would be possible.) Everything I've searched everywhere regarding LO turns up pages about either spell check not working period (which is definitely not my problem), or adding a custom dictionary in addition to the regular one, not turning off the regular dictionary and using ONLY the custom one. The only link that turns up anything similar is this Ask LibreOffice question, with an answer that basically says one would need to remove all the words in the standard dictionary, and I don't want to do that for my other documents.
Last edited by Doranwen on Thu Dec 17, 2020 8:53 pm, edited 1 time in total.
LibreOffice 5.1.6.2 on Linux Mint 18.1
Doranwen
 
Posts: 68
Joined: Sun May 26, 2019 6:46 am

Re: Spell check using ONLY custom dictionary

Postby Hagar Delest » Thu Dec 17, 2020 9:11 am

That's an interesting question!

The proposal in the topic you've linked sounds good, except that it was easier at that time, before the dictionaries were packaged as extensions.
  • find and delete the main dictionary file. This might work, or might make the whole program misbehave. If it works, we're done; otherwise
  • replace the main dictionary with an empty file with the same name. If it works, we're done; otherwise
  • replace the main dictionary by a completely different one (Chinese?) renamed to the original name. With luck, it will consider all words in an English document to be misspelt Chinese, unless in the custom dictionary (maybe it will unhelpfully offer a Chinese alternative). If it works, we're done; otherwise

The easiest IMHO would be to install a Chinese or other non western language dictionary, then the trick is to do a custom dictionary but with THAT language setting. Then, set the language of your text to that language too and it should use the non-western standard dictionary that will basically flag all words as misspelled and then use the custom dictionary to approve your own list.

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the *EDIT button if your issue has been fixed.
LibreOffice 7.0.5 on Xubuntu 21.04 and 7.0.5 portable on Windows 10
User avatar
Hagar Delest
Moderator
 
Posts: 29809
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Spell check using ONLY custom dictionary

Postby Doranwen » Thu Dec 17, 2020 9:43 am

I installed the extension for Hindi, figuring it was unlikely any words would match (the trouble with using another language, is that it's possible for small words to match - I hoped Hindi was distinct enough!). While it seemed to install correctly and showed up in the extension manager, even after I rebooted I was unable to set the text to it. The only place where the dropdown allowed me to choose between English and Hindi was in the spell/grammar dialog window, and there I could not actually select anything besides "<None>". In the menus, I could not even see Hindi, though I could choose "More" and be presented with the font formatting dialog - which has a dropdown for language, allowing me to pick from a long list of languages which I do not have dictionaries installed for (but Hindi didn't seem to be one of them). None of it has any effect - it clearly is spell-checking using the standard English dictionary.

The concept made perfect sense, but it doesn't seem to be working in practice… :/

I did figure out how to do something like I wanted with the program KompoZer in a Windows VM. It allowed me to edit the dictionary directly - but the red squiggle under each "misspelled" word is so faint that it's not going to be very easy to use like that, even blown up to large font size. Plus it only works as I type words - it won't automatically underline everything I paste in that doesn't match the dictionary, and I don't want to have to pull up the spell-check dialog all the time, the whole idea is so I can see them in the block of text and edit there. Sigil (also in Windows, the dictionaries seem to be less integrated that way and I can find them to edit, lol - plus I won't need the spellcheck for anything, particularly the German one which I used for this) is somewhat better, allowing direct editing of the Hunspell dictionaries and highlighting misspelled words in code view, though not regular view. If there's no good solution to this using LO I may have to go that route and hope the office developers take note of this unusual case. (It wouldn't be that hard to offer an option to turn off the standard dictionary and use only the custom one, but I'm suspecting no one ever bothered because they never considered someone might *want* to, lol.)
Last edited by Doranwen on Thu Dec 17, 2020 8:12 pm, edited 1 time in total.
LibreOffice 5.1.6.2 on Linux Mint 18.1
Doranwen
 
Posts: 68
Joined: Sun May 26, 2019 6:46 am

Re: Spell check using ONLY custom dictionary

Postby Hagar Delest » Thu Dec 17, 2020 1:57 pm

Well, it seems that the fact that it is a non-western language or a complex layout kind involves different processes.
Try perhaps with a western language that could have as little as possible to do with English. It is just to check. If it works, then you can dig in the extension and blank out the content of the different files. I did not propose that at first (one of the ideas quoted above) because it means there is some digging needed in the extension.
LibreOffice 7.0.5 on Xubuntu 21.04 and 7.0.5 portable on Windows 10
User avatar
Hagar Delest
Moderator
 
Posts: 29809
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Spell check using ONLY custom dictionary

Postby RoryOF » Thu Dec 17, 2020 2:14 pm

I would agree that it is best to modify the dictionary of a Western language if that best suits your needs; in that case I would suggest taking a Western language that you will never use, and editing its dictionary by substituting your own words.
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32665
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Spell check using ONLY custom dictionary

Postby John_Ha » Thu Dec 17, 2020 4:15 pm

See Use only custom dictionaries?, [Solved] Can dictionary get too big? and [Solved] Removing "statue" from base standard dictionary

It is easy to hack a proper dictionary so that all words are flagged as misspelled. Be sure to edit the number of lines at the top to 2.

Removing the dictionary didn't seem work for you so how about editing the dictionary file C:\Users\xxxx\AppData\Roaming\OpenOffice\4\user\uno_packages\cache\uno_packages\sv1glr1s.tmp_\dict-en.oxt\en_GB.dic (my GB English dictionary in W7) so it has only one or two lines containing non-words like qwertyuiop and asdfghjkl. You now have a valid GB dictionary against which the text will be checked and every word except qwertyuiop and asdfghjkl will be flagged as misspelled. You can test to see that you have done it correctly because, if you have, qwertyuiop and asdfghjkl will be shown as being correct.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 8465
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Spell check using ONLY custom dictionary

Postby Bill » Thu Dec 17, 2020 6:50 pm

You can download a dictionary extension for a language the you don't use and modify the extension before installing it. I'm unlikely to use Esperanto, so I tried this:

Download the Esperanto dictionary extension to the Desktop.
Open the downloaded extension file with the Engrampa archive manager.
In the archive manager window, open the .dic file with a text editor.
Delete everything in the .dic file and put "0" (without quotes) on the first line.
Save the file and update it in the archive manager.
Install the modified extension in OpenOffice.

If the document language is set to Esperanto then all words that haven't been added to the custom dictionary will be underlined.
AOO 4.1.10 on Ubuntu MATE 21.04
Bill
Volunteer
 
Posts: 8286
Joined: Sat Nov 24, 2007 6:48 am

Re: Spell check using ONLY custom dictionary

Postby RoryOF » Thu Dec 17, 2020 6:52 pm

Bill

For clarity: why "0" (without quotes)? Is it the count of items in the file?
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32665
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Spell check using ONLY custom dictionary

Postby Bill » Thu Dec 17, 2020 6:57 pm

RoryOF wrote:Bill

For clarity: why "0" (without quotes)? Is it the count of items in the file?

I assume that it is. I haven't found documentation yet, but that was the case for several .dic files that I looked at.
AOO 4.1.10 on Ubuntu MATE 21.04
Bill
Volunteer
 
Posts: 8286
Joined: Sat Nov 24, 2007 6:48 am

Re: Spell check using ONLY custom dictionary

Postby RoryOF » Thu Dec 17, 2020 7:04 pm

There was (maybe is) documentation on the hunspell site, which also had information on using an affix file to handle plurals and possessives.
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32665
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Spell check using ONLY custom dictionary

Postby John_Ha » Thu Dec 17, 2020 7:13 pm

RoryOF wrote:Bill

For clarity: why "0" (without quotes)? Is it the count of items in the file?

Rory
The first line in a standard dictionary file is the number of entries. My GB dictionary has 89,012 lines where the first 100 are as below.

So, if you delete them all, it's presumably zero. I think my method is safer: Delete all except for two dummy entries like qwertyuiop amd asdfghjkl, and set the first line to 2.

Code: Select all   Expand viewCollapse view
89012
'gainst
'mongst
'neath
'strewth
'struth
'tis
'twas
'tween-decks
'twixt
0/#@
0th/}{
1/#0
1024x768
1080i
1080p
1280x720
1280x720p
128K
1366x768
16-bit
16K
1920x1080
1920x1080i
1920x1080p
1D
1st/}
1th/{_
2/#@
24-bit
2D
2nd/}
2th/{_
3/#@
32-bit
320x240
3D
3DES/M
3GPP/M
3rd/}
3th/{_
4/#@
48K
4D
4th/}{
4x4/S
5/#@
5th/}{
6/#@
64-bit
640x480
64K
6th/}{
7/#@
720p
7th/}{
8-bit
8/#@
800x600
8th/}{
9/#@
9th/}{
A
à
A'Chleit/M
A-bomb
A-bombs
A-levels
A-line
a.m.
a/o
A1
A2
A3
A4
A5
AA
AAA
AAC
Aachen/M
AACS/M
aardvark/MS
aardwolf/M
aardwolves/M
aargh
Aarhus/M
Aaron/M
Aaronvitch/M
AB
ab
Ab/M
Ababa/M
aback/SM
abacus/SM
Abadie/M
abaft
abalone/MS
abandon/7LdSr
abandonedly
abandonware/M
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 8465
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Spell check using ONLY custom dictionary

Postby Doranwen » Thu Dec 17, 2020 8:51 pm

Esperanto seemed like a good idea to me as well as I would be highly unlikely to ever use it, so I installed that extension.

I had to do some major hunting to find my extension path, so for any future Linux users, here's where I found it on mine:
Code: Select all   Expand viewCollapse view
/home/username/.config/libreoffice/4/user/uno_packages/cache/uno_packages/lu19211sj2yv8.tmp_/dict-eo.oxt/dictionaries


I went with 3 entries - one for each row of the keyboard: qwertyuiop, asdfghjkl, and zxcvbnm. :D No way will those ever turn up in any text I'm producing.

I was also able to, once I restarted LO entirely, get the assignment of text to Esperanto to work - and it flagged the two words in the five-word sentence that should've been fine with an English editor but were not in the sample dictionary I had created for this. So yay! Just have to make sure I select all the text to start with and assign it to Esperanto and it'll basically use my dictionary only. Thank you very much!
Last edited by Doranwen on Thu Dec 17, 2020 10:55 pm, edited 1 time in total.
LibreOffice 5.1.6.2 on Linux Mint 18.1
Doranwen
 
Posts: 68
Joined: Sun May 26, 2019 6:46 am

Re: [SOLVED] Spell check using ONLY custom dictionary

Postby Bill » Thu Dec 17, 2020 10:07 pm

Some information about the file formats of the dictionary and affix files can be found in section 5 of the Linux man pages. It says that the first line of the dictionary file (.dic) "contains the approximate word count".

Hunspell
AOO 4.1.10 on Ubuntu MATE 21.04
Bill
Volunteer
 
Posts: 8286
Joined: Sat Nov 24, 2007 6:48 am


Return to Advanced Uses

Who is online

Users browsing this forum: No registered users and 2 guests