Re: [PATCH] Allow removing words from the personal dictionary, that weren't previously added

2022-05-15 Thread Jean-Marc Lasgouttes

Le 26/04/2022 à 09:27, Isaac Oscar Gariano a écrit :
I've made the "Remove from personal dictionary" function/context menu 
item work for words that haven't been previously added, but instead are 
in the system-wide dictionary.


Dear Isaac,

Thanks for the patch. Unfortunately, I just realize that you are not on 
the list. To make sure that this feature is correctly tracked, I suggest 
that you either subscribe to the list, or create a ticket at 
www.lyx.org/trac/ and attach your patch and whatever information makes 
sense.


We (not me actually) will look at the feature as soon as possible.

JMarc

I've modified the behaviour so that it will cause the word to be marked 
as incorrectly spelt, regardless of whether it is in the user's personal 
dictionary, or the system-wide dictionary.
I've attached two patches, one that can be applied on the latest release 
branch |2.3.6.1|​, and the other works on the |master|​ branch)


Previously, this only worked for words not in the system-wide 
dictionary, e.g.:


 1. write "ello", it will be red squigglyunderlined
 2. right click and go "Add to personal dictionary"
 3. now the underline will disappear
 4. right click it and go "Remove from personal dictionary"
 5. it will now be red underlined again

Now you can also do:

 1. write "hello"
 2. right click on it, and click "Remove from personal dictionary"
 3. there should now be a red squiggly underline under "hello", i.e. it
is no longer considered a word

(The above also works with the corresponding lyx-functions 
|spelling-add|​ and |spelling-remove|​)
It might be better to change the text of the context menu button, e.g., 
"Add to personal bad words list" or something, but then it'd need to be 
translated



The main use cases I have for this feature are:

 1. removing rare words that are common misspellings, e.g., if you often
write "whet" instead of "wet", you can mark the former as invalid.
 2. ensure you consistently use the same variant of a word , e.g., make
"spelled" an error if you prefer "spelt" (the latter being a word in
the en_GB dictionary)

This change is backwards compatible: any words you had previously added 
to the personal dictionary will still be recognised.


I have fully tested this on Linux (specifically OpenSUSE Tumbleweed, 
with Aspell v0.60.8, Enchant v2.2.15, and, Hunspell 1.7.0), and Windows 
11 (using the included Hunspell v1.6.2), I don't have a Mac so I can't 
test the AppleSpeller/Native backend.


How it works:

  *
Enchant already supports this feature out of the box, so I didn't
need to change the backend at all, all I needed to do was to make
the "Remove from personal dictionary" context menu button show up
for all correctly spelt words (and not just those in the personal
dictionary).
Specifically, enchant uses two files |~/.config./enchant/.dic|
​ and |~/.config/enchant/.exc|​ to store the personal
dictionary. The former contains all words that you have clicked "Add
to personal dictionary", and the latter uses all that you have
clicked "Remove from personal dictionary" for.
Note that words are added to |.dic|​ and |.exc|​ even if unnecessary
(because the word is in the system-wide dictionary, or not in it,
respectively).
The ".exc" file appears to take precedence over |.dic|​, so if a
word is in both, it is considered misspelt.
  * Aspell and Hunspell currently uses a file
|$LYX_USERDIR/pwl_.dict|​ to store words you have clicked "Add
to personal dictionary" for. LyX now also uses the
|$LYX_USERDIR/pwl_.excl|​ file for words you have "Remove from
personal dictionary". For consistency, my code treats these files
like the enchant |.dic|​ and |.exc|​ files above, specifically the
|.excl|​ file takes precedence of the |.dict|​ file, and words may
be added to these files even if redundant/unnecessary.
The Hunspell backend already natively supports removing words from
the dictionary at runtime, however Aspell does not, so after spell
checking a word, my code manually checks for it's presence in the
|.excl|​ list, which I have not optimised at all, and so it is an
O(/n/) operation, where /n/ is the number of words in the |.excl|​ file.
AppleSpeller/Native: this may work out of the box like Enchant, or
not. I have no idea, as I can't test it and the documentation is
unhelpful (e.g.

https://developer.apple.com/documentation/appkit/nsspellchecker/1525147-unlearnword

)

Note: I have deleted |LEARNED_WORD|​ from the |SpellChecker::Result|​ 
enum, as the code no longer distinguishes between words in the personal 
dictionary and the base dictionary. I also removed the |ROOT_FOUND|​, 
|COMPOUND_WORD|​, and |IGNORED_WORD|​ variants as they were never used.


For the master branch, I haven't modified the "Remove from document 
dictionary" option to also work 

Re: [PATCH] Allow removing words from the personal dictionary, that weren't previously added

