Coder Social home page Coder Social logo

apertium-keyboard's Introduction

apertium-keyboard

Language model

Currently supports a morpheme-aware character language model. Sample Guarani model (converted_model.tflite) lives in the assets directory (./app/src/main/assets), along with the set of symbols the LM is aware of (labels.txt), in order of their numerical index as used by the neural net.

Currently, the keyboard uses a simplified prediction logic. It presents continuations of the current input, up to the next predicted boundary (morpheme, word, or sentence). In the keyboard view, word continuations are presented with a "_" at the end, morpheme continuations with a "@", and sentences with a "<eos>".

This is achieved via a greedy unroll of the top 3 character predictions given the character history (i.e., running the language model with it's top choice given some starting point).

Building

Building on the command line:

$ gradle assembleDebug

The .apk will be found in ./app/build/outputs/apk/debug/app-debug.apk.

Make sure you have the following environment variables set:

ANDROID_HOME=/path/to/android-sdk/
NDK_HOME=/path/to/android-ndk-r19c
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Building in android studio.

Note that when you load the keyboard from Android studio, you may need to activate it as an input method:

Settings -> Languages & Input -> Virtual Keyboard -> Manage Keyboard

TODO: Add additional logic for rewriting the current unit, rather than just completing it.

Files

  • ./app/src/main/res/xml/qwerty.xml: This is the main keyboard layout file

  • ./src/main/assets

  • ./src/main/java

  • ./src/main/res

Key classes and methods:

LanguageModel/LanguageModelMobileNet: These classes in the tflite directory store the code for loading a Tensorflow Lite model, and using it to generate keyboard predictions. See LanguageModel::generate() for the inference function.

SmartKeyboard: This kotlin class in the service directory contains all the relevant keyboard code. Here are the some important functions:

SmartKeyboard::updateCandidates() //Get a new set of predicted continuations based on the current input history.

SmartKeyboard::getPredictions() //Call the language model to get some number of prediction candidates.

SmartKeyboard::pickSuggestion() //What should the keyboard do when the user picks a predicted continuation?

SmartKeyboard::handleBackspace() //What should happen if the user made a mistake and backs up?

Acknowledgements

The original fork this code is based on was written by Christo Kirov.

apertium-keyboard's People

Contributors

ftyers avatar

Stargazers

Robert Pugh avatar Leland Paul Kusmer avatar  avatar

Watchers

Kevin Brubeck Unhammer avatar Xavi Ivars avatar Mikel L. Forcada avatar Sergio Ortiz Rojas avatar  avatar Kaarel Kaljurand avatar James Cloos avatar Jonathan Washington avatar Shardul Chiplunkar avatar  avatar

Forkers

lelandpaul

apertium-keyboard's Issues

Emojis

Don't need gifs or stickers, but emojis would be nice.

Add multi-language build support

My idea at the moment is to have the keyboard layouts and transducers/etc. inside the monolingual packages, and then use autotools to do e.g. either:

./configure --with-lang1=../languages/apertium-quc  --with-lang2=../languages/apertium-spa

Or

./configure --with-languages=../languages/

@nlhowell what do you think?

Theming

It would be nice to have support for multiple (custom as well?) themes. At the very least, a dark mode would be nice.

Related to #8

Make a logo

Maybe the Apertium logo with a small keyboard icon superimposed on it.

Make the theme nicer

At the moment it's pretty bleh, it should look like GBoard.

photo5213071265269657575-2

Potentially there should be also a dark mode. But the most important is the Gboard-like one.

Rename?

Should we rename this to apertium-android-keyboard in case we make apertium-ios-keyboard?

TFlite models are crushingly slow

For some reason on my phone, the tflite models are really slow and the keyboard is unusable. Probably best to turn it off by default until we get it working faster.

Popup keyword work like Gboard

At the moment longpress brings up a popup that has an [x] to close it or click to close it, the way that Gboard works is better, e.g. hold and slide to select something from the 2nd level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.