Skip to content

Commit

Permalink
Fixed types, added singapore test case
Browse files Browse the repository at this point in the history
  • Loading branch information
andreihar committed Aug 2, 2024
1 parent c7d4e3f commit 33a72be
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 23 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ c.get(input);

* `south` (default) - [Zhangzhou][zhangzhou-wiki]-leaning pronunciation
* `north` - [Quanzhou][quanzhou-wiki]-leaning pronunciation
* `singapore` - Quanzhou-leaning pronunciation with [Singaporean characteristics][singapore-wiki]

| text | south | north |
| ------ | ------------- | ------------- |
| 五月節 | Gōo-gue̍h-tseh | Gōo-ge̍h-tsueh |
| text | south | north | singapore |
| -------------- | --------------------------- | --------------------------- | -------------------------- |
| 五月節我啉咖啡 | Gōo-gue̍h-tseh guá lim ka-pi | Gōo-ge̍h-tsueh guá lim ka-pi | Gōo-ge̍h-tsueh uá lim ko-pi |

#### Format

Expand Down Expand Up @@ -185,9 +186,9 @@ Default value depends on the chosen `system`:

Sandhi rules also change depending on the dialect chosen.

| text | no sandhi | south | north |
| ---- | --------- | ------- | ------- |
| 台灣 | Tâi-uân | Tāi-uân | Tài-uân |
| text | no sandhi | south | north / singapore |
| ---- | --------- | ------- | ----------------- |
| 台灣 | Tâi-uân | Tāi-uân | Tài-uân |

#### Punctuation

Expand Down Expand Up @@ -279,6 +280,10 @@ c = new Converter({ dialect: 'north' });
c.get("我欲用箸食魚");
>> Guá bueh īng tū tsia̍h hû

c = new Converter({ dialect: 'singapore' });
c.get("我欲用箸食魚");
>> Uá bueh ēng tū tsia̍h hû

//// Format
c = new Converter(); // for Tailo, mark by default
c.get("生日快樂");
Expand Down Expand Up @@ -446,5 +451,6 @@ The data is licensed under [CC BY-SA 4.0][data-cc]
[ipa-wiki]: https://en.wikipedia.org/wiki/International_Phonetic_Alphabet
[zhangzhou-wiki]: https://en.wikipedia.org/wiki/Zhangzhou_dialects
[quanzhou-wiki]: https://en.wikipedia.org/wiki/Quanzhou_dialects
[singapore-wiki]: https://en.wikipedia.org/wiki/Singaporean_Hokkien
[nltk-tokenize]: https://nltk.org/api/nltk.tokenize.html
[sandhi-wiki]: https://en.wikipedia.org/wiki/Taiwanese_Hokkien#Tone%20sandhi:~:text=thng%E2%9F%A9%20(%22soup%22).-,Tone%20sandhi,-%5Bedit%5D
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taibun",
"version": "1.1.2",
"version": "1.1.3",
"description": "Taiwanese Hokkien Transliterator and Tokeniser",
"main": "taibun/index.js",
"types": "taibun/index.d.ts",
Expand Down
18 changes: 12 additions & 6 deletions readme/README-cmn.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ c.get(input);

* `south` (預設) - 發音更接近[漳州話][zhangzhou-wiki]
* `north` - 發音更接近[泉州話][quanzhou-wiki]
* `singapore` - 帶有[新加坡特色][singapore-wiki]的泉州話發音

| 文本 | south | north |
| ------ | ------------- | ------------- |
| 五月節 | Gōo-gue̍h-tseh | Gōo-ge̍h-tsueh |
| 文本 | south | north | singapore |
| -------------- | --------------------------- | --------------------------- | -------------------------- |
| 五月節我啉咖啡 | Gōo-gue̍h-tseh guá lim ka-pi | Gōo-ge̍h-tsueh guá lim ka-pi | Gōo-ge̍h-tsueh uá lim ko-pi |

#### Format

Expand Down Expand Up @@ -185,9 +186,9 @@ c.get(input);

變調規則也會根據所選擇的方言而變化。

| 文本 | 沒有變調 | south | north |
| ---- | -------- | ------- | ------- |
| 台灣 | Tâi-uân | Tāi-uân | Tài-uân |
| 文本 | 沒有變調 | south | north / singapore |
| ---- | -------- | ------- | ----------------- |
| 台灣 | Tâi-uân | Tāi-uân | Tài-uân |

#### Punctuation

Expand Down Expand Up @@ -279,6 +280,10 @@ c = new Converter({ dialect: 'north' });
c.get("我欲用箸食魚");
>> Guá bueh īng tū tsia̍h hû

c = new Converter({ dialect: 'singapore' });
c.get("我欲用箸食魚");
>> Uá bueh ēng tū tsia̍h hû

//// Format
c = new Converter(); // 在 Tailo 中,format 預設值: mark
c.get("生日快樂");
Expand Down Expand Up @@ -446,5 +451,6 @@ isCjk('我食pháng');
[ipa-wiki]: https://zh.wikipedia.org/zh-tw/%E5%9C%8B%E9%9A%9B%E9%9F%B3%E6%A8%99
[zhangzhou-wiki]: https://zh.wikipedia.org/zh-tw/%E6%BC%B3%E5%B7%9E%E8%AF%9D
[quanzhou-wiki]: https://zh.wikipedia.org/zh-tw/%E6%B3%89%E5%B7%9E%E8%AF%9D
[singapore-wiki]: https://zh.wikipedia.org/wiki/%E6%96%B0%E5%8A%A0%E5%9D%A1%E7%A6%8F%E5%BB%BA%E8%A9%B1
[nltk-tokenize]: https://nltk.org/api/nltk.tokenize.html
[sandhi-wiki]: https://zh.wikipedia.org/zh-tw/%E8%87%BA%E7%81%A3%E8%A9%B1#%E9%80%A3%E8%AE%80%E8%AE%8A%E8%AA%BF:~:text=%E3%80%82%5B144%5D-,%E9%80%A3%E8%AE%80%E8%AE%8A%E8%AA%BF,-%E9%80%A3%E8%AE%80%E8%AE%8A%E8%AA%BF
18 changes: 12 additions & 6 deletions readme/README-oan.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ c.get(input);

