Implement next word prediction after space #44
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.