@kensio/pinyinjs 1.7.4 → 1.7.6
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.
- package/README.md +128 -123
- package/data/full.entries +2595 -2595
- package/data/manifest.json +5 -5
- package/data/script.map +66 -3
- package/dist/accuracy/score-case.d.ts +23 -0
- package/dist/accuracy/score-case.d.ts.map +1 -0
- package/dist/accuracy/score-case.js +63 -0
- package/dist/accuracy/score-case.js.map +1 -0
- package/dist/accuracy/score.d.ts +1 -8
- package/dist/accuracy/score.d.ts.map +1 -1
- package/dist/accuracy/score.js +1 -55
- package/dist/accuracy/score.js.map +1 -1
- package/dist/cli/arguments.d.ts +4 -290
- package/dist/cli/arguments.d.ts.map +1 -1
- package/dist/cli/arguments.js +5 -357
- package/dist/cli/arguments.js.map +1 -1
- package/dist/cli/check-command.d.ts +9 -0
- package/dist/cli/check-command.d.ts.map +1 -0
- package/dist/cli/check-command.js +95 -0
- package/dist/cli/check-command.js.map +1 -0
- package/dist/cli/cli-input.d.ts +49 -0
- package/dist/cli/cli-input.d.ts.map +1 -0
- package/dist/cli/cli-input.js +31 -0
- package/dist/cli/cli-input.js.map +1 -0
- package/dist/cli/command.d.ts +97 -0
- package/dist/cli/command.d.ts.map +1 -0
- package/dist/cli/command.js +40 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/commands.d.ts +7 -110
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +14 -991
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/convert-command.d.ts +6 -0
- package/dist/cli/convert-command.d.ts.map +1 -0
- package/dist/cli/convert-command.js +52 -0
- package/dist/cli/convert-command.js.map +1 -0
- package/dist/cli/environment.d.ts +1 -1
- package/dist/cli/environment.d.ts.map +1 -1
- package/dist/cli/explain-command.d.ts +6 -0
- package/dist/cli/explain-command.d.ts.map +1 -0
- package/dist/cli/explain-command.js +40 -0
- package/dist/cli/explain-command.js.map +1 -0
- package/dist/cli/explain-syllable.d.ts +10 -0
- package/dist/cli/explain-syllable.d.ts.map +1 -0
- package/dist/cli/explain-syllable.js +70 -0
- package/dist/cli/explain-syllable.js.map +1 -0
- package/dist/cli/flag-help.d.ts +18 -0
- package/dist/cli/flag-help.d.ts.map +1 -0
- package/dist/cli/flag-help.js +78 -0
- package/dist/cli/flag-help.js.map +1 -0
- package/dist/cli/flag-lists.d.ts +49 -0
- package/dist/cli/flag-lists.d.ts.map +1 -0
- package/dist/cli/flag-lists.js +58 -0
- package/dist/cli/flag-lists.js.map +1 -0
- package/dist/cli/flag-values.d.ts +44 -0
- package/dist/cli/flag-values.d.ts.map +1 -0
- package/dist/cli/flag-values.js +56 -0
- package/dist/cli/flag-values.js.map +1 -0
- package/dist/cli/flags.d.ts +193 -0
- package/dist/cli/flags.d.ts.map +1 -0
- package/dist/cli/flags.js +133 -0
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/format-options.d.ts +29 -0
- package/dist/cli/format-options.d.ts.map +1 -0
- package/dist/cli/format-options.js +72 -0
- package/dist/cli/format-options.js.map +1 -0
- package/dist/cli/global-help.d.ts +23 -0
- package/dist/cli/global-help.d.ts.map +1 -0
- package/dist/cli/global-help.js +40 -0
- package/dist/cli/global-help.js.map +1 -0
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +5 -99
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/html-commands.d.ts +13 -0
- package/dist/cli/html-commands.d.ts.map +1 -0
- package/dist/cli/html-commands.js +49 -0
- package/dist/cli/html-commands.js.map +1 -0
- package/dist/cli/info-command.d.ts +7 -0
- package/dist/cli/info-command.d.ts.map +1 -0
- package/dist/cli/info-command.js +39 -0
- package/dist/cli/info-command.js.map +1 -0
- package/dist/cli/lookup-commands.d.ts +10 -0
- package/dist/cli/lookup-commands.d.ts.map +1 -0
- package/dist/cli/lookup-commands.js +101 -0
- package/dist/cli/lookup-commands.js.map +1 -0
- package/dist/cli/match-command.d.ts +11 -0
- package/dist/cli/match-command.d.ts.map +1 -0
- package/dist/cli/match-command.js +76 -0
- package/dist/cli/match-command.js.map +1 -0
- package/dist/cli/number-command.d.ts +12 -0
- package/dist/cli/number-command.d.ts.map +1 -0
- package/dist/cli/number-command.js +89 -0
- package/dist/cli/number-command.js.map +1 -0
- package/dist/cli/options.d.ts +30 -0
- package/dist/cli/options.d.ts.map +1 -0
- package/dist/cli/options.js +54 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/cli/run-command.d.ts +24 -0
- package/dist/cli/run-command.d.ts.map +1 -0
- package/dist/cli/run-command.js +40 -0
- package/dist/cli/run-command.js.map +1 -0
- package/dist/cli/run.d.ts +4 -42
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +6 -61
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/script-command.d.ts +10 -0
- package/dist/cli/script-command.d.ts.map +1 -0
- package/dist/cli/script-command.js +58 -0
- package/dist/cli/script-command.js.map +1 -0
- package/dist/cli/segment-command.d.ts +11 -0
- package/dist/cli/segment-command.d.ts.map +1 -0
- package/dist/cli/segment-command.js +53 -0
- package/dist/cli/segment-command.js.map +1 -0
- package/dist/cli/slug-command.d.ts +10 -0
- package/dist/cli/slug-command.d.ts.map +1 -0
- package/dist/cli/slug-command.js +28 -0
- package/dist/cli/slug-command.js.map +1 -0
- package/dist/cli/syllable-command.d.ts +14 -0
- package/dist/cli/syllable-command.d.ts.map +1 -0
- package/dist/cli/syllable-command.js +82 -0
- package/dist/cli/syllable-command.js.map +1 -0
- package/dist/cli/system-table.d.ts +12 -0
- package/dist/cli/system-table.d.ts.map +1 -0
- package/dist/cli/system-table.js +48 -0
- package/dist/cli/system-table.js.map +1 -0
- package/dist/cli/systems.d.ts +57 -0
- package/dist/cli/systems.d.ts.map +1 -0
- package/dist/cli/systems.js +27 -0
- package/dist/cli/systems.js.map +1 -0
- package/dist/cli/transcribe-command.d.ts +18 -0
- package/dist/cli/transcribe-command.d.ts.map +1 -0
- package/dist/cli/transcribe-command.js +86 -0
- package/dist/cli/transcribe-command.js.map +1 -0
- package/dist/cli/transcribe-reading.d.ts +15 -0
- package/dist/cli/transcribe-reading.d.ts.map +1 -0
- package/dist/cli/transcribe-reading.js +90 -0
- package/dist/cli/transcribe-reading.js.map +1 -0
- package/dist/cli/transcribe-rows.d.ts +26 -0
- package/dist/cli/transcribe-rows.d.ts.map +1 -0
- package/dist/cli/transcribe-rows.js +30 -0
- package/dist/cli/transcribe-rows.js.map +1 -0
- package/dist/cli/usage-error.d.ts +9 -0
- package/dist/cli/usage-error.d.ts.map +1 -0
- package/dist/cli/usage-error.js +9 -0
- package/dist/cli/usage-error.js.map +1 -0
- package/dist/decode/alternatives.d.ts +16 -0
- package/dist/decode/alternatives.d.ts.map +1 -0
- package/dist/decode/alternatives.js +31 -0
- package/dist/decode/alternatives.js.map +1 -0
- package/dist/decode/chang-context.d.ts +27 -0
- package/dist/decode/chang-context.d.ts.map +1 -0
- package/dist/decode/chang-context.js +66 -0
- package/dist/decode/chang-context.js.map +1 -0
- package/dist/decode/chang-rule.d.ts +37 -0
- package/dist/decode/chang-rule.d.ts.map +1 -0
- package/dist/decode/chang-rule.js +169 -0
- package/dist/decode/chang-rule.js.map +1 -0
- package/dist/decode/confidence.d.ts +11 -3
- package/dist/decode/confidence.d.ts.map +1 -1
- package/dist/decode/confidence.js +14 -121
- package/dist/decode/confidence.js.map +1 -1
- package/dist/decode/convert-options.d.ts +116 -0
- package/dist/decode/convert-options.d.ts.map +1 -0
- package/dist/decode/convert-options.js +2 -0
- package/dist/decode/convert-options.js.map +1 -0
- package/dist/decode/convert-pipeline.d.ts +18 -0
- package/dist/decode/convert-pipeline.d.ts.map +1 -0
- package/dist/decode/convert-pipeline.js +67 -0
- package/dist/decode/convert-pipeline.js.map +1 -0
- package/dist/decode/convert.d.ts +9 -118
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +5 -453
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/de-rule.d.ts +54 -0
- package/dist/decode/de-rule.d.ts.map +1 -0
- package/dist/decode/de-rule.js +113 -0
- package/dist/decode/de-rule.js.map +1 -0
- package/dist/decode/decode.d.ts +2 -15
- package/dist/decode/decode.d.ts.map +1 -1
- package/dist/decode/decode.js +2 -121
- package/dist/decode/decode.js.map +1 -1
- package/dist/decode/decoders.d.ts +32 -0
- package/dist/decode/decoders.d.ts.map +1 -0
- package/dist/decode/decoders.js +29 -0
- package/dist/decode/decoders.js.map +1 -0
- package/dist/decode/edge-context.d.ts +38 -0
- package/dist/decode/edge-context.d.ts.map +1 -0
- package/dist/decode/edge-context.js +57 -0
- package/dist/decode/edge-context.js.map +1 -0
- package/dist/decode/hint-lattice.d.ts +45 -0
- package/dist/decode/hint-lattice.d.ts.map +1 -0
- package/dist/decode/hint-lattice.js +154 -0
- package/dist/decode/hint-lattice.js.map +1 -0
- package/dist/decode/hints.d.ts +2 -45
- package/dist/decode/hints.d.ts.map +1 -1
- package/dist/decode/hints.js +1 -139
- package/dist/decode/hints.js.map +1 -1
- package/dist/decode/jiao-rule.d.ts +64 -0
- package/dist/decode/jiao-rule.d.ts.map +1 -0
- package/dist/decode/jiao-rule.js +115 -0
- package/dist/decode/jiao-rule.js.map +1 -0
- package/dist/decode/lattice-costs.d.ts +55 -0
- package/dist/decode/lattice-costs.d.ts.map +1 -0
- package/dist/decode/lattice-costs.js +90 -0
- package/dist/decode/lattice-costs.js.map +1 -0
- package/dist/decode/lattice-edges.d.ts +29 -0
- package/dist/decode/lattice-edges.d.ts.map +1 -0
- package/dist/decode/lattice-edges.js +78 -0
- package/dist/decode/lattice-edges.js.map +1 -0
- package/dist/decode/lattice-slice.d.ts +37 -0
- package/dist/decode/lattice-slice.d.ts.map +1 -0
- package/dist/decode/lattice-slice.js +43 -0
- package/dist/decode/lattice-slice.js.map +1 -0
- package/dist/decode/lattice-types.d.ts +101 -0
- package/dist/decode/lattice-types.d.ts.map +1 -0
- package/dist/decode/lattice-types.js +63 -0
- package/dist/decode/lattice-types.js.map +1 -0
- package/dist/decode/lattice.d.ts +2 -59
- package/dist/decode/lattice.d.ts.map +1 -1
- package/dist/decode/lattice.js +2 -118
- package/dist/decode/lattice.js.map +1 -1
- package/dist/decode/number-pieces.d.ts +62 -0
- package/dist/decode/number-pieces.d.ts.map +1 -0
- package/dist/decode/number-pieces.js +106 -0
- package/dist/decode/number-pieces.js.map +1 -0
- package/dist/decode/numbers.d.ts +53 -0
- package/dist/decode/numbers.d.ts.map +1 -0
- package/dist/decode/numbers.js +69 -0
- package/dist/decode/numbers.js.map +1 -0
- package/dist/decode/pieces.d.ts +78 -0
- package/dist/decode/pieces.d.ts.map +1 -0
- package/dist/decode/pieces.js +136 -0
- package/dist/decode/pieces.js.map +1 -0
- package/dist/decode/polyphone-rules.d.ts +11 -0
- package/dist/decode/polyphone-rules.d.ts.map +1 -0
- package/dist/decode/polyphone-rules.js +11 -0
- package/dist/decode/polyphone-rules.js.map +1 -0
- package/dist/decode/reading-rules.d.ts +3 -126
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +8 -434
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/rules.d.ts +1 -17
- package/dist/decode/rules.d.ts.map +1 -1
- package/dist/decode/rules.js +1 -43
- package/dist/decode/rules.js.map +1 -1
- package/dist/decode/run-lattice.d.ts +52 -0
- package/dist/decode/run-lattice.d.ts.map +1 -0
- package/dist/decode/run-lattice.js +91 -0
- package/dist/decode/run-lattice.js.map +1 -0
- package/dist/decode/run-words.d.ts +17 -0
- package/dist/decode/run-words.d.ts.map +1 -0
- package/dist/decode/run-words.js +29 -0
- package/dist/decode/run-words.js.map +1 -0
- package/dist/decode/sandhi-input.d.ts +30 -0
- package/dist/decode/sandhi-input.d.ts.map +1 -0
- package/dist/decode/sandhi-input.js +35 -0
- package/dist/decode/sandhi-input.js.map +1 -0
- package/dist/decode/sandhi-tones.d.ts +97 -0
- package/dist/decode/sandhi-tones.d.ts.map +1 -0
- package/dist/decode/sandhi-tones.js +139 -0
- package/dist/decode/sandhi-tones.js.map +1 -0
- package/dist/decode/sandhi.d.ts +10 -7
- package/dist/decode/sandhi.d.ts.map +1 -1
- package/dist/decode/sandhi.js +11 -88
- package/dist/decode/sandhi.js.map +1 -1
- package/dist/decode/script-types.d.ts +76 -0
- package/dist/decode/script-types.d.ts.map +1 -0
- package/dist/decode/script-types.js +35 -0
- package/dist/decode/script-types.js.map +1 -0
- package/dist/decode/script-words.d.ts +32 -0
- package/dist/decode/script-words.d.ts.map +1 -0
- package/dist/decode/script-words.js +77 -0
- package/dist/decode/script-words.js.map +1 -0
- package/dist/decode/script.d.ts +3 -73
- package/dist/decode/script.d.ts.map +1 -1
- package/dist/decode/script.js +3 -109
- package/dist/decode/script.js.map +1 -1
- package/dist/decode/tan-rule.d.ts +68 -0
- package/dist/decode/tan-rule.d.ts.map +1 -0
- package/dist/decode/tan-rule.js +131 -0
- package/dist/decode/tan-rule.js.map +1 -0
- package/dist/decode/write-run.d.ts +21 -0
- package/dist/decode/write-run.d.ts.map +1 -0
- package/dist/decode/write-run.js +42 -0
- package/dist/decode/write-run.js.map +1 -0
- package/dist/dictionary/artifact-claims.d.ts +25 -0
- package/dist/dictionary/artifact-claims.d.ts.map +1 -0
- package/dist/dictionary/artifact-claims.js +47 -0
- package/dist/dictionary/artifact-claims.js.map +1 -0
- package/dist/dictionary/artifact-format.d.ts +86 -0
- package/dist/dictionary/artifact-format.d.ts.map +1 -0
- package/dist/dictionary/artifact-format.js +91 -0
- package/dist/dictionary/artifact-format.js.map +1 -0
- package/dist/dictionary/artifact-read.d.ts +34 -0
- package/dist/dictionary/artifact-read.d.ts.map +1 -0
- package/dist/dictionary/artifact-read.js +114 -0
- package/dist/dictionary/artifact-read.js.map +1 -0
- package/dist/dictionary/artifact.d.ts +4 -63
- package/dist/dictionary/artifact.d.ts.map +1 -1
- package/dist/dictionary/artifact.js +12 -229
- package/dist/dictionary/artifact.js.map +1 -1
- package/dist/dictionary/assertions.d.ts +5 -57
- package/dist/dictionary/assertions.d.ts.map +1 -1
- package/dist/dictionary/assertions.js +4 -317
- package/dist/dictionary/assertions.js.map +1 -1
- package/dist/dictionary/build-assertions.d.ts +12 -0
- package/dist/dictionary/build-assertions.d.ts.map +1 -0
- package/dist/dictionary/build-assertions.js +13 -0
- package/dist/dictionary/build-assertions.js.map +1 -0
- package/dist/dictionary/built-dictionary.d.ts +46 -0
- package/dist/dictionary/built-dictionary.d.ts.map +1 -0
- package/dist/dictionary/built-dictionary.js +97 -0
- package/dist/dictionary/built-dictionary.js.map +1 -0
- package/dist/dictionary/cedict-senses.d.ts +87 -0
- package/dist/dictionary/cedict-senses.d.ts.map +1 -0
- package/dist/dictionary/cedict-senses.js +126 -0
- package/dist/dictionary/cedict-senses.js.map +1 -0
- package/dist/dictionary/character-defaults.d.ts +26 -0
- package/dist/dictionary/character-defaults.d.ts.map +1 -0
- package/dist/dictionary/character-defaults.js +67 -0
- package/dist/dictionary/character-defaults.js.map +1 -0
- package/dist/dictionary/character-readings.d.ts +10 -0
- package/dist/dictionary/character-readings.d.ts.map +1 -0
- package/dist/dictionary/character-readings.js +25 -0
- package/dist/dictionary/character-readings.js.map +1 -0
- package/dist/dictionary/constituent-repair.d.ts +36 -0
- package/dist/dictionary/constituent-repair.d.ts.map +1 -0
- package/dist/dictionary/constituent-repair.js +117 -0
- package/dist/dictionary/constituent-repair.js.map +1 -0
- package/dist/dictionary/dictionary-entry.d.ts +37 -0
- package/dist/dictionary/dictionary-entry.d.ts.map +1 -0
- package/dist/dictionary/dictionary-entry.js +41 -0
- package/dist/dictionary/dictionary-entry.js.map +1 -0
- package/dist/dictionary/dictionary-readings.d.ts +56 -0
- package/dist/dictionary/dictionary-readings.d.ts.map +1 -0
- package/dist/dictionary/dictionary-readings.js +93 -0
- package/dist/dictionary/dictionary-readings.js.map +1 -0
- package/dist/dictionary/dictionary.d.ts +6 -60
- package/dist/dictionary/dictionary.d.ts.map +1 -1
- package/dist/dictionary/dictionary.js +9 -169
- package/dist/dictionary/dictionary.js.map +1 -1
- package/dist/dictionary/entry-invariants.d.ts +3 -0
- package/dist/dictionary/entry-invariants.d.ts.map +1 -0
- package/dist/dictionary/entry-invariants.js +67 -0
- package/dist/dictionary/entry-invariants.js.map +1 -0
- package/dist/dictionary/entry-lines.d.ts +35 -0
- package/dist/dictionary/entry-lines.d.ts.map +1 -0
- package/dist/dictionary/entry-lines.js +70 -0
- package/dist/dictionary/entry-lines.js.map +1 -0
- package/dist/dictionary/erhua-repair.d.ts +26 -0
- package/dist/dictionary/erhua-repair.d.ts.map +1 -0
- package/dist/dictionary/erhua-repair.js +49 -0
- package/dist/dictionary/erhua-repair.js.map +1 -0
- package/dist/dictionary/frequency-tones.d.ts +74 -0
- package/dist/dictionary/frequency-tones.d.ts.map +1 -0
- package/dist/dictionary/frequency-tones.js +128 -0
- package/dist/dictionary/frequency-tones.js.map +1 -0
- package/dist/dictionary/inventory-invariants.d.ts +3 -0
- package/dist/dictionary/inventory-invariants.d.ts.map +1 -0
- package/dist/dictionary/inventory-invariants.js +54 -0
- package/dist/dictionary/inventory-invariants.js.map +1 -0
- package/dist/dictionary/locale-candidates.d.ts +40 -0
- package/dist/dictionary/locale-candidates.d.ts.map +1 -0
- package/dist/dictionary/locale-candidates.js +77 -0
- package/dist/dictionary/locale-candidates.js.map +1 -0
- package/dist/dictionary/locale-segments.d.ts +47 -0
- package/dist/dictionary/locale-segments.d.ts.map +1 -0
- package/dist/dictionary/locale-segments.js +141 -0
- package/dist/dictionary/locale-segments.js.map +1 -0
- package/dist/dictionary/locale.d.ts +1 -21
- package/dist/dictionary/locale.d.ts.map +1 -1
- package/dist/dictionary/locale.js +9 -198
- package/dist/dictionary/locale.js.map +1 -1
- package/dist/dictionary/merge-types.d.ts +127 -0
- package/dist/dictionary/merge-types.d.ts.map +1 -0
- package/dist/dictionary/merge-types.js +35 -0
- package/dist/dictionary/merge-types.js.map +1 -0
- package/dist/dictionary/merge-walk.d.ts +27 -0
- package/dist/dictionary/merge-walk.d.ts.map +1 -0
- package/dist/dictionary/merge-walk.js +49 -0
- package/dist/dictionary/merge-walk.js.map +1 -0
- package/dist/dictionary/merge-word.d.ts +7 -0
- package/dist/dictionary/merge-word.d.ts.map +1 -0
- package/dist/dictionary/merge-word.js +91 -0
- package/dist/dictionary/merge-word.js.map +1 -0
- package/dist/dictionary/merge.d.ts +5 -62
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +32 -725
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/proper-noun.d.ts +28 -0
- package/dist/dictionary/proper-noun.d.ts.map +1 -0
- package/dist/dictionary/proper-noun.js +43 -0
- package/dist/dictionary/proper-noun.js.map +1 -0
- package/dist/dictionary/reading-agreement.d.ts +71 -0
- package/dist/dictionary/reading-agreement.d.ts.map +1 -0
- package/dist/dictionary/reading-agreement.js +156 -0
- package/dist/dictionary/reading-agreement.js.map +1 -0
- package/dist/dictionary/script-conversion.d.ts +28 -0
- package/dist/dictionary/script-conversion.d.ts.map +1 -0
- package/dist/dictionary/script-conversion.js +58 -0
- package/dist/dictionary/script-conversion.js.map +1 -0
- package/dist/dictionary/script-pairings.d.ts +74 -0
- package/dist/dictionary/script-pairings.d.ts.map +1 -0
- package/dist/dictionary/script-pairings.js +120 -0
- package/dist/dictionary/script-pairings.js.map +1 -0
- package/dist/dictionary/script-tables.d.ts.map +1 -1
- package/dist/dictionary/script-tables.js +2 -165
- package/dist/dictionary/script-tables.js.map +1 -1
- package/dist/dictionary/taiwan-reading.d.ts +8 -0
- package/dist/dictionary/taiwan-reading.d.ts.map +1 -0
- package/dist/dictionary/taiwan-reading.js +38 -0
- package/dist/dictionary/taiwan-reading.js.map +1 -0
- package/dist/dictionary/tone-invariants.d.ts +3 -0
- package/dist/dictionary/tone-invariants.d.ts.map +1 -0
- package/dist/dictionary/tone-invariants.js +64 -0
- package/dist/dictionary/tone-invariants.js.map +1 -0
- package/dist/dictionary/traditional-form.d.ts +21 -0
- package/dist/dictionary/traditional-form.d.ts.map +1 -0
- package/dist/dictionary/traditional-form.js +59 -0
- package/dist/dictionary/traditional-form.js.map +1 -0
- package/dist/dictionary/traditional-ranking.d.ts +22 -0
- package/dist/dictionary/traditional-ranking.d.ts.map +1 -0
- package/dist/dictionary/traditional-ranking.js +74 -0
- package/dist/dictionary/traditional-ranking.js.map +1 -0
- package/dist/dictionary/traditional-table.d.ts +51 -0
- package/dist/dictionary/traditional-table.d.ts.map +1 -0
- package/dist/dictionary/traditional-table.js +98 -0
- package/dist/dictionary/traditional-table.js.map +1 -0
- package/dist/dictionary/traditional.d.ts +3 -56
- package/dist/dictionary/traditional.d.ts.map +1 -1
- package/dist/dictionary/traditional.js +3 -186
- package/dist/dictionary/traditional.js.map +1 -1
- package/dist/dictionary/variant-counts.d.ts +39 -0
- package/dist/dictionary/variant-counts.d.ts.map +1 -0
- package/dist/dictionary/variant-counts.js +38 -0
- package/dist/dictionary/variant-counts.js.map +1 -0
- package/dist/dictionary/word-reading.d.ts +26 -0
- package/dist/dictionary/word-reading.d.ts.map +1 -0
- package/dist/dictionary/word-reading.js +76 -0
- package/dist/dictionary/word-reading.js.map +1 -0
- package/dist/dictionary/word-readings.d.ts +15 -0
- package/dist/dictionary/word-readings.d.ts.map +1 -0
- package/dist/dictionary/word-readings.js +41 -0
- package/dist/dictionary/word-readings.js.map +1 -0
- package/dist/format/annotate.d.ts +90 -0
- package/dist/format/annotate.d.ts.map +1 -0
- package/dist/format/annotate.js +168 -0
- package/dist/format/annotate.js.map +1 -0
- package/dist/format/html.d.ts +15 -46
- package/dist/format/html.d.ts.map +1 -1
- package/dist/format/html.js +3 -162
- package/dist/format/html.js.map +1 -1
- package/dist/format/slug-hash.d.ts +51 -0
- package/dist/format/slug-hash.d.ts.map +1 -0
- package/dist/format/slug-hash.js +74 -0
- package/dist/format/slug-hash.js.map +1 -0
- package/dist/format/slug-options.d.ts +98 -0
- package/dist/format/slug-options.d.ts.map +1 -0
- package/dist/format/slug-options.js +2 -0
- package/dist/format/slug-options.js.map +1 -0
- package/dist/format/slug-words.d.ts +27 -0
- package/dist/format/slug-words.d.ts.map +1 -0
- package/dist/format/slug-words.js +0 -0
- package/dist/format/slug-words.js.map +1 -0
- package/dist/format/slug.d.ts +3 -128
- package/dist/format/slug.d.ts.map +1 -1
- package/dist/format/slug.js +0 -0
- package/dist/format/slug.js.map +1 -1
- package/dist/grade/check-readings.d.ts +41 -0
- package/dist/grade/check-readings.d.ts.map +1 -0
- package/dist/grade/check-readings.js +36 -0
- package/dist/grade/check-readings.js.map +1 -0
- package/dist/grade/check.d.ts +4 -4
- package/dist/grade/check.d.ts.map +1 -1
- package/dist/grade/check.js +5 -270
- package/dist/grade/check.js.map +1 -1
- package/dist/grade/pair-syllables.d.ts +48 -0
- package/dist/grade/pair-syllables.d.ts.map +1 -0
- package/dist/grade/pair-syllables.js +71 -0
- package/dist/grade/pair-syllables.js.map +1 -0
- package/dist/grade/reading-syllables.d.ts +62 -0
- package/dist/grade/reading-syllables.d.ts.map +1 -0
- package/dist/grade/reading-syllables.js +58 -0
- package/dist/grade/reading-syllables.js.map +1 -0
- package/dist/grade/reading-tolerance.d.ts +72 -0
- package/dist/grade/reading-tolerance.d.ts.map +1 -0
- package/dist/grade/reading-tolerance.js +107 -0
- package/dist/grade/reading-tolerance.js.map +1 -0
- package/dist/grade/typed-reading.d.ts +28 -0
- package/dist/grade/typed-reading.d.ts.map +1 -0
- package/dist/grade/typed-reading.js +36 -0
- package/dist/grade/typed-reading.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/numerals/numeral-parse.d.ts +32 -0
- package/dist/numerals/numeral-parse.d.ts.map +1 -0
- package/dist/numerals/numeral-parse.js +44 -0
- package/dist/numerals/numeral-parse.js.map +1 -0
- package/dist/numerals/numeral-shapes.d.ts +89 -0
- package/dist/numerals/numeral-shapes.d.ts.map +1 -0
- package/dist/numerals/numeral-shapes.js +99 -0
- package/dist/numerals/numeral-shapes.js.map +1 -0
- package/dist/numerals/numerals.d.ts.map +1 -1
- package/dist/numerals/numerals.js +2 -36
- package/dist/numerals/numerals.js.map +1 -1
- package/dist/numerals/read-numeral.d.ts +76 -0
- package/dist/numerals/read-numeral.d.ts.map +1 -0
- package/dist/numerals/read-numeral.js +88 -0
- package/dist/numerals/read-numeral.js.map +1 -0
- package/dist/numerals/text.d.ts +3 -37
- package/dist/numerals/text.d.ts.map +1 -1
- package/dist/numerals/text.js +3 -254
- package/dist/numerals/text.js.map +1 -1
- package/dist/numerals/time.d.ts +34 -0
- package/dist/numerals/time.d.ts.map +1 -0
- package/dist/numerals/time.js +93 -0
- package/dist/numerals/time.js.map +1 -0
- package/dist/orthography/address-grouping.d.ts +34 -0
- package/dist/orthography/address-grouping.d.ts.map +1 -0
- package/dist/orthography/address-grouping.js +52 -0
- package/dist/orthography/address-grouping.js.map +1 -0
- package/dist/orthography/grouping.d.ts +3 -87
- package/dist/orthography/grouping.d.ts.map +1 -1
- package/dist/orthography/grouping.js +4 -270
- package/dist/orthography/grouping.js.map +1 -1
- package/dist/orthography/place-grouping.d.ts +39 -0
- package/dist/orthography/place-grouping.d.ts.map +1 -0
- package/dist/orthography/place-grouping.js +83 -0
- package/dist/orthography/place-grouping.js.map +1 -0
- package/dist/orthography/word-grouping.d.ts +48 -0
- package/dist/orthography/word-grouping.d.ts.map +1 -0
- package/dist/orthography/word-grouping.js +147 -0
- package/dist/orthography/word-grouping.js.map +1 -0
- package/dist/script/conversion-format.d.ts +22 -0
- package/dist/script/conversion-format.d.ts.map +1 -0
- package/dist/script/conversion-format.js +22 -0
- package/dist/script/conversion-format.js.map +1 -0
- package/dist/script/conversion-read.d.ts +9 -0
- package/dist/script/conversion-read.d.ts.map +1 -0
- package/dist/script/conversion-read.js +69 -0
- package/dist/script/conversion-read.js.map +1 -0
- package/dist/script/conversion-write.d.ts +14 -0
- package/dist/script/conversion-write.d.ts.map +1 -0
- package/dist/script/conversion-write.js +34 -0
- package/dist/script/conversion-write.js.map +1 -0
- package/dist/script/conversion.d.ts +10 -16
- package/dist/script/conversion.d.ts.map +1 -1
- package/dist/script/conversion.js +2 -115
- package/dist/script/conversion.js.map +1 -1
- package/dist/search/candidate-narrowing.d.ts +56 -0
- package/dist/search/candidate-narrowing.d.ts.map +1 -0
- package/dist/search/candidate-narrowing.js +55 -0
- package/dist/search/candidate-narrowing.js.map +1 -0
- package/dist/search/candidate-query.d.ts +25 -0
- package/dist/search/candidate-query.d.ts.map +1 -0
- package/dist/search/candidate-query.js +28 -0
- package/dist/search/candidate-query.js.map +1 -0
- package/dist/search/candidate-writings.d.ts +24 -0
- package/dist/search/candidate-writings.d.ts.map +1 -0
- package/dist/search/candidate-writings.js +114 -0
- package/dist/search/candidate-writings.js.map +1 -0
- package/dist/search/candidates.d.ts +7 -41
- package/dist/search/candidates.d.ts.map +1 -1
- package/dist/search/candidates.js +10 -164
- package/dist/search/candidates.js.map +1 -1
- package/dist/search/match-chunks.d.ts +19 -0
- package/dist/search/match-chunks.d.ts.map +1 -0
- package/dist/search/match-chunks.js +30 -0
- package/dist/search/match-chunks.js.map +1 -0
- package/dist/search/match-ranking.d.ts +39 -0
- package/dist/search/match-ranking.d.ts.map +1 -0
- package/dist/search/match-ranking.js +51 -0
- package/dist/search/match-ranking.js.map +1 -0
- package/dist/search/match-readings.d.ts +43 -0
- package/dist/search/match-readings.d.ts.map +1 -0
- package/dist/search/match-readings.js +83 -0
- package/dist/search/match-readings.js.map +1 -0
- package/dist/search/match-scoring.d.ts +146 -0
- package/dist/search/match-scoring.d.ts.map +1 -0
- package/dist/search/match-scoring.js +114 -0
- package/dist/search/match-scoring.js.map +1 -0
- package/dist/search/match-search.d.ts +28 -0
- package/dist/search/match-search.d.ts.map +1 -0
- package/dist/search/match-search.js +128 -0
- package/dist/search/match-search.js.map +1 -0
- package/dist/search/match.d.ts +5 -36
- package/dist/search/match.d.ts.map +1 -1
- package/dist/search/match.js +2 -379
- package/dist/search/match.js.map +1 -1
- package/dist/search/reverse-index-build.d.ts +30 -0
- package/dist/search/reverse-index-build.d.ts.map +1 -0
- package/dist/search/reverse-index-build.js +72 -0
- package/dist/search/reverse-index-build.js.map +1 -0
- package/dist/search/reverse-index-format.d.ts +60 -0
- package/dist/search/reverse-index-format.d.ts.map +1 -0
- package/dist/search/reverse-index-format.js +54 -0
- package/dist/search/reverse-index-format.js.map +1 -0
- package/dist/search/reverse-index-groups.d.ts +37 -0
- package/dist/search/reverse-index-groups.d.ts.map +1 -0
- package/dist/search/reverse-index-groups.js +71 -0
- package/dist/search/reverse-index-groups.js.map +1 -0
- package/dist/search/reverse-index-passes.d.ts +78 -0
- package/dist/search/reverse-index-passes.d.ts.map +1 -0
- package/dist/search/reverse-index-passes.js +59 -0
- package/dist/search/reverse-index-passes.js.map +1 -0
- package/dist/search/reverse-index-state.d.ts +36 -0
- package/dist/search/reverse-index-state.d.ts.map +1 -0
- package/dist/search/reverse-index-state.js +95 -0
- package/dist/search/reverse-index-state.js.map +1 -0
- package/dist/search/reverse-index.d.ts +8 -67
- package/dist/search/reverse-index.d.ts.map +1 -1
- package/dist/search/reverse-index.js +4 -255
- package/dist/search/reverse-index.js.map +1 -1
- package/dist/sources/unihan-readings.d.ts +58 -0
- package/dist/sources/unihan-readings.d.ts.map +1 -0
- package/dist/sources/unihan-readings.js +95 -0
- package/dist/sources/unihan-readings.js.map +1 -0
- package/dist/sources/unihan.d.ts +6 -9
- package/dist/sources/unihan.d.ts.map +1 -1
- package/dist/sources/unihan.js +2 -85
- package/dist/sources/unihan.js.map +1 -1
- package/dist/syllable/final-tables.d.ts +23 -0
- package/dist/syllable/final-tables.d.ts.map +1 -0
- package/dist/syllable/final-tables.js +50 -0
- package/dist/syllable/final-tables.js.map +1 -0
- package/dist/syllable/inventory.d.ts +8 -42
- package/dist/syllable/inventory.d.ts.map +1 -1
- package/dist/syllable/inventory.js +9 -918
- package/dist/syllable/inventory.js.map +1 -1
- package/dist/syllable/spellings.d.ts +40 -0
- package/dist/syllable/spellings.d.ts.map +1 -0
- package/dist/syllable/spellings.js +469 -0
- package/dist/syllable/spellings.js.map +1 -0
- package/dist/syllable/syllable-parts.d.ts +31 -0
- package/dist/syllable/syllable-parts.d.ts.map +1 -0
- package/dist/syllable/syllable-parts.js +105 -0
- package/dist/syllable/syllable-parts.js.map +1 -0
- package/dist/syllable/syllable.d.ts +1 -14
- package/dist/syllable/syllable.d.ts.map +1 -1
- package/dist/syllable/syllable.js +3 -144
- package/dist/syllable/syllable.js.map +1 -1
- package/dist/syllable/written-tones.d.ts +6 -0
- package/dist/syllable/written-tones.d.ts.map +1 -0
- package/dist/syllable/written-tones.js +453 -0
- package/dist/syllable/written-tones.js.map +1 -0
- package/dist/transcription/bopomofo-parse.d.ts +42 -0
- package/dist/transcription/bopomofo-parse.d.ts.map +1 -0
- package/dist/transcription/bopomofo-parse.js +92 -0
- package/dist/transcription/bopomofo-parse.js.map +1 -0
- package/dist/transcription/bopomofo-reverse.d.ts +31 -0
- package/dist/transcription/bopomofo-reverse.d.ts.map +1 -0
- package/dist/transcription/bopomofo-reverse.js +48 -0
- package/dist/transcription/bopomofo-reverse.js.map +1 -0
- package/dist/transcription/bopomofo-symbols.d.ts +36 -0
- package/dist/transcription/bopomofo-symbols.d.ts.map +1 -0
- package/dist/transcription/bopomofo-symbols.js +41 -0
- package/dist/transcription/bopomofo-symbols.js.map +1 -0
- package/dist/transcription/bopomofo-tables.d.ts +87 -0
- package/dist/transcription/bopomofo-tables.d.ts.map +1 -0
- package/dist/transcription/bopomofo-tables.js +180 -0
- package/dist/transcription/bopomofo-tables.js.map +1 -0
- package/dist/transcription/bopomofo.d.ts +14 -32
- package/dist/transcription/bopomofo.d.ts.map +1 -1
- package/dist/transcription/bopomofo.js +5 -343
- package/dist/transcription/bopomofo.js.map +1 -1
- package/dist/transcription/gwoyeu-first-second.d.ts +36 -0
- package/dist/transcription/gwoyeu-first-second.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-first-second.js +75 -0
- package/dist/transcription/gwoyeu-first-second.js.map +1 -0
- package/dist/transcription/gwoyeu-spelling.d.ts +38 -0
- package/dist/transcription/gwoyeu-spelling.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-spelling.js +124 -0
- package/dist/transcription/gwoyeu-spelling.js.map +1 -0
- package/dist/transcription/gwoyeu-tables.d.ts +93 -0
- package/dist/transcription/gwoyeu-tables.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-tables.js +205 -0
- package/dist/transcription/gwoyeu-tables.js.map +1 -0
- package/dist/transcription/gwoyeu-tonal-forms.d.ts +49 -0
- package/dist/transcription/gwoyeu-tonal-forms.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-tonal-forms.js +89 -0
- package/dist/transcription/gwoyeu-tonal-forms.js.map +1 -0
- package/dist/transcription/gwoyeu-vowels.d.ts +51 -0
- package/dist/transcription/gwoyeu-vowels.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-vowels.js +58 -0
- package/dist/transcription/gwoyeu-vowels.js.map +1 -0
- package/dist/transcription/gwoyeu.d.ts +1 -26
- package/dist/transcription/gwoyeu.d.ts.map +1 -1
- package/dist/transcription/gwoyeu.js +2 -540
- package/dist/transcription/gwoyeu.js.map +1 -1
- package/dist/transcription/ipa-symbols.d.ts +67 -0
- package/dist/transcription/ipa-symbols.d.ts.map +1 -0
- package/dist/transcription/ipa-symbols.js +135 -0
- package/dist/transcription/ipa-symbols.js.map +1 -0
- package/dist/transcription/ipa.d.ts +2 -10
- package/dist/transcription/ipa.d.ts.map +1 -1
- package/dist/transcription/ipa.js +2 -134
- package/dist/transcription/ipa.js.map +1 -1
- package/dist/transcription/wade-giles-index.d.ts +35 -0
- package/dist/transcription/wade-giles-index.d.ts.map +1 -0
- package/dist/transcription/wade-giles-index.js +110 -0
- package/dist/transcription/wade-giles-index.js.map +1 -0
- package/dist/transcription/wade-giles-parse.d.ts +36 -0
- package/dist/transcription/wade-giles-parse.d.ts.map +1 -0
- package/dist/transcription/wade-giles-parse.js +84 -0
- package/dist/transcription/wade-giles-parse.js.map +1 -0
- package/dist/transcription/wade-giles-spelling.d.ts +61 -0
- package/dist/transcription/wade-giles-spelling.d.ts.map +1 -0
- package/dist/transcription/wade-giles-spelling.js +107 -0
- package/dist/transcription/wade-giles-spelling.js.map +1 -0
- package/dist/transcription/wade-giles-syllable.d.ts +29 -0
- package/dist/transcription/wade-giles-syllable.d.ts.map +1 -0
- package/dist/transcription/wade-giles-syllable.js +90 -0
- package/dist/transcription/wade-giles-syllable.js.map +1 -0
- package/dist/transcription/wade-giles-tables.d.ts +80 -0
- package/dist/transcription/wade-giles-tables.d.ts.map +1 -0
- package/dist/transcription/wade-giles-tables.js +178 -0
- package/dist/transcription/wade-giles-tables.js.map +1 -0
- package/dist/transcription/wade-giles.d.ts +9 -60
- package/dist/transcription/wade-giles.d.ts.map +1 -1
- package/dist/transcription/wade-giles.js +6 -543
- package/dist/transcription/wade-giles.js.map +1 -1
- package/dist/transcription/yale-tables.d.ts +54 -0
- package/dist/transcription/yale-tables.d.ts.map +1 -0
- package/dist/transcription/yale-tables.js +125 -0
- package/dist/transcription/yale-tables.js.map +1 -0
- package/dist/transcription/yale.d.ts.map +1 -1
- package/dist/transcription/yale.js +1 -124
- package/dist/transcription/yale.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,13 +14,13 @@ pnpm add @kensio/pinyinjs
|
|
|
14
14
|
Node 22+, or any browser. The core imports no Node built-ins, and the package is
|
|
15
15
|
ESM only.
|
|
16
16
|
|
|
17
|
-
The dictionaries ship inside the package,
|
|
18
|
-
download
|
|
17
|
+
The dictionaries ship inside the package, and that is what makes it a 4 MB
|
|
18
|
+
download. `data/` is 10 MB of artifacts and the point of the whole thing.
|
|
19
19
|
|
|
20
20
|
## Command line
|
|
21
21
|
|
|
22
|
-
Installing the package installs a `pinyinjs` command,
|
|
23
|
-
|
|
22
|
+
Installing the package installs a `pinyinjs` command, the quickest way to try
|
|
23
|
+
any of this.
|
|
24
24
|
|
|
25
25
|
```console
|
|
26
26
|
$ pinyinjs convert 我要去北京。
|
|
@@ -43,7 +43,7 @@ $ pinyinjs check 银行 yínxíng
|
|
|
43
43
|
$ pinyinjs explain 银行
|
|
44
44
|
银行 yínháng
|
|
45
45
|
yín locked
|
|
46
|
-
háng word xíng +
|
|
46
|
+
háng word xíng +14.6 héng +16.6 hàng +17.6
|
|
47
47
|
|
|
48
48
|
$ pinyinjs lookup 头发
|
|
49
49
|
头发 tóu fa n
|
|
@@ -99,8 +99,7 @@ never coloured. See [the command line](docs/cli/#colour).
|
|
|
99
99
|
|
|
100
100
|
### Calling it from something else
|
|
101
101
|
|
|
102
|
-
`convert` writes the pinyin and
|
|
103
|
-
pipeline:
|
|
102
|
+
`convert` writes the pinyin and no more, ready for a pipeline:
|
|
104
103
|
|
|
105
104
|
```console
|
|
106
105
|
$ pinyinjs convert 银行
|
|
@@ -108,12 +107,12 @@ yínháng
|
|
|
108
107
|
```
|
|
109
108
|
|
|
110
109
|
Everything else has columns for a person to read. Add `--json` to any command
|
|
111
|
-
and it writes one JSON document per answer instead,
|
|
110
|
+
and it writes one JSON document per answer instead, the shape `jq` wants:
|
|
112
111
|
|
|
113
112
|
```console
|
|
114
113
|
$ pinyinjs explain 长江大桥 --json | jq -c '.syllables[] | select(.state != "locked")'
|
|
115
|
-
{"text":"Cháng","state":"word","tone":2,"alternatives":[{"reading":"zhǎng","cost":
|
|
116
|
-
{"text":"Dà","state":"word","tone":4,"alternatives":[{"reading":"dài","cost":
|
|
114
|
+
{"text":"Cháng","state":"word","tone":2,"alternatives":[{"reading":"zhǎng","cost":14.62}]}
|
|
115
|
+
{"text":"Dà","state":"word","tone":4,"alternatives":[{"reading":"dài","cost":12.62}]}
|
|
117
116
|
|
|
118
117
|
$ pinyinjs lookup 垃圾 --json | jq -r .taiwanReading
|
|
119
118
|
lè sè
|
|
@@ -121,13 +120,13 @@ lè sè
|
|
|
121
120
|
$ cat article.txt | pinyinjs convert --json | jq -r .pinyin
|
|
122
121
|
```
|
|
123
122
|
|
|
124
|
-
One document per answer
|
|
125
|
-
|
|
123
|
+
One document per answer, and never one array for the whole run. The shape is the
|
|
124
|
+
same whether you convert one word or pipe a file through.
|
|
126
125
|
|
|
127
126
|
## Load a dictionary
|
|
128
127
|
|
|
129
|
-
Converting needs a dictionary
|
|
130
|
-
|
|
128
|
+
Converting needs a dictionary. A dictionary is a fetchable file, so loading one
|
|
129
|
+
is asynchronous.
|
|
131
130
|
|
|
132
131
|
```ts
|
|
133
132
|
import { convert, loadDictionary } from "@kensio/pinyinjs";
|
|
@@ -149,9 +148,9 @@ convert(dictionary, "长城"); // "Chángchéng"
|
|
|
149
148
|
```
|
|
150
149
|
|
|
151
150
|
Serve the artifacts uncompressed and let HTTP `Content-Encoding: br` compress
|
|
152
|
-
them
|
|
151
|
+
them. `DecompressionStream` has no brotli.
|
|
153
152
|
|
|
154
|
-
Load the dictionary once and keep it
|
|
153
|
+
Load the dictionary once and keep it. It is immutable and safe to share.
|
|
155
154
|
|
|
156
155
|
### Tiers
|
|
157
156
|
|
|
@@ -161,8 +160,8 @@ Load the dictionary once and keep it; it is immutable and safe to share.
|
|
|
161
160
|
| `standard` | 66,970 | 377 KB | the most common words |
|
|
162
161
|
| `full` | 461,555 | 2,378 KB | every word |
|
|
163
162
|
|
|
164
|
-
`full` is the default. The tiers are nested
|
|
165
|
-
|
|
163
|
+
`full` is the default. The tiers are nested. A page can load `standard` first,
|
|
164
|
+
convert with it, and reload as `full` arrives.
|
|
166
165
|
|
|
167
166
|
## Convert
|
|
168
167
|
|
|
@@ -174,7 +173,7 @@ convert(dictionary, "3D银行"); // "sān D yínháng", the digit is read, the l
|
|
|
174
173
|
```
|
|
175
174
|
|
|
176
175
|
A reading the dictionary cannot settle on its own is settled by context, with
|
|
177
|
-
typed rules over the lattice
|
|
176
|
+
typed rules over the lattice and never a tweak to the output:
|
|
178
177
|
|
|
179
178
|
```ts
|
|
180
179
|
convert(dictionary, "我得走了"); // "wǒ děi zǒule", modal 得
|
|
@@ -216,9 +215,10 @@ convert(dictionary, "好好", { sandhi: { thirdTone: true } }); // "háohǎo"
|
|
|
216
215
|
|
|
217
216
|
### Spacing, capitals and punctuation
|
|
218
217
|
|
|
219
|
-
**Capitals.** Proper nouns always
|
|
220
|
-
source is punctuated as one, since that is the only thing separating 学生
|
|
221
|
-
up as a word from 这是我的书。written as a sentence. A comma
|
|
218
|
+
**Capitals.** Proper nouns always, and the first word of a sentence only when
|
|
219
|
+
the source is punctuated as one, since that is the only thing separating 学生
|
|
220
|
+
looked up as a word from 这是我的书。written as a sentence. A comma leaves the
|
|
221
|
+
next word lower case.
|
|
222
222
|
|
|
223
223
|
```ts
|
|
224
224
|
convert(dictionary, "银行"); // "yínháng", not "Yínháng"
|
|
@@ -226,9 +226,9 @@ convert(dictionary, "我要去北京。"); // "Wǒ yào qù Běijīng."
|
|
|
226
226
|
convert(dictionary, "你好,世界"); // "nǐ hǎo, shìjiè"
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
**Apostrophes.** The 隔音符号 goes before any syllable of a word that starts
|
|
230
|
-
`a`, `o` or `e
|
|
231
|
-
where leaving it out would read as something else.
|
|
229
|
+
**Apostrophes.** The 隔音符号 goes before any syllable of a word that starts
|
|
230
|
+
with `a`, `o` or `e`, unless it is the first. `apostrophe: "standard"` writes it
|
|
231
|
+
only where leaving it out would read as something else.
|
|
232
232
|
|
|
233
233
|
```ts
|
|
234
234
|
convert(dictionary, "天安门"); // "Tiān'ānmén"
|
|
@@ -239,7 +239,7 @@ convert(dictionary, "女儿"); // "nǚ'ér"
|
|
|
239
239
|
the space the full-width glyph carried. Brackets and quotation marks are left
|
|
240
240
|
alone. `punctuation: "keep"` leaves everything as it was.
|
|
241
241
|
|
|
242
|
-
**Word spacing.** 分词连写 is applied to the decoded words
|
|
242
|
+
**Word spacing.** 分词连写 is applied to the decoded words. Aspect particles
|
|
243
243
|
attach to their verb, suffixes to their stem, and the generic half of a place
|
|
244
244
|
name separates and capitalises. A small curated list covers words the standard
|
|
245
245
|
writes in a way no rule reaches.
|
|
@@ -256,12 +256,11 @@ convert(dictionary, "黄河"); // "Huáng Hé"
|
|
|
256
256
|
convert(dictionary, "中国人"); // "Zhōngguórén"
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
The list
|
|
260
|
-
|
|
261
|
-
`Qīnghǎi`.
|
|
259
|
+
The list falls short of a complete 正词法 implementation, so a word it misses is
|
|
260
|
+
written differently. 不但 is `búdàn`, 大米 is `dàmǐ`, and 青海 is `Qīnghǎi`.
|
|
262
261
|
|
|
263
|
-
**Reduplication** takes a hyphen
|
|
264
|
-
a boundary inside it.
|
|
262
|
+
**Reduplication** takes a hyphen where a space would go, since it is one word
|
|
263
|
+
with a boundary inside it.
|
|
265
264
|
|
|
266
265
|
```ts
|
|
267
266
|
convert(dictionary, "干干净净"); // "gāngān-jìngjìng"
|
|
@@ -270,7 +269,7 @@ convert(dictionary, "爸爸妈妈"); // "bàba māma", that shape, but two words
|
|
|
270
269
|
```
|
|
271
270
|
|
|
272
271
|
**A 成语 that can be read as two disyllables** takes the same hyphen, from a
|
|
273
|
-
curated list of 117
|
|
272
|
+
curated list of 117. The rest are written solid, as the standard writes them.
|
|
274
273
|
|
|
275
274
|
```ts
|
|
276
275
|
convert(dictionary, "风平浪静"); // "fēngpíng-làngjìng"
|
|
@@ -308,7 +307,7 @@ pieces[1]?.confidence?.alternatives.map((found) =>
|
|
|
308
307
|
); // ["xíng", "héng", "hàng"]
|
|
309
308
|
```
|
|
310
309
|
|
|
311
|
-
A piece with no `syllable` is the text between two of them
|
|
310
|
+
A piece with no `syllable` is the text between two of them, a space or a run
|
|
312
311
|
that was never Han. `joinPieces(pieces)` gives back exactly what `convert`
|
|
313
312
|
returns.
|
|
314
313
|
|
|
@@ -346,10 +345,10 @@ convertToHtml(dictionary, "行");
|
|
|
346
345
|
|
|
347
346
|
One element per syllable, with `py-tone-1` to `py-tone-5` (5 is the neutral
|
|
348
347
|
tone), and `py-uncertain` plus the rejected readings where the decoder was
|
|
349
|
-
guessing. Each one declares itself pinyin
|
|
350
|
-
conversion
|
|
351
|
-
page around it. Text that
|
|
352
|
-
included, so write your own:
|
|
348
|
+
guessing. Each one declares itself pinyin, as `zh-Latn-TW-pinyin` for a `zh-TW`
|
|
349
|
+
conversion. A screen reader then reads it as pinyin, and not as the language of
|
|
350
|
+
the page around it. Text that was never Han is escaped and left unmarked. No
|
|
351
|
+
styles are included, so write your own:
|
|
353
352
|
|
|
354
353
|
```css
|
|
355
354
|
.py-tone-1 {
|
|
@@ -365,8 +364,8 @@ and `lang: false`. `toHtml(pieces, options)` renders pieces you already have.
|
|
|
365
364
|
|
|
366
365
|
## Annotated output: hanzi and pinyin together
|
|
367
366
|
|
|
368
|
-
`convertToHtml` writes the pinyin _instead of_ the hanzi. To keep both
|
|
369
|
-
learner's text, a subtitle
|
|
367
|
+
`convertToHtml` writes the pinyin _instead of_ the hanzi. To keep both, for a
|
|
368
|
+
learner's text, a subtitle or a dictionary entry, annotate it instead:
|
|
370
369
|
|
|
371
370
|
```ts
|
|
372
371
|
import { convertToAnnotatedHtml } from "@kensio/pinyinjs";
|
|
@@ -376,14 +375,15 @@ convertToAnnotatedHtml(dictionary, "银行");
|
|
|
376
375
|
// lang="zh-Latn-CN-pinyin">yín</span></rt><rp>)</rp></ruby>…
|
|
377
376
|
```
|
|
378
377
|
|
|
379
|
-
The markup is `<ruby>`, which browsers lay out natively
|
|
380
|
-
|
|
381
|
-
`<rt>` holds exactly what `convertToHtml` would have written, so
|
|
382
|
-
and uncertainty marking work inside an annotation as they do
|
|
378
|
+
The markup is `<ruby>`, which browsers lay out natively. The reading sits above
|
|
379
|
+
the characters, and `<rp>` puts it in parentheses where a browser lacks ruby
|
|
380
|
+
support. Each `<rt>` holds exactly what `convertToHtml` would have written, so
|
|
381
|
+
tone colours and uncertainty marking work inside an annotation as they do
|
|
382
|
+
outside one.
|
|
383
383
|
|
|
384
|
-
**A base
|
|
385
|
-
|
|
386
|
-
|
|
384
|
+
**A base can span characters**, and this is where per-character annotation goes
|
|
385
|
+
wrong. 玩儿 is two characters and the one syllable `wánr`, and a read number
|
|
386
|
+
reverses on the way, so both are annotated whole:
|
|
387
387
|
|
|
388
388
|
```ts
|
|
389
389
|
convertToAnnotatedHtml(dictionary, "玩儿"); // one <ruby>, 玩儿 over wánr
|
|
@@ -399,13 +399,13 @@ ruby rt {
|
|
|
399
399
|
```
|
|
400
400
|
|
|
401
401
|
`toAnnotatedHtml(pieces, options)` renders pieces you already have, and
|
|
402
|
-
`ConvertedPiece.source` is what makes that possible
|
|
403
|
-
reads, or undefined where it reads on into the ones before it.
|
|
402
|
+
`ConvertedPiece.source` is what makes that possible, holding the characters each
|
|
403
|
+
piece reads, or undefined where it reads on into the ones before it.
|
|
404
404
|
|
|
405
405
|
## Segment
|
|
406
406
|
|
|
407
407
|
Converting has to find the words before it can read them, because the unit a
|
|
408
|
-
reading belongs to is the word
|
|
408
|
+
reading belongs to is the word. 行 is `xíng` or `háng` and only 银行 and 行长
|
|
409
409
|
say which. `segment` returns that answer instead of throwing it away.
|
|
410
410
|
|
|
411
411
|
```ts
|
|
@@ -421,14 +421,14 @@ found[3]?.isProperNoun; // true
|
|
|
421
421
|
found[3]?.at; // 3, in code points from the start of the text
|
|
422
422
|
```
|
|
423
423
|
|
|
424
|
-
Every stretch comes back in order, including the ones that were never Han
|
|
425
|
-
|
|
426
|
-
|
|
424
|
+
Every stretch comes back in order, including the ones that were never Han. The
|
|
425
|
+
segments rejoin into exactly the text they came from. That is what makes it safe
|
|
426
|
+
to rebuild a document, highlight in place, or index a corpus. Filter on
|
|
427
427
|
`isKnown` for the stretches the dictionary recognised.
|
|
428
428
|
|
|
429
|
-
|
|
430
|
-
segments as 他 / 看 / 了 and converts as `tā kànle`, because attaching an
|
|
431
|
-
particle to its verb is a fact about writing pinyin
|
|
429
|
+
One thing it leaves alone is 分词连写, the word spacing written pinyin wants.
|
|
430
|
+
他看了 segments as 他 / 看 / 了 and converts as `tā kànle`, because attaching an
|
|
431
|
+
aspect particle to its verb is a fact about writing pinyin, not about where the
|
|
432
432
|
words are.
|
|
433
433
|
|
|
434
434
|
## Match a pinyin query
|
|
@@ -444,28 +444,32 @@ match(dictionary, "北京大学", "beijing")?.ranges; // [{ at: 0, length: 2 }]
|
|
|
444
444
|
match(dictionary, "北京大学", "nanjing"); // undefined
|
|
445
445
|
```
|
|
446
446
|
|
|
447
|
-
Every way anybody types it
|
|
448
|
-
`bei jing`; initials, `bj`; the two mixed, `beij` and `bjing`; tones as digits
|
|
449
|
-
where they are worth writing, `bei3jing1`; `v` or `u:` for ü; and the r of 儿化
|
|
450
|
-
on the syllable it belongs to, so 玩儿 answers to `wanr`.
|
|
447
|
+
Every way anybody types it is accepted:
|
|
451
448
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
449
|
+
- full syllables joined or spaced, `beijing` and `bei jing`
|
|
450
|
+
- initials, `bj`
|
|
451
|
+
- the two mixed, `beij` and `bjing`
|
|
452
|
+
- tones as digits where they are worth writing, `bei3jing1`
|
|
453
|
+
- `v` or `u:` for ü
|
|
454
|
+
- the r of 儿化 on the syllable it belongs to, so 玩儿 answers to `wanr`
|
|
455
|
+
|
|
456
|
+
**No index is built and none is needed.** The haystack is Chinese. The query is
|
|
457
|
+
tested as a path over each character's readings, with no text spelled out in
|
|
458
|
+
advance. That is why every reading of a polyphone is matchable, where a default
|
|
459
|
+
reading table only ever offers one of them:
|
|
456
460
|
|
|
457
461
|
```ts
|
|
458
462
|
match(dictionary, "银行", "yh")?.score; // 7, and 银行 is yínháng
|
|
459
463
|
match(dictionary, "银行", "yx")?.score; // 5 — a reading 行 has, but not here
|
|
460
464
|
```
|
|
461
465
|
|
|
462
|
-
Both match, and the decoder's own reading is what ranks them, along with
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
466
|
+
Both match, and the decoder's own reading is what ranks them, along with whether
|
|
467
|
+
the match starts a word. Sort a filtered list by `score`, highest first. What
|
|
468
|
+
comes back is ranges in code points, so a caller can highlight what matched.
|
|
469
|
+
There is more than one where the query stepped over something with no reading of
|
|
470
|
+
its own, as 北京·大学 does.
|
|
467
471
|
|
|
468
|
-
The `core` tier is enough,
|
|
472
|
+
The `core` tier is enough, and a page that never loads a word list can still
|
|
469
473
|
filter. See [matching](docs/matching/).
|
|
470
474
|
|
|
471
475
|
## Go the other way: pinyin to hanzi
|
|
@@ -485,23 +489,23 @@ candidates(index, "yínháng"); // ["銀行", "银行"], narrowed by tone
|
|
|
485
489
|
homophonesOf(index, "长城"); // ["長城", "長程", "长程", "常程"]
|
|
486
490
|
```
|
|
487
491
|
|
|
488
|
-
This is the half of search with no haystack
|
|
489
|
-
already hold, and this answers a query with
|
|
490
|
-
|
|
491
|
-
|
|
492
|
+
This is the half of search with no haystack. `match` filters Chinese text you
|
|
493
|
+
already hold, and this answers a query with only the dictionary behind it.
|
|
494
|
+
Pinyin-only lookup, a homophones section on a word page, or a browser input
|
|
495
|
+
method for somebody with no Chinese keyboard.
|
|
492
496
|
|
|
493
|
-
**
|
|
497
|
+
**Everything is derived in memory.** Shipping a reverse index of the `full` tier
|
|
494
498
|
would add 1,995 KB to a 2,378 KB download and could not be compressed below
|
|
495
|
-
about 1,474 KB
|
|
499
|
+
about 1,474 KB. The client derives it instead, at 510 ms and 2.03 MB of heap on
|
|
496
500
|
`full`, and 4 ms on `core`. `ReverseIndex.building` drives that build a slice at
|
|
497
|
-
a time, and `serialise` hands it out of a worker
|
|
498
|
-
|
|
501
|
+
a time, and `serialise` hands it out of a worker. The main thread never has to
|
|
502
|
+
hold it.
|
|
499
503
|
|
|
500
504
|
Candidates come back likeliest first, because a posting is a dictionary position
|
|
501
505
|
and a position indexes the frequency table. Tones may be written or left off,
|
|
502
506
|
`v` and `u:` reach ü, and the r of 儿化 is optional, so 玩儿 answers to `wanr`
|
|
503
507
|
and to `wan`. Both scripts are dictionary keys, so pass a script preference and
|
|
504
|
-
the conversion tables to keep one writing of a word
|
|
508
|
+
the conversion tables to keep one writing of a word instead of both. See
|
|
505
509
|
[candidates](docs/candidates/).
|
|
506
510
|
|
|
507
511
|
## Check what somebody typed
|
|
@@ -519,7 +523,7 @@ marked.score; // 0.5
|
|
|
519
523
|
```
|
|
520
524
|
|
|
521
525
|
Each syllable comes back as one of six verdicts, with `source` and `at` naming
|
|
522
|
-
the characters it reads so a mistake can be shown against the text
|
|
526
|
+
the characters it reads so a mistake can be shown against the text and not
|
|
523
527
|
against the answer:
|
|
524
528
|
|
|
525
529
|
| Verdict | Means |
|
|
@@ -543,17 +547,17 @@ check(dictionary, "海鸥", "hǎiōu").isCorrect; // true, an apostrophe is not
|
|
|
543
547
|
check(dictionary, "我的书", "wǒ de shū").isCorrect; // true, pinyin marks no neutral tone
|
|
544
548
|
```
|
|
545
549
|
|
|
546
|
-
A guess is only forgiven where the library was guessing
|
|
547
|
-
prior
|
|
548
|
-
|
|
550
|
+
A guess is only forgiven where the library was guessing. 行 alone is chosen by a
|
|
551
|
+
prior alone, whereas 银行 settles both its syllables, so `yínxíng` is a real
|
|
552
|
+
mistake. See [confidence](docs/confidence/).
|
|
549
553
|
|
|
550
554
|
### Tones and word spacing
|
|
551
555
|
|
|
552
556
|
Two axes an exercise may or may not be teaching yet, each reported always and
|
|
553
557
|
each counted only when asked for.
|
|
554
558
|
|
|
555
|
-
Tones left off
|
|
556
|
-
the difference:
|
|
559
|
+
Tones left off report as `toneless` and never as `tone`, because `Syllable.tone`
|
|
560
|
+
knows the difference:
|
|
557
561
|
|
|
558
562
|
```ts
|
|
559
563
|
check(dictionary, "北京", "bei jing").isCorrect; // true
|
|
@@ -561,7 +565,7 @@ check(dictionary, "北京", "bei jing", { tones: "required" }).isCorrect; // fal
|
|
|
561
565
|
```
|
|
562
566
|
|
|
563
567
|
Word spacing is graded on `spacing`, separately from the syllable's own verdict,
|
|
564
|
-
because it is a separate mistake
|
|
568
|
+
because it is a separate mistake. `yín háng` reads 银行 perfectly and writes it
|
|
565
569
|
as two words.
|
|
566
570
|
|
|
567
571
|
```ts
|
|
@@ -572,7 +576,7 @@ check(dictionary, "银行", "yín háng", { spacing: "required" }).isCorrect; //
|
|
|
572
576
|
```
|
|
573
577
|
|
|
574
578
|
It is `split` for a word written as two and `joined` for two written as one, and
|
|
575
|
-
it is tolerant in the same spirit as everything else
|
|
579
|
+
it is tolerant in the same spirit as everything else. 分词连写 and the words the
|
|
576
580
|
dictionary knows are two conventions this package writes, and a learner may have
|
|
577
581
|
been taught either:
|
|
578
582
|
|
|
@@ -602,8 +606,8 @@ dictionary.hasPrefix("银"); // true, does any word start with this?
|
|
|
602
606
|
dictionary.readingsOf("行"); // xíng, háng, héng, hàng, likeliest first
|
|
603
607
|
```
|
|
604
608
|
|
|
605
|
-
Both scripts are keys in the same dictionary
|
|
606
|
-
|
|
609
|
+
Both scripts are keys in the same dictionary. A 繁體 word is found directly,
|
|
610
|
+
with no conversion first.
|
|
607
611
|
|
|
608
612
|
## Syllables
|
|
609
613
|
|
|
@@ -621,8 +625,8 @@ readSyllable("běi3"); // undefined, one notation at a time
|
|
|
621
625
|
isSyllable("wánr"); // true, 儿化 is a suffix, not a syllable of its own
|
|
622
626
|
```
|
|
623
627
|
|
|
624
|
-
Initials and finals
|
|
625
|
-
`j` + `iou` and 军 is `j` + `ün`. Spelling is reconstructed on demand:
|
|
628
|
+
Initials and finals hold the _underlying_ form, the one behind the spelling, so
|
|
629
|
+
就 is `j` + `iou` and 军 is `j` + `ün`. Spelling is reconstructed on demand:
|
|
626
630
|
|
|
627
631
|
```ts
|
|
628
632
|
const jiu = { initial: "j", final: "iou", tone: 4 } as const;
|
|
@@ -635,8 +639,8 @@ writeSyllable(jiu, "none"); // "jiu"
|
|
|
635
639
|
Input takes either notation, the `v` and `u:` conventions for ü, and raised tone
|
|
636
640
|
digits. Output is standard diacritics unless asked otherwise.
|
|
637
641
|
|
|
638
|
-
Parsing answers whether a spelling is _well formed_,
|
|
639
|
-
it
|
|
642
|
+
Parsing answers whether a spelling is _well formed_, and never whether Mandarin
|
|
643
|
+
uses it. `shong` parses and no Mandarin word uses it. The attested inventory is
|
|
640
644
|
separate:
|
|
641
645
|
|
|
642
646
|
```ts
|
|
@@ -676,14 +680,14 @@ stripToneMarks("hǎo"); // "hao"
|
|
|
676
680
|
toneFromMarks("hǎo"); // 3
|
|
677
681
|
```
|
|
678
682
|
|
|
679
|
-
`Syllable.tone` is `Tone | undefined`, and
|
|
683
|
+
`Syllable.tone` is `Tone | undefined`, and the two mean different things. The
|
|
680
684
|
`de` in 我的 is neutral (5), whereas the `bei` in a typed `beijing` has no tone
|
|
681
685
|
written at all.
|
|
682
686
|
|
|
683
687
|
## Numbers
|
|
684
688
|
|
|
685
|
-
Reading a number needs no dictionary, just arithmetic and about twenty
|
|
686
|
-
|
|
689
|
+
Reading a number needs no dictionary, just arithmetic and about twenty readings.
|
|
690
|
+
It runs before anything is loaded.
|
|
687
691
|
|
|
688
692
|
```ts
|
|
689
693
|
import { numeralHanzi, percentHanzi, readNumeral } from "@kensio/pinyinjs";
|
|
@@ -695,8 +699,8 @@ numeralHanzi(2, { counts: true }); // "两", as in 两个西瓜, never 二个
|
|
|
695
699
|
percentHanzi(95); // "百分之九十五", the order reverses
|
|
696
700
|
```
|
|
697
701
|
|
|
698
|
-
The same digits are read two ways and
|
|
699
|
-
2026年 is spelled out and 2026个 is counted
|
|
702
|
+
The same digits are read two ways and the number alone leaves the choice open,
|
|
703
|
+
since 2026年 is spelled out and 2026个 is counted. The style is the caller's:
|
|
700
704
|
|
|
701
705
|
```ts
|
|
702
706
|
numeralHanzi(2026); // "两千零二十六"
|
|
@@ -708,7 +712,7 @@ More in [numbers](docs/numerals/).
|
|
|
708
712
|
|
|
709
713
|
## Bopomofo, Wade-Giles, Yale, Gwoyeu Romatzyh and IPA
|
|
710
714
|
|
|
711
|
-
Also dictionary-free
|
|
715
|
+
Also dictionary-free. A romanisation is a mapping over about 420 syllables, so
|
|
712
716
|
hanzi → Wade-Giles is hanzi → pinyin → Wade-Giles.
|
|
713
717
|
|
|
714
718
|
```ts
|
|
@@ -731,7 +735,7 @@ writeIpa(jiu); // "tɕiou˥˩"
|
|
|
731
735
|
```
|
|
732
736
|
|
|
733
737
|
Gwoyeu Romatzyh is the odd one, and it needs no tone mark because the tone is
|
|
734
|
-
spelled into the syllable
|
|
738
|
+
spelled into the syllable. That is why 陝西 is Shaanxi in English and 山西 is
|
|
735
739
|
Shanxi:
|
|
736
740
|
|
|
737
741
|
```ts
|
|
@@ -755,7 +759,7 @@ first candidate recovers 79.05% of them. More in
|
|
|
755
759
|
## Sandhi
|
|
756
760
|
|
|
757
761
|
The dictionary stores underlying tones, and sandhi is applied to the syllable
|
|
758
|
-
array
|
|
762
|
+
array. It can be switched off, and it works across word boundaries.
|
|
759
763
|
|
|
760
764
|
```ts
|
|
761
765
|
import { applySandhi, readWord } from "@kensio/pinyinjs";
|
|
@@ -769,15 +773,15 @@ applySandhi(niHao); // unchanged by default
|
|
|
769
773
|
applySandhi(niHao, { thirdTone: true }); // ní hǎo
|
|
770
774
|
```
|
|
771
775
|
|
|
772
|
-
Third-tone sandhi is off by default
|
|
776
|
+
Third-tone sandhi is off by default, because standard orthography writes 你好 as
|
|
773
777
|
`nǐ hǎo` even though it is said `ní hǎo`. Turn it on for transcribing speech.
|
|
774
|
-
Its domain is the prosodic foot
|
|
778
|
+
Its domain is the prosodic foot and not the syllable string, so 展览馆 is
|
|
775
779
|
`zhánlánguǎn` and 纸老虎 `zhǐláohǔ`, and 老板很好 keeps the 板 that a
|
|
776
780
|
left-to-right scan would lower.
|
|
777
781
|
|
|
778
782
|
## Scripts and locales
|
|
779
783
|
|
|
780
|
-
Three axes
|
|
784
|
+
Three separate axes. Taiwan writes 繁體 with `zh-TW` readings, but mainland
|
|
781
785
|
editions of classical texts use 繁體 with `zh-CN` readings, and Singapore uses
|
|
782
786
|
简体.
|
|
783
787
|
|
|
@@ -794,7 +798,8 @@ Kong's 繁體 forms are recognised on the way in, so 羣眾 and 麪包 read exac
|
|
|
794
798
|
## Simplified and traditional
|
|
795
799
|
|
|
796
800
|
`toScript` converts between the scripts, and the reading is what makes it
|
|
797
|
-
accurate. Simplification merged distinct characters
|
|
801
|
+
accurate. Simplification merged distinct characters, and the reading un-merges
|
|
802
|
+
them.
|
|
798
803
|
|
|
799
804
|
```ts
|
|
800
805
|
import { loadScriptTables, toScript } from "@kensio/pinyinjs";
|
|
@@ -808,12 +813,12 @@ toScript(dictionary, tables, "头发", { to: "zh-Hant" }); // "頭髮", tóufà
|
|
|
808
813
|
toScript(dictionary, tables, "出发", { to: "zh-Hant" }); // "出發", chūfā
|
|
809
814
|
```
|
|
810
815
|
|
|
811
|
-
发 is 發 or
|
|
812
|
-
works from phrase tables alone
|
|
813
|
-
guessing past it.
|
|
816
|
+
发 is 發 or 髮, and the character on its own leaves the choice open. Every other
|
|
817
|
+
converter works from phrase tables alone. Each is right about the words on the
|
|
818
|
+
list and guessing past it.
|
|
814
819
|
|
|
815
|
-
It runs both ways
|
|
816
|
-
`Qiánlóng` and stays 乾隆
|
|
820
|
+
It runs both ways (乾燥 is `gānzào` and simplifies to 干燥, while 乾隆 is
|
|
821
|
+
`Qiánlóng` and stays 乾隆) and it targets a region, because there is no
|
|
817
822
|
region-free 繁體:
|
|
818
823
|
|
|
819
824
|
```ts
|
|
@@ -821,12 +826,12 @@ toScript(dictionary, tables, "面包", { to: "zh-Hant-TW" }); // "麵包"
|
|
|
821
826
|
toScript(dictionary, tables, "面包", { to: "zh-Hant-HK" }); // "麪包"
|
|
822
827
|
```
|
|
823
828
|
|
|
824
|
-
`toScriptPieces` reports what settled each character, and which were guesses
|
|
825
|
-
下面 is a surface or a bowl of noodles, both `xiàmiàn`, and it says so
|
|
826
|
-
|
|
827
|
-
converting hanzi to pinyin
|
|
829
|
+
`toScriptPieces` reports what settled each character, and which were guesses.
|
|
830
|
+
下面 is a surface or a bowl of noodles, both `xiàmiàn`, and it says so instead
|
|
831
|
+
of picking silently. The tables load separately from the dictionary, so
|
|
832
|
+
converting hanzi to pinyin never pays for them.
|
|
828
833
|
|
|
829
|
-
This is orthography and not translation
|
|
834
|
+
This is orthography and not translation. 软件 becomes 軟件, never 軟體. See
|
|
830
835
|
[script conversion](docs/script-conversion/).
|
|
831
836
|
|
|
832
837
|
## API
|
|
@@ -874,19 +879,19 @@ pnpm polyphones # score them against 20,139 hand-labelled polyphones
|
|
|
874
879
|
pnpm build:data # rebuild data/ from the upstream sources
|
|
875
880
|
```
|
|
876
881
|
|
|
877
|
-
`pnpm check` must pass
|
|
878
|
-
`exactOptionalPropertyTypes` and `noUncheckedIndexedAccess`, and vitest at
|
|
879
|
-
coverage thresholds.
|
|
882
|
+
`pnpm check` must pass, running oxlint including the type-aware rules, `tsc`
|
|
883
|
+
with `exactOptionalPropertyTypes` and `noUncheckedIndexedAccess`, and vitest at
|
|
884
|
+
95% coverage thresholds.
|
|
880
885
|
|
|
881
886
|
Every example in this README is executed by `src/readme.test.ts` against the
|
|
882
887
|
committed dictionary, so the two cannot drift apart. Change them together.
|
|
883
888
|
|
|
884
889
|
The compiled dictionaries in `data/` are committed, so what ships is exactly
|
|
885
|
-
what was tested. `pnpm build:data` fetches the four sources into `.cache/`
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
+
what was tested. `pnpm build:data` fetches the four sources into `.cache/` (~32
|
|
891
|
+
MB), merges them, runs the build assertions, and rewrites `data/` and `NOTICE`.
|
|
892
|
+
It fails where it could warn. No artifact is written unless 儿化 is repaired
|
|
893
|
+
both ways, 一 and 不 sandhi is normalised out, every syllable is one the
|
|
894
|
+
inventory knows, and every tier reads back exactly as it was built.
|
|
890
895
|
|
|
891
896
|
## Data sources
|
|
892
897
|
|
|
@@ -901,7 +906,7 @@ the inventory knows, and every tier reads back exactly as it was built.
|
|
|
901
906
|
|
|
902
907
|
## Licence
|
|
903
908
|
|
|
904
|
-
`Apache-2.0 AND CC-BY-SA-4.0`, because the package is two things
|
|
909
|
+
`Apache-2.0 AND CC-BY-SA-4.0`, because the package is two things. The code is
|
|
905
910
|
Apache-2.0, and the compiled dictionaries in `data/` are share-alike, CC-CEDICT
|
|
906
911
|
being CC BY-SA 4.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE), which is
|
|
907
912
|
generated from the sources the pipeline actually fetched.
|