ManiacDC / TypingAid

Word AutoCompletion Utility
http://www.autohotkey.com/board/topic/49517-ahk-11typingaid-v2200-word-autocompletion-utility/
GNU General Public License v3.0
142 stars 45 forks source link

Option to sort by length of the suggestion #84

Open dejavecue opened 7 years ago

dejavecue commented 7 years ago

Hi Maniac and thanks in advance for your great program.

In some languages, German for example, we have what is linguistically called compound nouns. The English 'speed limits' becomes 'Geschwindigkeitsbegrenzung' for example and that leads to a small problem with the program: It does not offer the words in an order that makes a lot of sense for German. If I type 'Gesch', it starts offering me Geschichtswissenschaftlerinnen (!) as the first word, instead of maybe Geschichte.

I realise this may not be super problematic for English-only users, but is there a way to sort suggestion by length, i.e. show shortest first? That would probably make more sense for some languages (I think Turkish might benefit as well) as well as solve problems with plurals being suggested before singulars (in languages that append -s for example).

To be absolutely open, I downloaded a German wordlist.txt and an English wordlist.txt, let the program absorb them both and thus started with a huge database to begin with, so if the error comes from that, you may ignore it (although I think the function would be nice nevertheless)

ManiacDC commented 7 years ago

Welcome!

Sorry for the late response. Funny, this is a feature I added to save keystrokes. Longer words take more typing, so the algorithm favors them. That being said, it was designed with English in mind. I think we could allow this feature to be tweaked or disabled.

Note: This is in TypingAid.AHK in RecomputeMatches:

OrderByQuery .= " end, CASE WHEN count IS NOT NULL then ( (count - " . Normalize . ") * ( 1 - ( '0.75' / (LENGTH(word) - " . WordLen . ")))) end DESC, Word"

You can ignore the "Normalize". Count is the number of times the word has been typed. LENGTH(word) is the length of the word in the list. WordLen is the length of the string you've typed so far.

So if I type 'Gesch' So if the word is Geschichtswissenschaftlerinnen and it's been typed 10x, it would be this: 10 (1- (0.75 /(30-5)) 10 (1 - (.03)) =a weight of 9.7

If the word is Geschichte and it's been typed 15x, it would be this: 15 (1-(0.75/(10-5)) 15 (1-0.15) =a weight of 12.75

As you can see, the weighting has an effect, but not a huge one (unless there's very few letters left to type). It can be lowered further by changing the 0.75 to a lower value. As you type words, the more common ones should take higher priority.

dejavecue commented 7 years ago

Thank you for your reply.

Just to check if I get it right: If I lower the 0.75 value, I give shorter words a higher priority?

Edit: I just realised, I have the precompiled executable, so I cannot change this, right?

ManiacDC commented 7 years ago

Yes, and yes. You'll need to install AutoHotKey and run the TypingAid.ahk script from the source file (you can download it here from github).