Skip to content

Input Method Management

Archie Liu edited this page Jul 13, 2023 · 1 revision

Deployment

Each input method undergoes a thorough deployment process prior to release. The deployed files are subsequently uploaded to our server, allowing users to utilize them right after downloading. Bear in mind, though, that deployment within a WebAssembly environment might be slightly sluggish due to its suboptimal IO performance.

We've streamlined our input method management by consolidating all schemes under a single file, "default.xml", located in the "schema-manifest" repository. To access the source code for all schemes, execute the command "repo init -u https://gitlab.fydeos.xyz/fydeos-extensions/ime/schema-manifest". Upon successful download, clone the "schema-builder" repository into the same folder, then navigate to the "schema-builder" directory. You'll need to adjust the "DEPLOYER" variable in the "do-build" script to align with the correct path of "rime_deployer". Running this script initiates the deployment procedure. Once finalized, upload the 'build-product' directory to the OSS server to make it user-accessible. Don't forget to upload the schema-list.yaml file as well.

Download

To broaden the schema list, the program consults the "schema-list" to accumulate data regarding all possible schemas.

Clicking on the 'Download Schema' button initiates the download of the '.schema.yaml' file from the build directory, which is a deployed rendition of the schema, housing detailed information about the current schema. Parsing this YAML file is necessary to obtain all lexicons needed for the input schema. Several schemes need not only the primary lexicon, but also supplementary auxiliary lexicons—for example, the English lexicon "melt_eng" for "rime_ice" and the "liangfen" lexicon for reverse phonetic lookup. To ensure the input method functions correctly, all these lexicons must be downloaded. Each lexicon entails downloading the files ".table.bin", ".prism.bin", and ".reverse.bin".

Alongside lexicon files, a schema might also necessitate auxiliary files, such as Lua script files for Lua plugins or conversion files for OpenCC. For Lua files, given that Lua plugins can only utilize "rime.lua" as a fixed script filename, if the schema employs Lua, we download the "rime..lua" file. After schema loading, this file is duplicated as "rime.lua". For the OpenCC configuration files, we parse them and concurrently download the required dictionaries specified in each configuration.

The downloaded schema files are also housed in the virtual filesystem leveraging the APIs provided by fs.ts.

Configuration

The configuration for the quantity of candidate words per page in RIME is preserved in the schema's YAML configuration file. Consequently, each time RIME is launched, we parse the schema's YAML file and supersede the default page_size with the number of candidate words selected by the user.

For the fuzzy pronunciation configuration, as it necessitates modifying the schema's prism, we compile the main dictionary's prism file every time the user alters the configuration. Given that compiling the prism file is a swift process, it doesn't significantly affect performance.

During runtime, RIME requires a global default.yaml file, but only extracts the ascii_composer configuration (i.e., toggling between Chinese and English input using the Shift key) from it. Currently, the plugin generates a fixed default.yaml file each time. If there arises a need to introduce a configuration toggle key—say, changing Shift to Ctrl—the logic in this section can be adjusted accordingly.