Commit Graph

319 Commits

Author SHA1 Message Date
zonble dd803b6c31 Removes logs and add copyright information. 2022-01-28 04:40:53 +08:00
zonble 056ffeabfd Tunes the interface. 2022-01-28 04:04:44 +08:00
zonble 7ee955a55c Cleans-up KeyHandlerInput. 2022-01-28 03:24:06 +08:00
zonble 87702f76c5 Cleans-up the interface. 2022-01-28 03:18:10 +08:00
zonble e17d06fd2a Fixes the cursor index when choosing candidates. 2022-01-28 01:58:25 +08:00
zonble 9351d877ba Fixes the issue on presenting the candidate window. 2022-01-28 01:44:50 +08:00
zonble fc0c077193 Fixes the bug on handling arrow keys. 2022-01-28 01:35:15 +08:00
zonble 2bbaa4a793 Fixes NSCoding exceptions. 2022-01-28 00:23:31 +08:00
zonble 56c393cefa Prevents using global state as possible. 2022-01-27 23:19:27 +08:00
zonble 1ad9e23918 Refactors the input controller. 2022-01-27 22:54:53 +08:00
zonble 6fe2fc59f3 Moves the way to render attributed string to the states. 2022-01-24 21:47:24 +08:00
zonble 82a916c433 Adds a new file KeyHandler.swift to start to break input controller to testable modules. 2022-01-24 17:46:34 +08:00
zonble 177cba5d56 [WIP] Starts to extract input states from the input controller. 2022-01-24 02:13:18 +08:00
zonble 6f254bf75d Updates copyright information. 2022-01-22 11:24:22 +08:00
zonble 3bba134e2f Adds Credits.rtf. 2022-01-22 00:34:48 +08:00
zonble 8717625d2e Adds a missing line back to the installer. 2022-01-22 00:07:07 +08:00
zonble bfb66cb080 Converts the installer to Swift. 2022-01-22 00:01:21 +08:00
zonble 5fe1c28ae7 Converts main to Swift. 2022-01-21 19:17:36 +08:00
Lukhnos Liu 957b66a96b Bump to version 2.0.1 2022-01-20 15:37:31 -08:00
Lukhnos Liu 6c76b2cae0 Delete a duplicate key in McBopomofo-Info.plist 2022-01-20 15:36:33 -08:00
zonble cb05937478 Fixes the order of the keyboard layouts.
Fixes #250.
2022-01-20 14:20:10 +08:00
Lukhnos Liu 25c50e67a4 Bump to version 2.0 2022-01-19 10:05:48 -08:00
Lukhnos Liu 42c4441d05 Introduce a Swift class to the Installer
This is so that the Installer will be built with the correct Swift
settings, especially those that instruct the Xcode to package the Swift
runtime libraries. This is needed because the Installer now depends on
InputSourceHelper, which is written in Swift. Without this, the app
would not be packaged with the Swift runtime libraries, which caused
the installer to be unusable on older but supported macOS versions.
2022-01-19 10:05:38 -08:00
Lukhnos Liu 29df72b79f Bump to version 2.0-alpha 2022-01-18 23:31:07 -08:00
Lukhnos Liu 8c692e6c3b Update copyright years 2022-01-18 23:28:08 -08:00
Lukhnos Liu 202b1fa058 Also make PhraseReplacementMap more tolerant
This also clarifies the test expectations and how parsing errors are
handled.
2022-01-18 22:46:26 -08:00
Weizhong Yang a.k.a zonble 9bc3536630 Merge branch 'master' into more-tolerant-userphraseslm 2022-01-19 14:01:23 +08:00
Weizhong Yang a.k.a zonble 04d2ff5a4d Merge pull request #244 from lukhnos/custom-data-templates
Writes templates the first time custom data is used
2022-01-19 13:31:15 +08:00
Weizhong Yang a.k.a zonble 777994edcc Merge pull request #245 from lukhnos/update-copyright-headers
Update copyright headers (fixes #213)
2022-01-19 13:29:23 +08:00
Lukhnos Liu c8f65580bb Make UserPhrasesLM more tolerant
This lets UserPhrasesLM consumes as much user data as possible before
bailing. This makes it more tolerant to data errors and will not fail
entirely just because the user has one faulty line in a data file.

Also removes FastFM from the benchmarking suite.

This also runs the CMake-based C++ tests as part of the GitHub CI.
2022-01-18 16:20:25 -08:00
Lukhnos Liu 75f321f088 Update copyright headers (fixes #213) 2022-01-18 14:21:55 -08:00
Lukhnos Liu 61f55670fb Write templates the first time custom data is used
Now that we allow comments in the custom data files, this change writes
localized templates as well as basic instructions. Links to McBopomofo
User's Manual are also provided.
2022-01-18 13:42:45 -08:00
zonble 7e2d3df5ba Prevents users from adding custom phrases with more than 6 characters.
Also fixes typos.
2022-01-19 00:49:50 +08:00
zonble d2c039c42d Notifies the users it is not suggested to add phrase when model is converted. 2022-01-18 22:19:25 +08:00
zonble aa9c31ffcf Fixes the location of the tooltip. 2022-01-18 22:04:09 +08:00
zonble 0d80d28e0e Formats Swift code. 2022-01-18 21:16:07 +08:00
zonble dd1310d40a Makes version update testable. 2022-01-18 18:39:21 +08:00
zonble 29813f93e5 Adds test cases. 2022-01-18 17:05:51 +08:00
zonble e9b1a8ad4a Removes unused comments. 2022-01-17 00:55:36 +08:00
zonble a75c7b7086 Allows users to type Latin letters while using shift + letter keys.
Fixes issue #162.
2022-01-17 00:48:29 +08:00
zonble 8249c612ff Adds a validator for candidate keys in the preference window. 2022-01-16 23:33:35 +08:00
zonble 4ec4eed562 Removes unused files. 2022-01-16 15:15:41 +08:00
zonble 5ff6f378e6 Fixes a bug on selecting the candidate keys in the preference UI. 2022-01-16 15:14:49 +08:00
zonble c4259c4c4e Updates comments and fixes a typo. 2022-01-16 15:04:20 +08:00
zonble 4e56f350e8 Fixes a wrong API call. 2022-01-16 15:04:20 +08:00
zonble 5c0a14deeb Refactors the function to filter and transform unigrams in McBopomofoLM. 2022-01-16 15:04:20 +08:00
zonble b627e8e3b6 Adds an option to let users to choose Chinse conversion style.
Option 0: converts the output.
Option 1: converts the models.
2022-01-16 15:04:20 +08:00
zonble b348a05735 Filters duplicated unigram values properly. 2022-01-16 15:04:18 +08:00
Lukhnos Liu d064f420e4 Use a parseless phrase db to speed up LM loading
We take advantage of the fact that no one is able to modify the phrase
databases shipped with the binary (guranteed by macOS's integrity check
for notarized apps), and we can simply pre-sort the phrases in the
database files.

With this change, we can speed up McBopomofo's language model loading
during the app initialization by about 500-800x on a 2018 Intel MacBook
Pro. The LM loading used to take 300-400 ms, but now it's done within a
sub-millisecond range (0.5-0.6 ms). Microbenchmarking shows that
ParselessLM is about 16000x faster than FastLM. We amortize the latency
during the query time, and even by deferring the parsing, ParselessLM is
only ~1.5x slower than FastLM, and both LM classes serve queries unedr 6
microseconds (that's 0.006 ms), which means the tradeoff only
contributes to neglible overall latency.

This PR requires some small changes to the phrase db cooking scripts.
Python 3 is now used and the (value, reading, score) tuples are
rearranged to (reading, value, score) and sorted by reading ("key"). A
header is added to the phrase databases to call out the fact that these
are pre-sorted.

clang-format is used to apply WebKit C++ style to the new code. This
also applies to KeyValueBlobReader that was added recently.

Microbenchmark result below:

```
---------------------------------------------------------------------
Benchmark                           Time             CPU   Iterations
---------------------------------------------------------------------
BM_ParselessLMOpenClose         17710 ns        17199 ns        33422
BM_FastLMOpenClose          376520248 ns    367526500 ns            2
BM_ParselessLMFindUnigrams       5967 ns         5899 ns       113729
BM_FastLMFindUnigrams            2268 ns         2265 ns       307038
```
2022-01-15 16:15:02 -08:00
zonble 136ac34f22 Introduces in-place phrase replacement.
Since we have implemented the functions to add and exlcude phrases, the
commit allows users to use a table to change the output of a phrase
without changing its BPMF reading and score, when the "phrase replacement"
mode is on.

It could help users to switch a specific input scenario and the ordinary
one. For example, if a user wants to work on financial Chinese numbers
like 壹、貳、參, he or she may want the characters to have higher score
as the normal numbers like 一、二、三. The commit can let the users to
temporarily replace 一、二、三 to 壹、貳、參 by just turn on "phrase
replacement" mode and prepare a custom table.

The conversion is not done on the output phase like how we do
Traditional/Simplified Chinese conversion. What the phrase replacement
table does is to slightly modify the language model. The replacement
takes place on walking the nodes and candidates list.

A user can enable the mode and edit the table from the input menu. Since
the function is quite advanced, the menu items are hidden until the user
holds the option key.

The table is a plain text file. Each line contains a "from" and "to".
For example

```
一 壹
```

However, if the user also want all other phrase contain 一 to become 壹,
all of the phrases have to be built into the table

```
一百 壹佰
一千 壹仟
一萬 壹萬
一百萬 壹百萬
```
2022-01-15 06:23:09 +08:00