twfilter 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -1
- data/LICENSE +1 -1
- data/NOTICES.md +28 -15
- data/README.md +602 -191
- data/lib/twfilter/checks/erhua.rb +14 -12
- data/lib/twfilter/checks/lexicon.rb +6 -6
- data/lib/twfilter/checks/script.rb +5 -4
- data/lib/twfilter/checks/shape.rb +2 -2
- data/lib/twfilter/data/MANIFEST.json +17 -13
- data/lib/twfilter/data/admitted_uncharted.txt +1 -0
- data/lib/twfilter/data/erhua.txt +3 -0
- data/lib/twfilter/data/erhua_headed.txt +1 -0
- data/lib/twfilter/data/mainland_exceptions.tsv +17 -3
- data/lib/twfilter/data/mainland_hard.tsv +0 -5
- data/lib/twfilter/data/mainland_soft.tsv +5 -0
- data/lib/twfilter/evidence.rb +14 -4
- data/lib/twfilter/subject.rb +40 -2
- data/lib/twfilter/tables.rb +16 -12
- data/lib/twfilter/version.rb +1 -1
- data/lib/twfilter.rb +3 -2
- data/sig/twfilter.rbs +15 -1
- metadata +13 -9
- data/lib/twfilter/data/erhua_tailed.txt +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d715cf4f41b534f447f55d7a402d7d8c957c98890d040ebe0ac7ed2b74d483f7
|
|
4
|
+
data.tar.gz: 6e87f53daf407b0ff3dcfbc2f2bc05b04e95300d359b5e218f3fc1cbf319f285
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 742da720b6e5f43b4044cd0753a07b3c8ce2ed82b3bafe4d4d7feb1f5de06f5e3a9358aa409dd2b07c66c4d087c72dea4ab580a1276343502de54030d3e3b620
|
|
7
|
+
data.tar.gz: 87457bdd4616fa2c330ebdfd0465335f929f83719ca1a024d449bdfcabd1b6e0936bf03eebae1be1f83161821192fb16429187640c5d76024b480061baed001f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 — 2026-12-06
|
|
4
|
+
|
|
5
|
+
Measured on an evaluation set rebuilt from official public sources (`tools/benchmark/`):
|
|
6
|
+
367 929 native Taiwanese sentences, 44 468 mainland sentences converted by OpenCC in three
|
|
7
|
+
variants (133 399 rows), 13 978 Hong Kong sentences.
|
|
8
|
+
|
|
9
|
+
- Checks run on the Unicode NFC form of the input, so CJK compatibility ideographs (U+F900–
|
|
10
|
+
U+FAFF) are judged as the unified characters. `Report#text` is the caller's string
|
|
11
|
+
unchanged, and finding details quote the caller's spelling (`Subject#source`,
|
|
12
|
+
`Subject#original`, `Subject#quote`)
|
|
13
|
+
- 〇 (U+3007) is accepted at the 常用 tier (`admitted_uncharted.txt`)
|
|
14
|
+
- Erhua is a list of forms, 玩兒 事兒 點兒, suppressed where 兒 opens a root such as 兒童 or
|
|
15
|
+
兒藝 (`erhua.txt`, `erhua_headed.txt`). `erhua_tailed.txt` and `Checks::Erhua.tailed` are
|
|
16
|
+
removed. 這兒, 那兒, 哪兒, 塊兒 and 會兒 are not listed: each occurs in native text
|
|
17
|
+
- Five lexical pairs move from the hard to the soft band because Taiwanese writers use them:
|
|
18
|
+
錄像, 複印, 裏頭, 身份證, 初中 (144 hard, 43 soft)
|
|
19
|
+
- 22 masks for marker collisions attested in native text, among them 博客來, 內存入, 數字段,
|
|
20
|
+
身份證明, 互聯網大學, 洪水平原 (水平原), 社交互, 交互計算 (`mainland_exceptions.tsv`, 20 rows)
|
|
21
|
+
- 蛤 counts as a particle only when no Han character is adjacent; 文蛤 and 蛤蜊 no longer count
|
|
22
|
+
as Taiwan evidence (native pool 68 → 0 sentences, `s2twp` 24 → 0)
|
|
23
|
+
- `tools/build_tables.rb` derives every table from `tools/input/` alone and reproduces the
|
|
24
|
+
0.1.0 tables byte for byte (digest `d2594f83346f1e9e`) before applying the changes above.
|
|
25
|
+
A spec checks that the shipped tables equal a fresh build
|
|
26
|
+
- `Tables.names` and `TWFilter.provenance` consider only `*.txt` and `*.tsv` files, so a
|
|
27
|
+
checkout of the dataset works as `Tables.dir`; a `.add` or `.remove` suffix counts only
|
|
28
|
+
directly before the extension
|
|
29
|
+
- `TWFILTER_OVERLAY_DIR` is read on first use; it was ignored until a table source changed
|
|
30
|
+
- README states the limit of sentence-level filtering for converted mainland text
|
|
31
|
+
- Requires Ruby 3.4 or later
|
|
32
|
+
|
|
33
|
+
Acceptance on the test part of the evaluation set, `corpus` policy, provenance checks only,
|
|
34
|
+
95 % Wilson intervals:
|
|
35
|
+
|
|
36
|
+
| class | n | 0.1.0 | 0.2.0 |
|
|
37
|
+
| -------------------------- | -----: | ---------------------: | ---------------------: |
|
|
38
|
+
| native, Common Voice zh-TW | 7 454 | 99.72 % [99.57, 99.82] | 99.85 % [99.74, 99.92] |
|
|
39
|
+
| native, statutes | 2 500 | 99.96 % [99.77, 99.99] | 99.96 % [99.77, 99.99] |
|
|
40
|
+
| native, press releases | 2 500 | 98.60 % [98.06, 98.99] | 98.84 % [98.34, 99.19] |
|
|
41
|
+
| native, all | 12 454 | 99.54 % [99.41, 99.65] | 99.67 % [99.55, 99.76] |
|
|
42
|
+
| converted, `s2t` | 10 000 | 76.94 % [76.10, 77.76] | 77.06 % [76.23, 77.87] |
|
|
43
|
+
| converted, `s2tw` | 10 000 | 98.29 % [98.02, 98.53] | 98.53 % [98.27, 98.75] |
|
|
44
|
+
| converted, `s2twp` | 10 000 | 99.36 % [99.18, 99.50] | 99.58 % [99.43, 99.69] |
|
|
45
|
+
| Hong Kong | 6 853 | 50.68 % [49.49, 51.86] | 50.87 % [49.68, 52.05] |
|
|
46
|
+
|
|
47
|
+
Native sentences rejected, by code, over all 367 929 native sentences (`corpus`):
|
|
48
|
+
|
|
49
|
+
| code | 0.1.0 | 0.2.0 |
|
|
50
|
+
| ----------------------- | ----: | ----: |
|
|
51
|
+
| `unlisted` | 1 818 | 1 701 |
|
|
52
|
+
| `erhua` | 501 | 1 |
|
|
53
|
+
| `simplified` | 367 | 367 |
|
|
54
|
+
| `converted_orthography` | 108 | 108 |
|
|
55
|
+
| `mainland` | 80 | 17 |
|
|
56
|
+
| `cantonese` | 4 | 4 |
|
|
57
|
+
| `literary_density` | 4 | 4 |
|
|
58
|
+
|
|
59
|
+
The masks, the five moved pairs, the erhua list and 〇 were chosen with the whole set in view,
|
|
60
|
+
test part included. The native figures above are therefore in-sample for those changes and
|
|
61
|
+
overstate what a fresh sample would show. Converted acceptance rises by 0.1–0.2 points,
|
|
62
|
+
mostly because the 0.1.0 erhua rule rejected transliterated names in converted text
|
|
63
|
+
(帖木兒, 鹿兒島). The 17 remaining `mainland` rejections are mainland vocabulary in Taiwanese
|
|
64
|
+
text (互聯網, 激光, 信息).
|
|
65
|
+
|
|
3
66
|
## 0.1.0 — 2026-08-01
|
|
4
67
|
|
|
5
68
|
First release.
|
|
@@ -27,7 +90,7 @@ First release.
|
|
|
27
90
|
(`TWFilter::Punctuation`)
|
|
28
91
|
- Sentence segmentation over terminator and closer classes, linear in input length
|
|
29
92
|
(`TWFilter::Sentences`)
|
|
30
|
-
- Block-level
|
|
93
|
+
- Block-level judgment with a contamination tolerance and an evidence floor
|
|
31
94
|
(`TWFilter::Block`)
|
|
32
95
|
- Three policies — `corpus`, `publishable`, `permissive` — as immutable value objects
|
|
33
96
|
(`TWFilter::Policy`)
|
data/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026 Den Patin <hi@dpat.in>
|
|
3
|
+
Copyright (c) 2026 Den Patin 丁丹旭 <hi@dpat.in>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
6
6
|
software and associated documentation files (the "Software"), to deal in the Software
|
data/NOTICES.md
CHANGED
|
@@ -6,13 +6,13 @@ commercial products**, subject to the attribution stated below.
|
|
|
6
6
|
|
|
7
7
|
## Table provenance
|
|
8
8
|
|
|
9
|
-
| Table
|
|
10
|
-
|
|
|
11
|
-
| `moe_common.txt`, `moe_secondary.txt`, `moe_rare.txt` | 全字庫 CNS 11643, field `CNS_source`, entries marked 常用國字標準字體表 / 次常用國字標準字體表 / 罕用字體表 | OGDL v1.0
|
|
12
|
-
| `moe_exception.txt`
|
|
13
|
-
| `simplified_only.txt`
|
|
14
|
-
| `mainland_hard.tsv`, `mainland_soft.tsv`
|
|
15
|
-
| all other tables
|
|
9
|
+
| Table | Source | Terms |
|
|
10
|
+
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------- |
|
|
11
|
+
| `moe_common.txt`, `moe_secondary.txt`, `moe_rare.txt` | 全字庫 CNS 11643, field `CNS_source`, entries marked 常用國字標準字體表 / 次常用國字標準字體表 / 罕用字體表 | OGDL v1.0 |
|
|
12
|
+
| `moe_exception.txt` | Characters occurring as headwords in the MOE dictionaries but in none of the three charts | Factual inventory; see below |
|
|
13
|
+
| `simplified_only.txt` | Computed from OpenCC `STCharacters` ∖ `TSCharacters` | Apache-2.0 |
|
|
14
|
+
| `mainland_hard.tsv`, `mainland_soft.tsv` | Candidate pairs from OpenCC `TWPhrases` and from hand curation; retention and banding computed by me | Apache-2.0 |
|
|
15
|
+
| all other tables | Authored by me | MIT |
|
|
16
16
|
|
|
17
17
|
## OGDL v1.0 — 政府資料開放授權條款 第1版
|
|
18
18
|
|
|
@@ -41,9 +41,10 @@ Per §4(b), the derived files are **modified**:
|
|
|
41
41
|
|
|
42
42
|
- `simplified_only.txt` is a set difference over two OpenCC conversion tables, further
|
|
43
43
|
reduced by 16 forms standard in Taiwan. It is not an OpenCC table and does not convert.
|
|
44
|
-
- `mainland_hard.tsv` and `mainland_soft.tsv`
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
- `mainland_hard.tsv` (144 pairs) and `mainland_soft.tsv` (43 pairs) hold a selection of
|
|
45
|
+
candidate pairs, many of them from `TWPhrases`. The selection, the banding and the
|
|
46
|
+
attestation counts are mine; the counts are frozen from the 0.1.0 grading. Most `TWPhrases`
|
|
47
|
+
pairs are left out because it is an orthographic mapping, not a provenance signal.
|
|
47
48
|
|
|
48
49
|
Attribution string:
|
|
49
50
|
|
|
@@ -65,19 +66,31 @@ Attribution is given regardless:
|
|
|
65
66
|
```
|
|
66
67
|
|
|
67
68
|
The ND term restricts distribution of adaptations. No dictionary text is shipped here, so
|
|
68
|
-
the term is not engaged. Consumers who ship dictionary
|
|
69
|
+
the term is not engaged. Consumers who ship dictionary _content_ must satisfy it
|
|
69
70
|
themselves.
|
|
70
71
|
|
|
71
72
|
## My own tables
|
|
72
73
|
|
|
73
|
-
`variants_used_in_taiwan.txt`, `
|
|
74
|
-
`
|
|
75
|
-
`
|
|
76
|
-
`
|
|
74
|
+
`variants_used_in_taiwan.txt`, `admitted_uncharted.txt`, `converted_orthography.txt`,
|
|
75
|
+
`cantonese.txt`, `wenyan.txt`, `mainland_exceptions.tsv`, `regional_hard.tsv`,
|
|
76
|
+
`foreign_topics.txt`, `taiwan_markers.txt`, `taiwan_lexicon.txt`, `taiwan_particles.txt`,
|
|
77
|
+
`taiwan_grammar.txt`, `erhua.txt`, `erhua_headed.txt` — MIT, same as the code.
|
|
77
78
|
|
|
78
79
|
These are word lists. Individual words are not copyrightable; the selection and arrangement
|
|
79
80
|
are mine and are released under MIT.
|
|
80
81
|
|
|
82
|
+
## Build inputs in the repository
|
|
83
|
+
|
|
84
|
+
`tools/input/` holds the inputs from which `tools/build_tables.rb` derives the tables. It is
|
|
85
|
+
part of the source repository, not of the packaged gem.
|
|
86
|
+
|
|
87
|
+
- `tools/input/moe/*.json` — the three chart lists, OGDL v1.0, attribution as above, and the 12
|
|
88
|
+
exception characters, a factual inventory as described above.
|
|
89
|
+
- `tools/input/opencc/STCharacters.txt`, `TSCharacters.txt` — unmodified OpenCC files,
|
|
90
|
+
Apache-2.0, attribution as above.
|
|
91
|
+
- `tools/input/lexicon/*` — the 0.1.0 lexical tables, under the terms of the tables they
|
|
92
|
+
produce.
|
|
93
|
+
|
|
81
94
|
## What a consumer must do
|
|
82
95
|
|
|
83
96
|
Shipping this gem in a commercial product requires reproducing two attribution strings —
|