A dynamic keyboard made using Flutter.
An input tool made up of buttons which functions as a keyboard. This keyboard changes dynamically depending on the input to display the most likely sub-aksaras (graphemes) to come next. The keyboard displays predictions of lengths 1-4.
All example word-frequency lists have been retrieved from the Dakshina data set.
Install Flutter: Instructions are here: https://flutter.dev/docs/get-started/install
In summary:
- Extract the file found in the link above to your desired location, e.g.
${USER}/${FOLDER}
. - Add Flutter to your path (e.g. by typing
export PATH="${PATH}:${PWD}/flutter/bin"
into the Linux command line). - To add Flutter to your path permanently, see instructions in the link above.
- Type
flutter doctor
into the command line to make sure everything has been installed smoothly.
Flutter comes with a Dart SDK so you do not need a separate download for this.
Flutter projects can be worked on in your IDE of choice. Flutter does, however, requires an installation of Android Studio to supply its Android platform dependencies. On the other hand, the pure Dart package we use cannot be created in Android Studio. Therefore, instructions for setting up both Android Studio and Visual Studio Code are given below.
- Download and install from here: https://developer.android.com/studio
- Start Android Studio and go through the Android Studio Setup Wizard.
- On the Android Studio homepage click Configure and then Plugins and search for Flutter.
- Install VS Code from here: https://code.visualstudio.com/
- Start VS Code and install the Dart and Flutter plugins by going to View > Command Palette (or Ctrl + Shift + P).
- Type install, and then select Extensions: Install Extensions.
- Type Flutter and click install. This installs both the Dart and Flutter plugins.
Instructions can be found here for Android: https://flutter.dev/docs/get-started/install
- Go to View > Command Palette in VS Code and choose Dart: New Project.
- Select Console Application (console-full) and name your project trie_constructor.
- Take note of where you store the project directory.
- Overwrite lib, bin, and pubspec.yaml with the lib, bin, and pubspec.yaml files in trie_constructor directory in this repository.
- Run
pub get
in your terminal.
- Download and extract the appropriate protoc from here: https://github.com/protocolbuffers/protobuf/releases/tag/v3.12.4 .
- Other possible ways of installing the compiler for Linux and Mac can be found here: https://github.com/dart-lang/protobuf/tree/master/protoc_plugin#hacking
- As instructed in the downloaded README, add the protoc binary location to your path.
- To download the Dart protoc plugin, instructions can be found here: https://github.com/dart-lang/protobuf/tree/master/protoc_plugin .
- In a terminal, navigate to trie_constructor/lib and then enter
protoc --dart_out=. ./suffix_trie.proto
. - If you ever make changes to the suffix_trie.proto file, repeat step 5.
- Create a new Flutter project (application) named keyboard_oracle in Android Studio.
- Delete the default test folder and copy-paste the files in the assets folder from this repository.
- This data is just placeholder data. You can replace it with your own, which can be generated using the dart package provided.
- Overwrite the project's pubspec.yaml file with the one from this repository.
- Find the comment in pubspec.yaml looking for a local path and replace it with the path to the directory of your Dart package.
- Overwrite the project's lib folder with the one from this repository.
- To run the app, select an emulator/device and run Flutter main.
- Go to terminal, navigate to trie_constructor/bin and enter
dart trie_constructor.dart
. This constructs a trie from the default text file (hi_examples.txt) and stores it in hi_trie.bin . - If you would like to change the input text file to a different text file, enter
dart trie_constructor.dart --inputFile=[filepath]
. For example:dart trie_constructor.dart --inputFile=ml_examples.txt
. - If you would like to change the output binary file location, enter
dart trie_constructor.dart --outputFile=[file path]
. - For input files, the script needs text files containing words where each word is separated by aksara and followed by its frequency in the form of: [Aksara1][space symbol][Aksara2][space symbol][Aksara3][tab symbol][frequency no.] .
- If you would like to run performance tests on your language model, use the command line flag isTest. E.g.
dart trie_constructor.dart --isTest
. The results will be printed to your console. - If you would like to run general tests on the suffix trie, you can run
pub run test test/
. - You can now copy the generated bin file from trie_constructor/bin and paste them into the assets folder in your flutter app to use.