Commit Graph

19 Commits

Author SHA1 Message Date
zonble 8ba4b9dfdf Prevents loading data models repeatedly. 2022-01-30 20:27:33 +08:00
zonble 8a05e4d6f7 Makes variables in LanguageModelManager static. 2022-01-30 08:18:45 +08:00
zonble 2c0a12f43f Lazy loads language models. 2022-01-30 08:06:22 +08:00
zonble 4c358c1c1d Converts InputMethodController to Swift. 2022-01-30 08:06:22 +08:00
zonble b13da10ec0 Code clean-up. 2022-01-28 16:16:52 +08:00
zonble 0bc9468ba2 Splits Input Method controller into two classes. 2022-01-28 15:02:00 +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 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 0d80d28e0e Formats Swift code. 2022-01-18 21:16:07 +08:00
zonble c4259c4c4e Updates comments and fixes a typo. 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 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
zonble d590d748f8 Adds UserPhrasesLM for user phrases.
Since there is no probability information for users' custom phrases,
they should be stored in a format differs from data.txt. Using the same
format and FastLM to parse user phrases just because of laziness but it
is not the right way.

The pull request adds a new language model class to parse user phrases.
It also update the input method controller to adopt the new user phrase
format.
2022-01-12 16:53:51 +08:00
zonble f1e56a7e01 Lets McBopomofoLM to accept NULL as the parameter in loadUserPhrases. 2022-01-12 13:17:41 +08:00
zonble abdf97f652 Adds McBopomofoLM as the facade of three language models.
- main language model
- user phrases
- user excluded phrases
2022-01-12 12:26:24 +08:00
zonble 9b485b799c Implements excluding phrases. 2022-01-12 00:16:55 +08:00
zonble 144d133463 Adds Language Model Manager.
The reference of the global language models were stored in the class
InputMethodController, however, the global models are global but not a
part of the input method controller, and the input method controller
only use one of the models (McBopomofo/Plain Bopomofo). I guess it
somehow violates SRP and there should be a better place for the global
models.
2022-01-11 17:12:58 +08:00