Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Some misspelled words not marked as such - RapidSpell Desktop .NET - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
Christian Ebel
#1 Posted : Tuesday, July 12, 2022 2:50:41 PM
Rank: Member

Groups: Registered

Joined: 1/17/2012
Posts: 23
Hi Jim,

the words "eingene", "eingenes", and "eingenen" (usually missspellings of "eigene", "eigenes", and "eigenen") are not marked as misspellings; "eingener" on the other hand is.
None of the words are in the dictionary we are using (German NDE) so we can't just remove them.

What's the deal with those words?

(We are using version 6.2.21.531 with TextControl v29 SP3 and DICT-DE-NDE-GermanRechtschreibreform.dict.)

Regards,
Christian
Jim
#2 Posted : Tuesday, July 12, 2022 5:45:49 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Hi Christian, this is a consequence of the way compound words work with the German dictionary, which is imperfect I am afraid. Essentially it accepts words if the word in question is made up of 2 valid words, eg "ein" + "Gene".

I know that is a somewhat naive approach but we don't have the necessary information in the dictionary (ie verb, adjective etc) to know whether an entry in the dictionary can be used as a compound. The alternative would be to form a dictionary with all the valid compound forms but there are more or less an unending number of words).

I know "eingene" in particular might be common enough that you want to block it, so if you do think having a list of words to never allow would help, then I can show you how.

Regards
Jim
-your feedback is helpful to other users, thank you!


Christian Ebel
#3 Posted : Wednesday, July 13, 2022 3:38:47 PM
Rank: Member

Groups: Registered

Joined: 1/17/2012
Posts: 23
Hi Jim,

as none of the above mentioned cases make any sense in German I'd like to block them.

So if you could show me how to block words that would solve my problem.

Regards,
Christian
Jim
#4 Posted : Wednesday, July 13, 2022 4:01:41 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
This is based on a KB article, so if it doesn't work I can make a new example in a couple of days.

To do it, you can add this class

Code:

    class SChecker : RapidSpellChecker

    {

        protected override bool LookUpMainDictionary(string query)

        {

            if (query == "i") return false;

            else

                return base.LookUpMainDictionary(query);

        }

        protected override bool LookUpUserDictionary(string query)

        {

            if (query == "i") return false;

            else

                return base.LookUpUserDictionary(query);

        }

        protected override System.Collections.ArrayList FindSuggestions(string word, bool searchLowerCase)

        {

            if (word == "i") return new System.Collections.ArrayList(new string[] { "I" });

            else return base.FindSuggestions(word, searchLowerCase);

        }

    }



and then use it like this

Code:

rapidSpellAsYouType1.RapidSpellChecker = new SChecker();

or

rapidSpellDialog1.CheckerEngine = new SChecker();



In this example it is making 'i' into a spelling error, but you can imagine changing the code to disallow any word in your own list.

Hope that works for you.
Jim
-your feedback is helpful to other users, thank you!


Christian Ebel
#5 Posted : Friday, July 15, 2022 4:00:33 PM
Rank: Member

Groups: Registered

Joined: 1/17/2012
Posts: 23
Unfortunately the code only works if CheckCompoundWords is set to false (and for single chars).
Eg for "eingen" query would be
"eingen" --> false
"einge" --> false
"eing" --> false
"ein" --> true
"Gen" --> true

As there is no way to switch off CheckCompoundWords for a single query, I changed the code to this:
Code:
Private Shared Property LookUpOverrides As HashSet(Of String) = New HashSet(Of String)(StringComparer.OrdinalIgnoreCase) From {
    {"eingen"},
    {"eingene"},
    {"eingenes"},
    {"eingenen"}
}

Private Property CurrentWord As String

Protected Overrides Function LookUpMainDictionary(query As String) As Boolean
    If LookUpOverrides.Contains(query) Then
        Me.CurrentWord = query
        Me.CheckCompoundWords = False
        Return False
    End If

    If Not (Me.CurrentWord Is Nothing OrElse query = Me.CurrentWord) Then
        Me.CheckCompoundWords = True
        Me.CurrentWord = Nothing
    End If

    Return MyBase.LookUpMainDictionary(query)
End Function

Protected Overrides Function LookUpUserDictionary(query As String) As Boolean
    If LookUpOverrides.Contains(query) Then
        Me.CurrentWord = query
        Me.CheckCompoundWords = False
        Return False
    End If

    If Not (Me.CurrentWord Is Nothing OrElse query = Me.CurrentWord) Then
        Me.CheckCompoundWords = True
        Me.CurrentWord = Nothing
    End If

    Return MyBase.LookUpUserDictionary(query)
End Function

Is there a better way to do this?

And why do the suggestions for "eingen" not contain "eigen"? I know I could add it to the suggestions myself by overriding FindSuggestions but as it's in the dictionary and has a Levenshtein distance of 1 I find it curious that it's not included.

BTW, what determines the number of items in the context menu? Is there a way to influence that amount?

Regards,
Christian
Jim
#6 Posted : Sunday, July 17, 2022 1:14:22 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
The number of items in the menu is unchangeable I am afraid, but if you'd like to change it we could add it and you can have a new build with that available.

Sorry my suggestion before was not the best, this works

Code:

    class SChecker : RapidSpellChecker
    {
        HashSet<string> overrides = new HashSet<string>(new string[] { "eingen", "eingene", "eingenes", "eingenen" },StringComparer.OrdinalIgnoreCase);


        public override bool FindCompoundWords(string text, IList subwords, bool lengthLimit)
        {
            if (overrides.Contains(text)) return false;
            else return base.FindCompoundWords(text, subwords, lengthLimit);
        }
    }



Suggestions can be improved by setting

Code:

rapidSpellAsYouType1.ConsiderationRange = 5000;


however for 'eigen' in particular it seems to be lost in all the other close suggestions.

Jim
-your feedback is helpful to other users, thank you!


Christian Ebel
#7 Posted : Monday, July 18, 2022 1:16:05 PM
Rank: Member

Groups: Registered

Joined: 1/17/2012
Posts: 23
Wow, I didn't see that function. Thanks, that's much cleaner.

Can you tell me, what detemines the number of suggestions? Is it just a constant?
7 is the highest I've seen so far in the context menu, but FindSuggestions returns a lot more.

And what detemines which suggestions get selected for the context menu?

A property or method to set the number of items in the context menu would be very nice.
Jim
#8 Posted : Tuesday, July 19, 2022 3:44:33 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Yes, it's just a constant, but I will make available a DLL with a settable property - sorry it might not be until Monday.

The order is determined by our algorithm, which is not actually Levenshtein.

-your feedback is helpful to other users, thank you!


Jim
#9 Posted : Wednesday, July 27, 2022 1:28:40 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Here you are, please see the new property NumberOfSuggestionMenuItems in RapidSpellAsYouType

https://www.dropbox.com/t/4oyuy4ThBwQgWtOI


-your feedback is helpful to other users, thank you!


Christian Ebel
#10 Posted : Thursday, July 28, 2022 8:40:44 AM
Rank: Member

Groups: Registered

Joined: 1/17/2012
Posts: 23
Hi Jim,

thanks a lot.

Regards,
Christian
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.