Draft
Conversation
Co-authored-by: tribixbite <381345+tribixbite@users.noreply.github.com>
- Add getPredictedWords() method to BigramModel to get next word predictions based on context - Add predictNextWords() method to WordPredictor that combines bigram predictions with dictionary frequency, user adaptation, and personalization - Integrate next word predictions into SuggestionHandler - triggers after space is typed - Next word predictions use BigramModel's word-level bigrams (e.g., "the|end", "I|am") to suggest contextually relevant words - Fallback to high-frequency words if no bigram matches found - Predictions respect disabled words, user adaptation, and personalization settings Co-authored-by: tribixbite <381345+tribixbite@users.noreply.github.com>
- Add BIGRAM_SCORE_SCALE constant (10000) for scaling bigram probability - Add FALLBACK_SCORE_MULTIPLIER constant (0.5f) for high-frequency word fallback scoring - Add PERSONALIZATION_BOOST_DIVISOR constant (4.0f) for personalization boost calculation - Add FREQUENCY_NORMALIZATION_FACTOR constant (1000.0f) for frequency normalization - Update predictNextWords() to use named constants instead of magic numbers - Improves code readability and maintainability Co-authored-by: tribixbite <381345+tribixbite@users.noreply.github.com>
- Extract BIGRAM_EXPANSION_FACTOR constant (3) for bigram candidate expansion - Add SPACE_CHARACTER constant to make trigger condition more explicit - Fix potential race condition in BigramModel.getPredictedWords() using lastOrNull() - Update Phase 7.1/7.2 comments to describe actual functionality - Improve code clarity and thread safety Co-authored-by: tribixbite <381345+tribixbite@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix next word prediction issue in CleverKeys
Implement next word prediction after space
Jan 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Keyboard showed word completions while typing but no next word predictions after completing a word. Implemented next word prediction using existing BigramModel word-level bigrams ("I|am", "the|end", etc.) combined with multi-signal scoring.
Type of Change
Related Issues
Addresses user report of missing next word predictions.
Changes Made
BigramModel.kt
getPredictedWords(context, maxPredictions)- retrieves next word candidates from bigram probabilitieslastOrNull()to prevent concurrent modification exceptionsWordPredictor.kt
predictNextWords(context, maxPredictions)- multi-signal scoring engineBIGRAM_SCORE_SCALE = 10000- scales probability (0-1) to scoring rangeBIGRAM_EXPANSION_FACTOR = 3- retrieves 3x candidates for filteringFALLBACK_SCORE_MULTIPLIER = 0.5f- demotes non-bigram fallback wordsPERSONALIZATION_BOOST_DIVISOR = 4.0f- converts boost (0-6) to multiplier (1.0-2.5)FREQUENCY_NORMALIZATION_FACTOR = 1000.0f- for logarithmic frequency scalingSuggestionHandler.kt
updateNextWordPredictions()- async prediction executorSPACE_CHARACTER = " "Scoring formula:
Example behavior:
Testing Performed
Manual Testing
Test Device:
Test Scenarios:
Results:
Pending manual testing on device.
Automated Testing
# Build verification ./gradlew assembleDebugScreenshots/Videos
Before:
Suggestion bar cleared after typing space, no next word predictions shown.
After:
After typing space, suggestion bar displays contextually relevant next word predictions based on bigram probabilities.
Performance Impact
Known optimization opportunities (not blocking):
Privacy & Security Checklist
Privacy Impact: None
Explanation: Uses existing local BigramModel data, all processing on-device, respects existing privacy settings.
Code Quality Checklist
Documentation
Breaking Changes
None. Feature is additive and uses existing prediction infrastructure.
Additional Context
Implementation notes:
Future enhancements:
Checklist for Maintainers
Thank you for contributing to CleverKeys! 🎉
🧠 Think Faster • ⌨️ Type Smarter • 🔒 Stay Private
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/gradle-daemon-main-8.10.2.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/agents/gradle-instrumentation-agent-8.10.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.10.2 grep(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.