Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shubham0204/text-predictor-android
Next word prediction and word auto-complete for Android - with the power of Rust 🚀
https://github.com/shubham0204/text-predictor-android
android android-library autocomplete-suggestions data-structures markov-model rust text-predictions trie-data-structure
Last synced: 30 days ago
JSON representation
Next word prediction and word auto-complete for Android - with the power of Rust 🚀
- Host: GitHub
- URL: https://github.com/shubham0204/text-predictor-android
- Owner: shubham0204
- License: gpl-2.0
- Created: 2023-07-03T19:09:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-25T02:18:14.000Z (10 months ago)
- Last Synced: 2024-02-25T03:23:51.335Z (10 months ago)
- Topics: android, android-library, autocomplete-suggestions, data-structures, markov-model, rust, text-predictions, trie-data-structure
- Language: Kotlin
- Homepage: https://shubham0204.github.io/text-predictor-android/android
- Size: 13.4 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Text Prediction in Android - With Rust 🚀
Perform next-word prediction with text-autocompletion, all in Android. The library uses Rust internally, to bring
text-suggestions within a few-milliseconds. See the [rust]() branch for more details.* [Documentation](https://shubham0204.github.io/text-predictor-android/android/)
## Installation
1. Download `text-predictor.aar` from the latest release. (See [Releases](https://github.com/shubham0204/text-predictor-android/releases))
2. Move the AAR to `app/libs`.
3. In module-level `build.gradle`, add the dependency,```groovy
dependencies {
...
implementation files('libs/text-predictor.aar')
...
}
```## Usage
To generate suggestions while text is being entered in a text-widget (could be a `EditText` or `TextField`), we use
the `stream` method available in the `TextPredictor` class. The `stream` method must be called inside on a `onTextChanged` or a
similar callback that provides a string entered by the user.For a Compose `TextField`,
```kotlin
val textPredictor = TextPredictor( this , results )var inputString by remember{ mutableStateOf("") }
TextField(
modifier = modifier,
value = inputString,,
onValueChange = {
textPredictor.stream(it)
inputString = it
},
singleLine = true,
)private val results: ((List) -> Unit) = { suggestions ->
// Handle UI changes that display `suggestions`
}
```For a `View`-based `EditText`,
```kotlin
val textPredictor = TextPredictor( this , results )editText.addTextChangedListener { it ->
textPredictor.stream( it.toString() )
}private val results: ((List) -> Unit) = { suggestions ->
// Handle UI changes that display `suggestions`
}
```