2022-05-15 Thread Jürgen Spitzmüller
Am Sonntag, dem 15.05.2022 um 15:58 +0200 schrieb Jean-Marc Lasgouttes:
> Le 26/04/2022 à 09:27, Isaac Oscar Gariano a écrit :
> > I've made the "Remove from personal dictionary" function/context
> > menu 
> > item work for words that haven't been previously added, but instead
> > are 
> > in the system-wide dictionary.
> 
> Juergen,
> 
> Did you have time to look at this patch?

Unfortunately not yet. It is marked in my inbox, but I didn't find the
time to look at it, and it will probably take me some more time to do
so.

-- 
Jürgen


signature.asc
Description: This is a digitally signed message part
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [PATCH] Allow removing words from the personal dictionary, that weren't previously added

2022-05-15 Thread Stephan Witt
Am 26.04.2022 um 09:27 schrieb Isaac Oscar Gariano :
> 
> I've made the "Remove from personal dictionary" function/context menu item 
> work for words that haven't been previously added, but instead are in the 
> system-wide dictionary.
> I've modified the behaviour so that it will cause the word to be marked as 
> incorrectly spelt, regardless of whether it is in the user's personal 
> dictionary, or the system-wide dictionary.
> I've attached two patches, one that can be applied on the latest release 
> branch 2.3.6.1​, and the other works on the master​ branch)
> 
> Previously, this only worked for words not in the system-wide dictionary, 
> e.g.:
>   • write "ello", it will be red squiggly underlined
>   • right click and go "Add to personal dictionary"
>   • now the underline will disappear
>   • right click it and go "Remove from personal dictionary"
>   • it will now be red underlined again
> Now you can also do:
>   • write "hello"
>   • right click on it, and click "Remove from personal dictionary"
>   • there should now be a red squiggly underline under "hello", i.e. it 
> is no longer considered a word
> (The above also works with the corresponding lyx-functions spelling-add​ and 
> spelling-remove​)
> It might be better to change the text of the context menu button, e.g., "Add 
> to personal bad words list" or something, but then it'd need to be translated
> 
> 
> The main use cases I have for this feature are:
>   • removing rare words that are common misspellings, e.g., if you often 
> write "whet" instead of "wet", you can mark the former as invalid.
>   • ensure you consistently use the same variant of a word , e.g., make 
> "spelled" an error if you prefer "spelt" (the latter being a word in the 
> en_GB dictionary)
> This change is backwards compatible: any words you had previously added to 
> the personal dictionary will still be recognised.
> 
> I have fully tested this on Linux (specifically OpenSUSE Tumbleweed, with 
> Aspell v0.60.8, Enchant v2.2.15, and, Hunspell 1.7.0), and Windows 11 (using 
> the included Hunspell v1.6.2), I don't have a Mac so I can't test the 
> AppleSpeller/Native backend.
> 
> How it works:
> 
>   • Enchant already supports this feature out of the box, so I didn't 
> need to change the backend at all, all I needed to do was to make the "Remove 
> from personal dictionary" context menu button show up for all correctly spelt 
> words (and not just those in the personal dictionary).
> Specifically, enchant uses two files ~/.config./enchant/.dic​ and 
> ~/.config/enchant/.exc​ to store the personal dictionary. The former 
> contains all words that you have clicked "Add to personal dictionary", and 
> the latter uses all that you have clicked "Remove from personal dictionary" 
> for.
> Note that words are added to .dic​ and .exc​ even if unnecessary (because the 
> word is in the system-wide dictionary, or not in it, respectively).
> The ".exc" file appears to take precedence over .dic​, so if a word is in 
> both, it is considered misspelt.
>   • Aspell and Hunspell currently uses a file 
> $LYX_USERDIR/pwl_.dict​ to store words you have clicked "Add to 
> personal dictionary" for. LyX now also uses the$LYX_USERDIR/pwl_.excl​ 
> file for words you have "Remove from personal dictionary". For consistency, 
> my code treats these files like the enchant .dic​ and .exc​ files above, 
> specifically the .excl​ file takes precedence of the .dict​ file, and words 
> may be added to these files even if redundant/unnecessary.
> The Hunspell backend already natively supports removing words from the 
> dictionary at runtime, however Aspell does not, so after spell checking a 
> word, my code manually checks for it's presence in the .excl​ list, which I 
> have not optimised at all, and so it is an O(n) operation, where n is the 
> number of words in the .excl​ file.
> AppleSpeller/Native: this may work out of the box like Enchant, or not. I 
> have no idea, as I can't test it and the documentation is unhelpful (e.g. 
> https://developer.apple.com/documentation/appkit/nsspellchecker/1525147-unlearnword)
> Note: I have deleted LEARNED_WORD​ from the SpellChecker::Result​ enum, as 
> the code no longer distinguishes between words in the personal dictionary and 
> the base dictionary. I also removed the ROOT_FOUND​, COMPOUND_WORD​, and 
> IGNORED_WORD​ variants as they were never used.
> 
> For the master branch, I haven't modified the "Remove from document 
> dictionary" option to also work with words not in said dictionary; I'd have 
> to modify the LyX file format to support a \spellchecker_reject​ or something 
> like, but I can probably work out how to do that if you're happy with the 
> idea.