* `south` (預設) - 發音較像[漳州話][zhangzhou-wiki]
* `north` - 發音較像[泉州話][quanzhou-wiki]
* `singapore` - 帶有[新加坡特色][singapore-wiki]的泉州話發音

| 文本 | south | north |
| ------ | ------------- | ------------- |
| 五月節 | Gōo-gue̍h-tseh | Gōo-ge̍h-tsueh |
| 文本 | south | north | singapore |
| -------------- | --------------------------- | --------------------------- | -------------------------- |
| 五月節我啉咖啡 | Gōo-gue̍h-tseh guá lim ka-pi | Gōo-ge̍h-tsueh guá lim ka-pi | Gōo-ge̍h-tsueh uá lim ko-pi |

#### Format

Expand Down Expand Up @@ -185,9 +186,9 @@ c.get(input);

變調規則也會隨著選的方言而有所改變。

| 文本 | 無變調 | south | north |
| ---- | ------- | ------- | ------- |
| 台灣 | Tâi-uân | Tāi-uân | Tài-uân |
| 文本 | 無變調 | south | north / singapore |
| ---- | ------- | ------- | ----------------- |
| 台灣 | Tâi-uân | Tāi-uân | Tài-uân |

#### Punctuation

Expand Down Expand Up @@ -279,6 +280,10 @@ c = new Converter({ dialect: 'north' });
c.get("我欲用箸食魚");
>> Guá bueh īng tū tsia̍h hû

c = new Converter({ dialect: 'singapore' });
c.get("我欲用箸食魚");
>> Uá bueh ēng tū tsia̍h hû

//// Format
c = new Converter(); // 佇 Tailo 中,format 預設值: mark
c.get("生日快樂");
Expand Down Expand Up @@ -446,5 +451,6 @@ isCjk('我食pháng');
[ipa-wiki]: https://zh.wikipedia.org/zh-tw/%E5%9C%8B%E9%9A%9B%E9%9F%B3%E6%A8%99
[zhangzhou-wiki]: https://zh.wikipedia.org/zh-tw/%E6%BC%B3%E5%B7%9E%E8%AF%9D
[quanzhou-wiki]: https://zh.wikipedia.org/zh-tw/%E6%B3%89%E5%B7%9E%E8%AF%9D
[singapore-wiki]: https://zh.wikipedia.org/wiki/%E6%96%B0%E5%8A%A0%E5%9D%A1%E7%A6%8F%E5%BB%BA%E8%A9%B1
[nltk-tokenize]: https://nltk.org/api/nltk.tokenize.html
[sandhi-wiki]: https://zh.wikipedia.org/zh-tw/%E8%87%BA%E7%81%A3%E8%A9%B1#%E9%80%A3%E8%AE%80%E8%AE%8A%E8%AA%BF:~:text=%E3%80%82%5B144%5D-,%E9%80%A3%E8%AE%80%E8%AE%8A%E8%AA%BF,-%E9%80%A3%E8%AE%80%E8%AE%8A%E8%AA%BF
2 changes: 1 addition & 1 deletion taibun/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interface ConverterOptions {
system?: 'Tailo' | 'POJ' | 'Zhuyin' | 'TLPA' | 'Pingyim' | 'Tongiong' | 'IPA';
dialect?: 'south' | 'north';
dialect?: 'south' | 'north' | 'singapore';
format?: 'mark' | 'number' | 'strip';
delimiter?: string;
sandhi?: 'auto' | 'none' | 'excLast' | 'inclLast';
Expand Down
2 changes: 1 addition & 1 deletion taibun/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function toTraditional(input) {
Description: Converts Chinese characters to Taiwanese Hokkien phonetic transcriptions.
Supports both Traditional and Simplified characters.
Invariant: system = `Tailo` (default), `POJ`, `Zhuyin`, `TLPA`, `Pingyim`, `Tongiong`, `IPA`
dialect = `south` (Zhangzhou-leaning, default), `north` (Quanzhou-leaning)
dialect = `south` (Zhangzhou-leaning, default), `north` (Quanzhou-leaning), `singapore` (Quanzhou-leaning with Singaporean characteristics)
format = `mark` (diacritical), `number` (numeric), `strip` (no tones)
delimiter = String that replaces the default delimiter
sandhi = `auto`, `none`, `excLast`, `inclLast`
Expand Down
10 changes: 10 additions & 0 deletions tests/singapore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ test('sandhi', () => {
});
});

test('additional vocabulary', () => {
const c = new Converter({ dialect: "Singapore", punctuation: 'none' });
const kos = ['我', '你', '甚物', '食物'];
const expectedResults = ['uá', 'lú', 'sīm-mi̍h', 'si̍t-bu̍t'];

kos.forEach((ko, index) => {
expect(c.get(ko)).toBe(expectedResults[index]);
});
});

test('kopi', () => {
const c = new Converter({ dialect: "Singapore", punctuation: 'none' });
const kos = ['咖啡', '烏咖啡', '咖啡杯', '咖哩', '咖咖仔'];
Expand Down

0 comments on commit 33a72be

Please sign in to comment.