Commit Graph

440 Commits

Author SHA1 Message Date
zonble dd1310d40a Makes version update testable. 2022-01-18 18:39:21 +08:00
zonble 28a9483de8 Adds tests. 2022-01-18 17:45:48 +08:00
zonble 8d0db31ed0 Modifies deploy target of the test bundle. 2022-01-18 17:10:38 +08:00
zonble 29813f93e5 Adds test cases. 2022-01-18 17:05:51 +08:00
zonble fb043b9308 Updates CI settings. 2022-01-18 15:39:07 +08:00
zonble 21264a8a27 Adds unit test cases. 2022-01-18 15:38:19 +08:00
Weizhong Yang a.k.a zonble 00f110f101 Merge pull request #239 from openvanilla/add-code-of-conduct-1
Create CODE_OF_CONDUCT.md
2022-01-17 21:06:07 +08:00
Weizhong Yang a.k.a zonble 6c2707c4e9 Merge pull request #237 from zonble/dev/latin_input
Allows users to type Latin letters while using shift + letter keys.
2022-01-17 10:44:19 +08:00
Lukhnos Liu d730e967a2 Create CODE_OF_CONDUCT.md 2022-01-16 18:21:54 -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
Lukhnos Liu f2d3ca3c78 Merge pull request #236 from zonble/master
Adds a validator for candidate keys in the preference window.
2022-01-16 08:11:09 -08:00
zonble 8249c612ff Adds a validator for candidate keys in the preference window. 2022-01-16 23:33:35 +08:00
Weizhong Yang a.k.a zonble 4f01fd95f6 Merge pull request #233 from tianjianjiang/build-xcode_12.4_swift_5.3
build: make Xcode 12.4 happy on Catalina with Swift 5.3
2022-01-16 23:33:16 +08:00
Mike Tian-Jian Jiang 720b2347e8 build: makes Xcode 12.4 happy on Catalina with Swift 5.3 2022-01-16 18:42:04 +09:00
Lukhnos Liu 0b0d97f20e Merge pull request #228 from openvanilla/issue-template
Update issue templates
2022-01-15 23:29:00 -08:00
Lukhnos Liu 3c9d3e59ed Merge pull request #232 from zonble/master
Minor changes like fixing typos
2022-01-15 23:28:00 -08:00
zonble 74df73a733 Updates the README file. 2022-01-16 15:18:47 +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
Weizhong Yang a.k.a zonble 01378b8091 Merge pull request #227 from zonble/master
Adds a new setting: Chinese conversion style
2022-01-16 15:05:08 +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
Weizhong Yang a.k.a zonble 8584f5c4b3 Merge pull request #230 from lukhnos/parseless-lm
Use a parseless phrase db to speed up LM loading
2022-01-16 14:39:08 +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 5a1779b436 Updates the issue templates. 2022-01-15 22:25:33 +08:00
zonble 1140228a4b Updates issue templates. 2022-01-15 22:20:55 +08:00
Weizhong Yang a.k.a zonble 8467b82860 Update issue templates 2022-01-15 21:52:06 +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
Weizhong Yang a.k.a zonble 825ed4f122 Merge pull request #223 from zonble/master
Extracts preferences and emacs key detection from the input controller
2022-01-15 01:40:05 +08:00
zonble 7edf011e42 Fixes a typo. 2022-01-14 22:36:58 +08:00
zonble 5ce581e0c6 Brings back VXHanConvert. 2022-01-14 22:15:17 +08:00
zonble 7a5cb635e9 Fixes the bugs in the preferences like typos. 2022-01-14 20:31:39 +08:00
zonble aa325f73aa Fixes the typo for the enum of McBopomofo keys. 2022-01-14 20:18:45 +08:00
zonble 95648caa0c Simplifies the code to build the input menu. 2022-01-14 19:55:08 +08:00
zonble d11daacbd2 Refactors the keyboard layout enum. 2022-01-14 19:47:53 +08:00
zonble 83354f7c48 Adds icons for keyboard layouts in preference. 2022-01-14 19:37:48 +08:00
zonble 9faed2153f Uses property wrappers to manage preferences. 2022-01-14 18:06:26 +08:00
Lukhnos Liu c698c61432 Merge pull request #220 from lukhnos/custom-phrase-reader
Use a more tolerant parser for user phrases
2022-01-13 23:43:35 -08:00
Lukhnos Liu d6cc5479f6 Use a more tolerant parser for user phrases
A generic key-value blob reader, KeyValueBlobReader, is implemented to
allow more flexibility in user-editable files. For example, this allows
comments in the file, as well as tolerating leading or trailing spaces,
tabs, or even Windows CR LF line endings.

Unit tests are supplied for KeyValueBlobReader although they are not
part of the Xcode project. A separate CMakeLists.txt is provided.

UserPhrasesLM is refactored to use KeyValueBlobReader. A small stylistic
change is appiled to reduce "using namespace" uses, but otherwise no
major style changes were applied to UserPhrasesLM.

Please note that McBopomofo's user phrase LM uses the value in a
key-value pair as the reading, and the key as the actual "value". We
don't plan to change that order so that we don't have to migrate data.

std::string_view is used to allow efficient reference to char buffers
and interop with std::string (and so no c_str() is needed). C++17 is now
enabled for the project to enable the use of std::string_view.

Copyright headers are added to McBopomofoLM and UserPhrasesLM.
2022-01-13 23:27:31 -08:00
Weizhong Yang a.k.a zonble 915693bc28 Merge pull request #219 from zonble/dev/half_size_punctuation
Various new functions and UI components
2022-01-14 14:40:20 +08:00
zonble 3ca0eddd23 Makes some members private. 2022-01-14 02:48:21 +08:00
zonble 34e193df21 Also updates the README file. 2022-01-14 02:34:23 +08:00
zonble 536aff1070 Removes unused files. 2022-01-14 01:38:32 +08:00
zonble fcdd59dd6b Wraps OpenCCBridge into a SPM package. 2022-01-14 00:57:41 +08:00
zonble e01eb46c9f Wraps InputSourceHelper to a SPM package. 2022-01-14 00:43:21 +08:00
zonble d4772ffa99 Adds notifier UI to notify user Chinese conversion on/off. 2022-01-13 23:38:56 +08:00