Skip to content

v0.7.0

Latest

Choose a tag to compare

@pythonbrad pythonbrad released this 29 Jul 19:43
46fe00d

Afrim Version 0.7.0 Overview

Afrim is a framework designed for creating custom input methods. It’s particularly focused on using phonetic and transliteration rules, which are scripted in a language called Rhai. The latest release, version 0.7.0, brings some key improvements, particularly regarding performance for translators and configuration, as well as a more straightforward delete command for easier front-end integration.

Reasons for the Updates

One of the main issues addressed in this release was the Translator::translate function. This function was being run every time a key was pressed, but it was also rebuilding an entire Rhai script engine for each call. This was creating unnecessary delays, especially on less powerful hardware. (#200)

Another challenge was with backspace functionality in certain front-end environments. In these cases, a single backspace command couldn't always cleanly delete a character because what was displayed could consist of multiple bytes or code points. Users needed clearer instructions on what to delete rather than just being told to erase "one unit". (#283)

Additionally, users found it cumbersome to have to manually add afrim-config, afrim-translator, and afrim-preprocessor to their own Cargo.toml files just to access certain types that Afrim already depended on. (#220)
Moreover, there was no option for integrators to adjust how confident a match needed to be before it was presented. (#235)

What Changed & How to Use the New Features

Here’s what’s new in version 0.7.0:

1. Faster Translation: (#278)
The Rhai Engine now remains cached in the Translator, meaning it won’t be rebuilt with each keystroke. Some optimizations in predicate checking have also been made, and we switched to a quicker sorting method. As a result, translation is not only faster but also avoids crashes that occurred when multi-byte characters (like emojis) were involved.

2. Improved Configuration Loading: (#281)
The process for loading configurations has been streamlined. We’ve simplified how auto-capitalization works and divided configuration reading and processing into separate steps. This means a better approach for both testing and efficiency.

3. More Explicit Delete Command: (#286)
The Command::Delete now specifies exactly which character needs to be deleted. This is a big improvement, especially for environments where backspace wasn’t functioning correctly. In this version, backspace will accurately delete the correct part of the input without needing multiple checks.

4. Configurable Minimum Confidence: (#291)
You can now define a min_confidence level in your configuration file to control how aggressively lower-confidence matches should be filtered. This allows for a more tailored experience depending on user needs.

5. Streamlined External API: (#292)
We’ve made the external API simpler, which simplifies things a lot.

6. Removal of the Inhibit Feature: (#294)
We’ve completely removed the inhibit feature to make the preprocessor less complicated. If you were relying on this feature, you’ll need to look for alternatives, as it is no longer available in this version.

7. Miscellaneous Updates: (#279)
The Rust toolchain has been updated to version 1.96, and there are various dependency updates, along with some new frontend project links added to the README.

Lessons Learned

One of the key takeaways from this development cycle was that caching the Rhai engine instead of rebuilding it each time a key is pressed was a significant performance gain. It serves as a reminder that what might seem like minor allocations can become quite significant when they’re executed frequently.

Also, an important lesson came from dealing with multi-byte characters. We learned that it’s crucial to ensure dictionary code handles not just plain ASCII keys but also non-ASCII characters, such as emojis. Additionally, rethinking the Command::Delete function revealed some complexities in managing backspace operations. It’s clear that deletion can vary – depending on what kind of input you're dealing with, and this led to a need for further adjustments to avoid bugs in how deletes are processed.


Highlights of Changes

Full Changelog: v0.6.2...v0.7.0

This update aims to provide a smoother, more efficient experience when using Afrim, and we hope these changes will significantly benefit developers and users alike.

This summary was drafted with LLM assistance (Claude and https://originality.ai), based on the PR descriptions and commit history above, and reviewed by the author.