Commit Graph

229 Commits (1c6693a219d546816d70fd092f887b73a8041ea3)

Author SHA1 Message Date
Jean Chalard 1c6693a219 Refactoring for whitelist (A83)
Avoid special casing the whitelist dictionary by having it implement
the interface it pretends it implements

Change-Id: I8b873cb0f3fe13cefd32c8cb756a25c8ae16a2b4
2012-07-10 18:05:20 +09:00
Jean Chalard fb6eeeb35a Refactoring (A82)
The user history dictionary should be the one knowing it does not suggest words
beyond 2 characters, not Suggest.

Change-Id: Ie85ec6116eb495e0c7f51108e4620c5ae536f4bf
2012-07-10 18:05:20 +09:00
Jean Chalard 966efe4889 Fix a bug with suggestion behavior (A81)
Bug: 6788235
Change-Id: I5a4212872e0fd3f9e80168fd3abd5c2b3bc4110f
2012-07-10 18:05:19 +09:00
Jean Chalard e9a86e2cdb Search bigrams for the lower case version of the word (A46)
...if there aren't any for the exact case version.

Bug: 6752830
Change-Id: I2737148b01ba04a64febe009ceb2ef53c265d224
2012-07-04 20:12:58 +09:00
Jean Chalard c5e911c06b Consolidate a method inside another (A45)
It's simpler to check the safety net directly inside the
function that checks for auto-correction threshold.

This introduces one very slight change in behavior. The value
checked by the safety net is not any more the "typed word" but the
"considered word", the difference being any possibly appended
single quotes.
E.g. the user types "this'''" : the typed word is "this'''" but
the considered word is "this".
This change in behavior can be considered a bugfix.

Change-Id: Ia7ab4bc933183dfbd41bb00328e4c0b5ab76bc63
2012-07-04 11:51:51 +09:00
Jean Chalard f72b8f5662 Move the safety net function to AutoCorrection (A44)
Change-Id: Iec791d061f237f60992dd6048c4a37b46f4cb9aa
2012-07-04 11:51:46 +09:00
Jean Chalard 4ca05e2474 Refactoring (A43)
Change-Id: Ib0b6f36999518096819ada2f19365767cb5f9931
2012-07-02 15:46:11 +09:00
Jean Chalard 7ad088a4cf Remove useless code (A42)
If allowsAutoCorrected is false, there is no point in making
hasAutoCorrection true, since in the only place where we use
it again, it's &&'ed with allowsAutoCorrected !

Well that was extremely obscure, good thing refactoring allowed
to realize this was useless >.>

Change-Id: I34936d445f1ced17c7bd04a9524bf608f9e8b9c8
2012-07-02 15:46:08 +09:00
Jean Chalard 90d300c770 Clarify some code and fix a bug (A41)
The test against hasMainDictionary is a test to know if we should
auto-correct or not. Its result should be recorded in
hasAutoCorrection, not in allowsToBeAutoCorrected.

Actually, this value being inserted in allowsToBeAutoCorrected was
causing a bug that nobody noticed: when typing in a language with
no dictionary, the word in the middle of the suggestion strip would
always be bold, as if it was going to auto-correct to itself !
This change fixes this bug.

Change-Id: Ia1f08efd7089b9c5cbede910c5b0951d83e698d2
2012-07-02 15:46:03 +09:00
Jean Chalard 2631e3b195 Small refactoring (A39)
Change-Id: I3c45b5a6571f986acc7adb3a8fe17b210303f7ea
2012-07-02 15:45:58 +09:00
Jean Chalard 79f5317848 Match calls for future consolidation (A38)
Change-Id: I2b2ab99e801fa8b4b30eab16a8aefb8cfe104ba9
2012-07-02 15:45:54 +09:00
Jean Chalard cd288620ea Make the autocorrection scheme more straightforward (A37)
Change-Id: I4833ca7e057b8c1f1f22390673cbca0d2433b1bd
2012-07-02 15:45:34 +09:00
Jean Chalard 9011b89f4e Remove cruft (A32)
Change-Id: I35c2ba4caf6be4ba0449e11c0597ae8e468c0e6e
2012-06-29 17:00:57 +09:00
Jean Chalard 2cda148fd5 Simplification (A31)
Change-Id: I9e4d030974ccec1a6256de6ca87610870e404149
2012-06-29 17:00:57 +09:00
Jean Chalard deb2d88245 Small refactoring (A30)
Change-Id: I41b413986a3c5bb6697bb7bbced17ed1e361913c
2012-06-29 17:00:57 +09:00
Jean Chalard 0a63111821 Remove a useless parameter (A29)
Change-Id: I52625e707abf61da9b95e542f0814c66b532f483
2012-06-29 17:00:56 +09:00
Jean Chalard 9e0af57736 Optimization (A26)
Change-Id: I1d7790289635729645995fb8c38868259ab1b3be
2012-06-29 17:00:56 +09:00
Jean Chalard 7a94cbd2a4 Remove useless code (A25)
isWhitelistedOrNotAWord takes an 'ignoreCase' argument. By looking
at the contents of the wordcomposer here, there is only one case
where its output will be different : when the word is typed with a
capital, but the lower case version exists in the dictionary.
E.g. the user typed "This".