Hi Isaac,

thank you for your work on LyX.

I’ve tried your patch and unfortunately it doesn’t work on Mac.

Despite the fact that it relies on the existence of the LEARNED_WORD in the 
SpellChecker::Result enum there is IMO a problem 

Re: [PATCH] Allow removing words from the personal dictionary, that weren't previously added

2022-05-15 Thread Jean-Marc Lasgouttes

Le 26/04/2022 à 09:27, Isaac Oscar Gariano a écrit :
I've made the "Remove from personal dictionary" function/context menu 
item work for words that haven't been previously added, but instead are 
in the system-wide dictionary.


Juergen,

Did you have time to look at this patch?

JMarc

I've modified the behaviour so that it will cause the word to be marked 
as incorrectly spelt, regardless of whether it is in the user's personal 
dictionary, or the system-wide dictionary.
I've attached two patches, one that can be applied on the latest release 
branch |2.3.6.1|​, and the other works on the |master|​ branch)


Previously, this only worked for words not in the system-wide 
dictionary, e.g.:


 1. write "ello", it will be red squigglyunderlined
 2. right click and go "Add to personal dictionary"
 3. now the underline will disappear
 4. right click it and go "Remove from personal dictionary"
 5. it will now be red underlined again

Now you can also do:

 1. write "hello"
 2. right click on it, and click "Remove from personal dictionary"
 3. there should now be a red squiggly underline under "hello", i.e. it
is no longer considered a word

(The above also works with the corresponding lyx-functions 
|spelling-add|​ and |spelling-remove|​)
It might be better to change the text of the context menu button, e.g., 
"Add to personal bad words list" or something, but then it'd need to be 
translated



The main use cases I have for this feature are:

 1. removing rare words that are common misspellings, e.g., if you often
write "whet" instead of "wet", you can mark the former as invalid.
 2. ensure you consistently use the same variant of a word , e.g., make
"spelled" an error if you prefer "spelt" (the latter being a word in
the en_GB dictionary)

This change is backwards compatible: any words you had previously added 
to the personal dictionary will still be recognised.


I have fully tested this on Linux (specifically OpenSUSE Tumbleweed, 
with Aspell v0.60.8, Enchant v2.2.15, and, Hunspell 1.7.0), and Windows 
11 (using the included Hunspell v1.6.2), I don't have a Mac so I can't 
test the AppleSpeller/Native backend.


How it works:

  *
Enchant already supports this feature out of the box, so I didn't
need to change the backend at all, all I needed to do was to make
the "Remove from personal dictionary" context menu button show up
for all correctly spelt words (and not just those in the personal
dictionary).
Specifically, enchant uses two files |~/.config./enchant/.dic|
​ and |~/.config/enchant/.exc|​ to store the personal
dictionary. The former contains all words that you have clicked "Add
to personal dictionary", and the latter uses all that you have
clicked "Remove from personal dictionary" for.
Note that words are added to |.dic|​ and |.exc|​ even if unnecessary
(because the word is in the system-wide dictionary, or not in it,
respectively).
The ".exc" file appears to take precedence over |.dic|​, so if a
word is in both, it is considered misspelt.
  * Aspell and Hunspell currently uses a file
|$LYX_USERDIR/pwl_.dict|​ to store words you have clicked "Add
to personal dictionary" for. LyX now also uses the
|$LYX_USERDIR/pwl_.excl|​ file for words you have "Remove from
personal dictionary". For consistency, my code treats these files
like the enchant |.dic|​ and |.exc|​ files above, specifically the
|.excl|​ file takes precedence of the |.dict|​ file, and words may
be added to these files even if redundant/unnecessary.
The Hunspell backend already natively supports removing words from
the dictionary at runtime, however Aspell does not, so after spell
checking a word, my code manually checks for it's presence in the
|.excl|​ list, which I have not optimised at all, and so it is an
O(/n/) operation, where /n/ is the number of words in the |.excl|​ file.
AppleSpeller/Native: this may work out of the box like Enchant, or
not. I have no idea, as I can't test it and the documentation is
unhelpful (e.g.

https://developer.apple.com/documentation/appkit/nsspellchecker/1525147-unlearnword

)

Note: I have deleted |LEARNED_WORD|​ from the |SpellChecker::Result|​ 
enum, as the code no longer distinguishes between words in the personal 
dictionary and the base dictionary. I also removed the |ROOT_FOUND|​, 
|COMPOUND_WORD|​, and |IGNORED_WORD|​ variants as they were never used.


For the master branch, I haven't modified the "Remove from document 
dictionary" option to also work with words not in said dictionary; I'd 
have to modify the LyX file format to support a |\spellchecker_reject|​ 
or something like, but I can probably work out how to do that if you're 
happy with the idea.


— Isaac Oscar Gariano​



--
lyx-devel mailing list
lyx-devel@lists.lyx.org