Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predictive text #357

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Predictive text #357

wants to merge 16 commits into from

Conversation

flide
Copy link
Collaborator

@flide flide commented Jul 25, 2023

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 26, 2023

Artifact 8vim-debug available until: 2023-08-14T06:00:04Z

@flide
Copy link
Collaborator Author

flide commented Aug 1, 2023 via email

flide and others added 16 commits August 7, 2023 11:24
…the manifest

The READ_USER_DICTIONARY permission is added to the AndroidManifest.xml file to allow the application to read the user's dictionary. This permission is necessary for predictive text functionality within the app.
…nary words

A temporary method to verify access to user's personal dictionary.
The printUserDictionaryWords method is added to the MainInputMethodService class to print the words from the user dictionary. This method takes a ContentResolver as a parameter and queries the UserDictionary.Words.CONTENT_URI to retrieve the words. The words are then printed to the console. The onCreate method is refactored to call the printUserDictionaryWords method after setting the theme and before calling the super.onCreate method. This allows for the user dictionary words to be printed when the input method service is created.
… track the current word being typed

The `onUpdateSelection` method is added to the `MainInputMethodService` class to track the current word being typed by the user. The method retrieves the text before the cursor and extracts the current word from it. The `getCurrentWord` method is also added to allow other parts of the code to retrieve the current word. This change improves the functionality of the input method service by providing access to the current word being typed.
…ctive text functionality

The build.gradle file was modified to add the Apache Commons Text library as a dependency. This library is required for the new predictive text functionality.
The MainInputMethodService.java file was modified to import the PredictiveTextHelper class and create an instance of it. This allows the IME to use the predictive text functionality.
A new PredictiveTextHelper.java file was added to implement the predictive text functionality. This class loads dictionaries, extracts the current word from the text before the cursor, generates word suggestions based on the current word, and sorts the suggestions based on their similarity to the current word using the Levenshtein distance algorithm.
…ctionary from raw resource file

The PredictiveTextHelper constructor now accepts a Context parameter instead of a ContentResolver. This change improves flexibility as it allows the PredictiveTextHelper class to be used in different contexts, not just limited to activities or services that have access to a ContentResolver.

The loadEnglishDictionaryWords method in PredictiveTextHelper now loads the English dictionary from a raw resource file.
…n based on Levenshtein distance and word frequency

In `PredictiveTextHelper.java`, the loading of the word frequency map from the file has been setup. The file is read line by line, and each line is split into word and frequency parts. The word and frequency are then added to the `wordFrequencyMap` map.

The `generateWordSuggestions()` method is improved to generate word suggestions based on Levenshtein distance and word frequency. The method now uses the `getClosestWords()` method to get a list of candidate words based on Levenshtein distance. The candidate words are then sorted based on their frequencies and added to the `suggestedWords` list.
…words to 12 for better performance

The number of suggested words is now limited to 12 to improve the performance of the PredictiveTextHelper class. By reducing the number of suggested words, the processing time and memory usage are optimized, resulting in a more efficient and responsive user experience.
…ggested words and set suggestions based on predictive text

The unused import statement for android.util.Log has been removed to improve code cleanliness. The SuggestionView has been added to the MainInputMethodService to display suggested words based on predictive text. The SuggestionView is a custom view that sets the suggestions based on a list of strings. The suggestion_item.xml and suggestion_view.xml layout files have been created to define the appearance of individual suggestion items and the suggestion view container, respectively.
The changes in these files are purely cosmetic. Unused imports have been removed and the code has been reformatted to improve readability.
…nment

The `android:baselineAligned` attribute is added to the `suggestion_view.xml` layout file to improve the alignment of the elements within the layout. This attribute ensures that the baseline of each element is aligned properly, resulting in a more visually appealing layout. This Also fixes the lint issues.
…s to SuggestionView

The SuggestionViewActionListener class is added to handle actions related to the SuggestionView. The SuggestionView class now has an actionListener field of type SuggestionViewActionListener, which is initialized in the initialize() method. Additionally, onClick listeners are added to the suggestion TextViews to handle click events and call the appropriate action on the actionListener. These changes improve the functionality and interactivity of the SuggestionView component.
@MaethorNaur MaethorNaur added this to the v0.18.0 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

2 participants