In this case, isWhitelistedOrNotAWord in line 235 will return false
instead of true, so the test will score a true instead of a false,
so hasAutoCorrection may be true instead of false in this specific
case and that's the only case where it's different.

But in this case, allowsToBeAutoCorrected is certain to be false,
which means the result will not have changed if hasAutoCorrection
was true in the first place. So in the end this change is sure not
to change the behavior.

Change-Id: Ic41cf959c20c19165f84d9b8ff006731fa595d84
2012-06-29 16:57:56 +09:00
Jean Chalard b3cfde2cbb Add a few comments for future reference (A24)
Change-Id: Ia356130b8a95ec9cf676bc6be05d801c13f14b64
2012-06-29 15:45:27 +09:00
Jean Chalard e398c6c024 Rename a method for readability (A23)
Change-Id: I6f569322e645d36bc82fddf4ec2fd621972e3b47
2012-06-29 15:45:24 +09:00
Jean Chalard ea578f6b1d Revert a test for readability (A22)
Change-Id: I1df4cef5ae2736a22273843dce67f0012181bfd3
2012-06-29 15:44:55 +09:00
Jean Chalard 19d02c19d0 Remove a useless variable (A21)
Change-Id: I901e6b0e2b994128da19d68233b9f68bb308cb95
2012-06-29 15:44:17 +09:00
Jean Chalard 4d5e7235c5 Remove a useless variable (A20)
Change-Id: Ifc37462f5243563693c8cd7cbeb401ff054daa52
2012-06-29 15:12:51 +09:00
Jean Chalard 739683dcfb Rename a method for readability (A19)
Change-Id: I0b8c06d1fd0bfb3caf363c048acc7048abed1752
2012-06-29 15:12:51 +09:00
Jean Chalard 31b346aac6 Remove a useless test (A18)
allowsToBeAutoCorrected always returns false if the word is empty.
This is because the whitelist never contains an empty string,
and isValidWord returns false if the word is empty.

Change-Id: I34ecc2a1563aea6db5b2f12796f251f6598576a2
2012-06-29 15:12:51 +09:00
Jean Chalard b01cdb975a Inline a method (A17)
This will allow us to remove unnecessary processing

Change-Id: I251dfdaffb077906186686ebe65fd82e1e360bd2
2012-06-29 15:12:51 +09:00
Jean Chalard a96a11949f Inline a simple method (A15)
Change-Id: Ib74fcbf33c680bf02c39a9896e30e3afbcfd149a
2012-06-29 15:12:51 +09:00
Jean Chalard 074c90af98 Inline a method (A14)
The new code is worse than the old one, but this is a necessary
step to make things prettier.

Change-Id: If6e8a139bb85e6920c749743c78792a22a8acb45
2012-06-29 15:12:51 +09:00
Jean Chalard f89a75134b Small readability improvement (A10)
Change-Id: Iba326921711e1c4eab38264e66b6b44a64fec398
2012-06-29 15:05:08 +09:00
Jean Chalard 5110e2cb51 Optimization (A8)
Change-Id: I2b9e8cc6a13fd9af84a5189e4d3fbb2b05c68d46
2012-06-29 12:54:11 +09:00
Jean Chalard 4847a27f74 Cleanup (A7)
Change-Id: Iba97e0062b702c005ab3ff9ce59f181d19ab7c98
2012-06-28 19:13:16 +09:00
Jean Chalard ed83d4b143 Stop special-casing a single suggestion (A6)
Treat it like the others

Change-Id: Ic24e40ada0e75773c3ece9470ab61c350697be5d
2012-06-28 19:12:37 +09:00
Jean Chalard 251bb70f08 Cleanup (A5)
Change-Id: I06134145b47c46bbc6c340ca539f34a01e2ca163
2012-06-28 19:12:37 +09:00
Jean Chalard 4c4e3a0949 Transform the whitelist suggestion like the others (A4)
...instead of having a different code path

Change-Id: Icd177e2151e45d25300000d4b63d4fba1f52b6a8
2012-06-28 19:10:32 +09:00
Jean Chalard 33b3805e79 Small refactoring (A3)
This will help make upcoming changes clearer

Change-Id: Ida8d4935f7315e5da6007ad364124694da3112d0
2012-06-28 19:10:24 +09:00
Jean Chalard b7cdafd78a Don't pass everything to a function that needs only the head (A2)
Change-Id: Ic367836202ab8071c1a9a02eaf0651b0da947d51
2012-06-28 19:10:13 +09:00
Jean Chalard 2d2e348033 Use a TreeSet to sort suggestions instead of doing it by hand (A1)
Change-Id: I16ba39321107e87ad48a99c2410a15995a66f23c
2012-06-28 18:54:14 +09:00
Jean Chalard 10abf10c1f Convert local members to local variables
Change-Id: I852787986c79502a4de7effe9c8281a4cf2d519d
2012-06-27 19:54:29 +09:00
Jean Chalard 3ecb2747b3 Optimization.
It's useless to do this for all suggestions including those
that will be ousted from the list.

Change-Id: I7bd63d783e21984a269e4b1ae17e9b9d8c0859e3
2012-06-27 18:55:43 +09:00
Jean Chalard 3705ef407b Read the suggestion type from the suggestion
...instead of dirtily passing it from the dictionary loop

Change-Id: I92ddbd7451609b69f6d4dc31bf89d614423b2016
2012-06-27 18:18:35 +09:00
Jean Chalard 24eec0fa68 Remember the source dictionary for each suggestion.
Change-Id: I3c63372bd5572a479a67eaecfe8c8ea1cabc70d9
2012-06-27 18:17:28 +09:00
Jean Chalard d8f0caa406 Move constants to a better place.
Change-Id: I5c27a3ed99b17f850e26a8503de16f001c7111c1
2012-06-27 18:08:08 +09:00
Jean Chalard 089c11a086 Cleanup
Change-Id: I575f22330bf6881af1d9a35f22b51b7bf2198113
2012-06-27 17:59:58 +09:00
Jean Chalard b5afd3de0c Remove unused stuff.
Change-Id: Ifd0d5b6978f76b841574a6e10157c32d0cd656b6
2012-06-27 17:44:16 +09:00
Jean Chalard 32ff2504a0 Update the prototype of onAddSuggestedWord - calling side.
We want to get rid of all those IDs in Latin IME.

Change-Id: Ibe08100a5e2976c80abb049889233b4047a686f3
2012-06-27 16:17:14 +09:00
Jean Chalard 56beb9e321 Use binarySearch instead of a hand-written linear search
Yay.

Change-Id: Icf686eb2d675da959f19edc856b521e6288dcea3
2012-06-27 14:17:29 +09:00
Jean Chalard 9da0027b38 Implement a comparator for SuggestedWordInfos.
Change-Id: Ic4b0ae05cd98a1aec5806c5e4b744158e73aea7a
2012-06-27 14:16:23 +09:00
Jean Chalard 4ef01c51f8 Merge "Remove some special casing" 2012-06-26 20:33:43 -07:00
Jean Chalard 7e49a2b6b8 Remove some special casing
This special casing is useless. If the word is the same as what
user typed, the scoring algorithm already ensures that it comes
out at the top. Actually, as is written in a comment here, code
executed later is actively relying on this suggestion having
the top score ! There is no need to test it for equalness and
inserting it at the top then.

Change-Id: I263a6de59b77ec72a2dcbb933361b8e16fca0681
2012-06-26 20:40:42 +09:00
Jean Chalard a3f5f51ec4 Fix a bug where a log would mysteriously not work
Change-Id: I5ca77ed65e95a6d357215c0e730238fb463986bb
2012-06-26 20:36:51 +09:00