@kensio/pinyinjs 1.7.4 → 1.7.5
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/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/confidence.d.ts.map +1 -1
- package/dist/decode/confidence.js +3 -118
- 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 +66 -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/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 +140 -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 +58 -0
- package/dist/decode/jiao-rule.d.ts.map +1 -0
- package/dist/decode/jiao-rule.js +76 -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 +82 -0
- package/dist/decode/lattice-types.d.ts.map +1 -0
- package/dist/decode/lattice-types.js +44 -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 +31 -0
- package/dist/decode/polyphone-rules.d.ts.map +1 -0
- package/dist/decode/polyphone-rules.js +159 -0
- package/dist/decode/polyphone-rules.js.map +1 -0
- package/dist/decode/reading-rules.d.ts +2 -97
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +4 -365
- 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/sandhi-tones.d.ts +69 -0
- package/dist/decode/sandhi-tones.d.ts.map +1 -0
- package/dist/decode/sandhi-tones.js +88 -0
- package/dist/decode/sandhi-tones.js.map +1 -0
- package/dist/decode/sandhi.d.ts +1 -1
- package/dist/decode/sandhi.d.ts.map +1 -1
- package/dist/decode/sandhi.js +1 -81
- 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 +28 -0
- package/dist/decode/write-run.d.ts.map +1 -0
- package/dist/decode/write-run.js +77 -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 +80 -0
- package/dist/dictionary/cedict-senses.d.ts.map +1 -0
- package/dist/dictionary/cedict-senses.js +114 -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/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 +121 -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-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 +30 -713
- 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 +38 -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/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 +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isSingleCharacter } from "../script/characters.js";
|
|
2
|
+
import { isSameReading } from "./entry.js";
|
|
3
|
+
import { readAlignedReading } from "./reading.js";
|
|
4
|
+
import { repairErhua } from "./erhua-repair.js";
|
|
5
|
+
import { NEUTRAL_SENSE_LOOKUP } from "./neutral-senses.js";
|
|
6
|
+
import { OVERRIDE_READINGS } from "./overrides.js";
|
|
7
|
+
import { nearestReading, preferNeutralTones, reducesToNeutral, } from "./reading-agreement.js";
|
|
8
|
+
/**
|
|
9
|
+
* Settle it.
|
|
10
|
+
*/
|
|
11
|
+
export function settleReading(word, defaults, cedictEntries, cedictReadings, phraseAligned) {
|
|
12
|
+
let neutralToneCorrections = 0;
|
|
13
|
+
let erhuaRepairs = 0;
|
|
14
|
+
// ── The reading: phrase corpus leads, CC-CEDICT corrects ──
|
|
15
|
+
let aligned = phraseAligned;
|
|
16
|
+
let reading = aligned
|
|
17
|
+
?.map((read) => read.syllable)
|
|
18
|
+
.filter((syllable) => syllable !== undefined);
|
|
19
|
+
if (reading === undefined) {
|
|
20
|
+
// No phrase entry. Single characters fall back to Unihan, which is the
|
|
21
|
+
// better source for them anyway; everything else falls back to
|
|
22
|
+
// CC-CEDICT.
|
|
23
|
+
const characterDefault = defaults.get(word);
|
|
24
|
+
if (isSingleCharacter(word) && characterDefault !== undefined) {
|
|
25
|
+
reading = characterDefault.slice(0, 1);
|
|
26
|
+
aligned = [{ characters: word, syllable: reading[0] }];
|
|
27
|
+
}
|
|
28
|
+
else if (cedictReadings[0] !== undefined) {
|
|
29
|
+
reading = cedictReadings[0];
|
|
30
|
+
aligned = readAlignedReading(word, cedictEntries[0]?.readings ?? []);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (reading === undefined || reading.length === 0) {
|
|
34
|
+
return {
|
|
35
|
+
reading: undefined,
|
|
36
|
+
aligned: undefined,
|
|
37
|
+
neutralToneCorrections: 0,
|
|
38
|
+
erhuaRepairs: 0,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// ── 儿化, before anything compares two readings ────────────
|
|
42
|
+
const repaired = repairErhua(word, reading, aligned, cedictEntries, cedictReadings);
|
|
43
|
+
reading = repaired.reading;
|
|
44
|
+
aligned = repaired.aligned;
|
|
45
|
+
if (repaired.isRepaired) {
|
|
46
|
+
erhuaRepairs++;
|
|
47
|
+
}
|
|
48
|
+
// ── Disagreements: CC-CEDICT wins on neutral tones ────────
|
|
49
|
+
// Which sense to correct against is normally the nearest one. For a word on
|
|
50
|
+
// the 轻声 list it is the nearest sense that *reduces* a syllable, because
|
|
51
|
+
// there the nearest sense is the full-tone homograph the corpus happens to
|
|
52
|
+
// have written and the everyday word is the other one — see
|
|
53
|
+
// {@link NEUTRAL_SENSE_WORDS}.
|
|
54
|
+
const chosen = reading;
|
|
55
|
+
const nearest = phraseAligned === undefined
|
|
56
|
+
? undefined
|
|
57
|
+
: ((NEUTRAL_SENSE_LOOKUP.has(word)
|
|
58
|
+
? nearestReading(chosen, cedictReadings.filter((candidate) => reducesToNeutral(chosen, candidate)))
|
|
59
|
+
: undefined) ?? nearestReading(chosen, cedictReadings));
|
|
60
|
+
// A sense of a different length describes a different pronunciation, so
|
|
61
|
+
// there is no syllable-for-syllable correction to make against it.
|
|
62
|
+
if (nearest !== undefined) {
|
|
63
|
+
const corrected = preferNeutralTones(reading, nearest);
|
|
64
|
+
if (!isSameReading(corrected, reading)) {
|
|
65
|
+
neutralToneCorrections++;
|
|
66
|
+
reading = corrected;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// ── The override table has the last word ──────────────────
|
|
70
|
+
const override = OVERRIDE_READINGS.get(word);
|
|
71
|
+
if (override !== undefined) {
|
|
72
|
+
reading = override;
|
|
73
|
+
}
|
|
74
|
+
return { reading, aligned, neutralToneCorrections, erhuaRepairs };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=word-reading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word-reading.js","sourceRoot":"","sources":["../../src/dictionary/word-reading.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,a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C1B,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;YACvC,sBAAsB,EAAE,CAAC;YACzB,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC;IACH,CAAC;IAED,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,GAAG,QAAQ,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words whose reading a build must reproduce.
|
|
3
|
+
*
|
|
4
|
+
* Each stands for a class of upstream defect a source refresh could
|
|
5
|
+
* reintroduce — a 儿化 repair, a sandhi normalisation, a polyphone the corpus
|
|
6
|
+
* would otherwise flatten — so a failure means the merge stopped doing
|
|
7
|
+
* something it used to, not that one word is wrong.
|
|
8
|
+
*/
|
|
9
|
+
import type { BuildAssertion } from "./built-dictionary.js";
|
|
10
|
+
/**
|
|
11
|
+
* Assert one word reads a particular way.
|
|
12
|
+
*/
|
|
13
|
+
export declare function reads(word: string, expected: string, why: string): BuildAssertion;
|
|
14
|
+
export declare const WORD_READINGS: readonly BuildAssertion[];
|
|
15
|
+
//# sourceMappingURL=word-readings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/word-readings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAE7E;;GAEG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,cAAc,CAahB;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EAmBlD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert one word reads a particular way.
|
|
3
|
+
*/
|
|
4
|
+
export function reads(word, expected, why) {
|
|
5
|
+
return {
|
|
6
|
+
description: `${word} → ${expected} (${why})`,
|
|
7
|
+
check: (dictionary) => {
|
|
8
|
+
const actual = dictionary.reading(word);
|
|
9
|
+
if (actual === undefined) {
|
|
10
|
+
return `${word} is missing from the dictionary`;
|
|
11
|
+
}
|
|
12
|
+
return actual === expected
|
|
13
|
+
? undefined
|
|
14
|
+
: `${word} reads ${actual}, expected ${expected}`;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export const WORD_READINGS = [
|
|
19
|
+
reads("玩儿", "wánr", "儿化 repaired from CC-CEDICT's r5"),
|
|
20
|
+
reads("女儿", "nǚ ér", "儿 keeps its own syllable here"),
|
|
21
|
+
reads("这儿", "zhèr", "儿化 despite upstream writing a tone on the er"),
|
|
22
|
+
reads("儿子", "ér zi", "儿化 exception list consulted"),
|
|
23
|
+
reads("一丁不识", "yī dīng bù shí", "一 sandhi normalised out"),
|
|
24
|
+
reads("一不小心", "yī bù xiǎo xīn", "一 and 不 sandhi normalised out"),
|
|
25
|
+
reads("大夫", "dài fu", "override applied over both sources"),
|
|
26
|
+
reads("东西", "dōng xi", "the thing, not the compass directions"),
|
|
27
|
+
reads("东西方", "dōng xī fāng", "and the directions where that is the word"),
|
|
28
|
+
reads("告诉", "gào su", "the everyday verb, not filing a complaint"),
|
|
29
|
+
reads("银行", "yín háng", "polyphone survives"),
|
|
30
|
+
reads("行长", "háng zhǎng", "polyphone survives"),
|
|
31
|
+
reads("头发", "tóu fa", "CC-CEDICT wins on the neutral tone"),
|
|
32
|
+
reads("还是", "hái shi", "CC-CEDICT wins on the neutral tone"),
|
|
33
|
+
reads("頭髮", "tóu fa", "繁體 derived using the reading, and keyed directly"),
|
|
34
|
+
reads("重複", "chóng fù", "one of two 繁體 spellings, both keyed"),
|
|
35
|
+
reads("重覆", "chóng fù", "the other, on the same entry"),
|
|
36
|
+
reads("下麵", "xià miàn", "both spellings of a word CC-CEDICT writes twice"),
|
|
37
|
+
];
|
|
38
|
+
//# sourceMappingURL=word-readings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word-readings.js","sourceRoot":"","sources":["../../src/dictionary/word-readings.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,UAAU,KAAK,CACnB,IAAY,EACZ,QAAgB,EAChB,GAAW;IAEX,OAAO;QACL,WAAW,EAAE,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG,GAAG;QAC7C,KAAK,EAAE,CAAC,UAA2B,EAAsB,EAAE;YACzD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,GAAG,IAAI,iCAAiC,CAAC;YAClD,CAAC;YACD,OAAO,MAAM,KAAK,QAAQ;gBACxB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,GAAG,IAAI,UAAU,MAAM,cAAc,QAAQ,EAAE,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAA8B;IACtD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,iCAAiC,CAAC;IACtD,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,+BAA+B,CAAC;IACrD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,8CAA8C,CAAC;IACnE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,6BAA6B,CAAC;IACnD,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,yBAAyB,CAAC;IAC1D,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,+BAA+B,CAAC;IAChE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,oCAAoC,CAAC;IAC3D,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,uCAAuC,CAAC;IAC/D,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,2CAA2C,CAAC;IACzE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,2CAA2C,CAAC;IAClE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,oBAAoB,CAAC;IAC7C,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,oBAAoB,CAAC;IAC/C,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,oCAAoC,CAAC;IAC3D,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,oCAAoC,CAAC;IAC5D,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,kDAAkD,CAAC;IACzE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,qCAAqC,CAAC;IAC9D,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,8BAA8B,CAAC;IACvD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,iDAAiD,CAAC;CAC3E,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing a conversion as ruby annotation.
|
|
3
|
+
*
|
|
4
|
+
* The pinyin sits above the characters rather than beside them, so the pieces
|
|
5
|
+
* are regrouped against the text they annotate.
|
|
6
|
+
*/
|
|
7
|
+
import { type HtmlOptions } from "./html.js";
|
|
8
|
+
import { type ConvertedPiece } from "../decode/convert.js";
|
|
9
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
10
|
+
/**
|
|
11
|
+
* What the characters being annotated declare themselves to be.
|
|
12
|
+
*
|
|
13
|
+
* The mirror of {@link languageTag}: inside an annotation the base is hanzi and
|
|
14
|
+
* only the reading is pinyin, so on an English page the two need different tags
|
|
15
|
+
* and neither can be left to inherit.
|
|
16
|
+
*
|
|
17
|
+
* **`zh`, with no script subtag, and that is deliberate.** `Hans` or `Hant`
|
|
18
|
+
* would be better for font selection, and neither can be known here. The
|
|
19
|
+
* conversion's locale does not settle it — script and locale are separate axes,
|
|
20
|
+
* and a mainland edition of a classical text is 繁體 read as `zh-CN` — and
|
|
21
|
+
* detecting it from the characters needs the script tables, which load
|
|
22
|
+
* separately from the dictionary precisely so that converting does not pay for
|
|
23
|
+
* them. A tag that is merely unspecific is worth more than one that is wrong,
|
|
24
|
+
* so a caller who knows the script should wrap the output and say so there.
|
|
25
|
+
*/
|
|
26
|
+
export declare const BASE_TAG = "zh";
|
|
27
|
+
/**
|
|
28
|
+
* One base and everything read off it.
|
|
29
|
+
*/
|
|
30
|
+
export interface Annotation {
|
|
31
|
+
/** The characters, or undefined for text that reads as nothing. */
|
|
32
|
+
readonly source: string | undefined;
|
|
33
|
+
readonly pieces: readonly ConvertedPiece[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gather pieces into the bases they are readings of.
|
|
37
|
+
*
|
|
38
|
+
* A piece naming characters opens a group and every piece after it that names
|
|
39
|
+
* none reads on into the same one, which is how 玩儿 keeps `wánr` over both
|
|
40
|
+
* characters and 95% keeps `bǎifēnzhījiǔshíwǔ` over all three. Pieces writing
|
|
41
|
+
* no reading at all — the spaces between words, and runs that were never Han —
|
|
42
|
+
* are their own groups, with nothing to annotate.
|
|
43
|
+
*/
|
|
44
|
+
export declare function annotationsOf(pieces: readonly ConvertedPiece[]): Annotation[];
|
|
45
|
+
/**
|
|
46
|
+
* Mark up a converted text as hanzi with its reading above, syllable by
|
|
47
|
+
* syllable.
|
|
48
|
+
*
|
|
49
|
+
* The output every other mode cannot give: `convert` and {@link toHtml} write
|
|
50
|
+
* the pinyin *instead of* the hanzi, and a learner's text, a subtitle and a
|
|
51
|
+
* dictionary entry all want both at once. The markup is `<ruby>`, which every
|
|
52
|
+
* current browser lays out natively and which degrades to parentheses through
|
|
53
|
+
* `<rp>` where it is not supported.
|
|
54
|
+
*
|
|
55
|
+
* ```html
|
|
56
|
+
* <ruby lang="zh">银<rp>(</rp><rt><span …>yín</span></rt><rp>)</rp></ruby>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Each `<rt>` holds whatever {@link toHtml} would have written for those
|
|
60
|
+
* syllables, so tone classes and uncertainty marking work inside an annotation
|
|
61
|
+
* exactly as they do outside one.
|
|
62
|
+
*
|
|
63
|
+
* **A base is not always one character.** 玩儿 is two characters and the one
|
|
64
|
+
* syllable `wánr`, and a read number reverses on the way — 95% is
|
|
65
|
+
* `bǎifēnzhījiǔshíwǔ` — so both are annotated whole. Splitting them per
|
|
66
|
+
* character is what everything that emits ruby from a pinyin library gets
|
|
67
|
+
* wrong, and it is why {@link ConvertedPiece.source} exists.
|
|
68
|
+
*/
|
|
69
|
+
export declare function toAnnotatedHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
|
|
70
|
+
/**
|
|
71
|
+
* Convert hanzi to pinyin as HTML, hanzi and reading together.
|
|
72
|
+
*
|
|
73
|
+
* {@link toAnnotatedHtml} applied to a fresh conversion; see it for what the
|
|
74
|
+
* markup is and why a base is not always one character.
|
|
75
|
+
*/
|
|
76
|
+
export declare function convertToAnnotatedHtml(dictionary: Dictionary, text: string, options?: HtmlOptions): string;
|
|
77
|
+
/**
|
|
78
|
+
* Convert hanzi to pinyin as HTML, one element per syllable.
|
|
79
|
+
*
|
|
80
|
+
* What per-syllable confidence is for, and the reason ALGORITHM.md asks for it:
|
|
81
|
+
* a reading the decode was guessing at can be *shown* to be a guess, which for
|
|
82
|
+
* a learner is a feature rather than a diagnostic. No styling is imposed — the
|
|
83
|
+
* classes are hooks, and the page decides whether a fourth tone is red and an
|
|
84
|
+
* uncertain reading is dotted underneath.
|
|
85
|
+
*
|
|
86
|
+
* Nothing is wrapped around the whole conversion, and anything that is not Han
|
|
87
|
+
* passes through escaped rather than marked up.
|
|
88
|
+
*/
|
|
89
|
+
export declare function convertToHtml(dictionary: Dictionary, text: string, options?: HtmlOptions): string;
|
|
90
|
+
//# sourceMappingURL=annotate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../src/format/annotate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAU,KAAK,WAAW,EAAsB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,OAAO,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;CAC5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,UAAU,EAAE,CAc7E;AA2ED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,OAAO,GAAE,WAAgB,GACxB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,CAER;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,CAER"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing a conversion as ruby annotation.
|
|
3
|
+
*
|
|
4
|
+
* The pinyin sits above the characters rather than beside them, so the pieces
|
|
5
|
+
* are regrouped against the text they annotate.
|
|
6
|
+
*/
|
|
7
|
+
import { escape, toHtml, writePiece } from "./html.js";
|
|
8
|
+
import { convertPieces } from "../decode/convert.js";
|
|
9
|
+
/**
|
|
10
|
+
* What the characters being annotated declare themselves to be.
|
|
11
|
+
*
|
|
12
|
+
* The mirror of {@link languageTag}: inside an annotation the base is hanzi and
|
|
13
|
+
* only the reading is pinyin, so on an English page the two need different tags
|
|
14
|
+
* and neither can be left to inherit.
|
|
15
|
+
*
|
|
16
|
+
* **`zh`, with no script subtag, and that is deliberate.** `Hans` or `Hant`
|
|
17
|
+
* would be better for font selection, and neither can be known here. The
|
|
18
|
+
* conversion's locale does not settle it — script and locale are separate axes,
|
|
19
|
+
* and a mainland edition of a classical text is 繁體 read as `zh-CN` — and
|
|
20
|
+
* detecting it from the characters needs the script tables, which load
|
|
21
|
+
* separately from the dictionary precisely so that converting does not pay for
|
|
22
|
+
* them. A tag that is merely unspecific is worth more than one that is wrong,
|
|
23
|
+
* so a caller who knows the script should wrap the output and say so there.
|
|
24
|
+
*/
|
|
25
|
+
export const BASE_TAG = "zh";
|
|
26
|
+
/**
|
|
27
|
+
* Gather pieces into the bases they are readings of.
|
|
28
|
+
*
|
|
29
|
+
* A piece naming characters opens a group and every piece after it that names
|
|
30
|
+
* none reads on into the same one, which is how 玩儿 keeps `wánr` over both
|
|
31
|
+
* characters and 95% keeps `bǎifēnzhījiǔshíwǔ` over all three. Pieces writing
|
|
32
|
+
* no reading at all — the spaces between words, and runs that were never Han —
|
|
33
|
+
* are their own groups, with nothing to annotate.
|
|
34
|
+
*/
|
|
35
|
+
export function annotationsOf(pieces) {
|
|
36
|
+
const groups = [];
|
|
37
|
+
for (const [at, piece] of pieces.entries()) {
|
|
38
|
+
const open = groups.at(-1);
|
|
39
|
+
if (open?.source !== undefined && continues(piece, pieces[at + 1])) {
|
|
40
|
+
groups[groups.length - 1] = {
|
|
41
|
+
source: open.source,
|
|
42
|
+
pieces: [...open.pieces, piece],
|
|
43
|
+
};
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
groups.push({ source: piece.source, pieces: [piece] });
|
|
47
|
+
}
|
|
48
|
+
return groups;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether a piece belongs to the annotation the group before it opened.
|
|
52
|
+
*
|
|
53
|
+
* Three kinds do:
|
|
54
|
+
*
|
|
55
|
+
* - A **syllable naming no characters** is reading on into the ones already
|
|
56
|
+
* named, which is 儿化 and every syllable of a read number after the first.
|
|
57
|
+
* - A **separator that is not a space** is a mark *inside* one orthographic
|
|
58
|
+
* word rather than a gap between two — the hyphen of `gāngān-jìngjìng`, the
|
|
59
|
+
* only one GB/T 16159 writes — so it belongs beside the syllables it divides.
|
|
60
|
+
* - A **space with more of the same reading after it**. 1988 is read
|
|
61
|
+
* `yī jiǔ bā bā`, four syllables over one base, and the spaces between them
|
|
62
|
+
* are inside that reading rather than between two of them.
|
|
63
|
+
*
|
|
64
|
+
* That last one is why this needs the piece after it. A space is written the
|
|
65
|
+
* same way whether it separates two words or two syllables of one number, and
|
|
66
|
+
* what tells them apart is whether what follows is still reading the same
|
|
67
|
+
* characters. Told apart wrongly, the reading escapes its own annotation:
|
|
68
|
+
* 1988年 came out as `1988` over `yī` with `jiǔ bā bā` loose beside it.
|
|
69
|
+
*
|
|
70
|
+
* A space between two words is the case that does not continue, and dropping it
|
|
71
|
+
* is the point: the hanzi it annotates has no space in it, and each base is
|
|
72
|
+
* already its own group on the page.
|
|
73
|
+
*/
|
|
74
|
+
function continues(piece, next) {
|
|
75
|
+
if (piece.syllable !== undefined) {
|
|
76
|
+
return piece.source === undefined;
|
|
77
|
+
}
|
|
78
|
+
if (piece.source !== undefined) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return (piece.text.trim() !== "" ||
|
|
82
|
+
(next?.syllable !== undefined && next.source === undefined));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Mark up one base and its reading.
|
|
86
|
+
*/
|
|
87
|
+
function writeAnnotation(annotation, options) {
|
|
88
|
+
const { lang = true } = options;
|
|
89
|
+
const { source, pieces } = annotation;
|
|
90
|
+
if (pieces.every((piece) => piece.syllable === undefined)) {
|
|
91
|
+
// Nothing is read here. Either it is source text that simply has no
|
|
92
|
+
// reading — punctuation, a Latin word — and is written as the author wrote
|
|
93
|
+
// it, or it is pinyin orthography with no source behind it at all: the
|
|
94
|
+
// space between two words, and the hyphen in `gāngān-jìngjìng`. Writing
|
|
95
|
+
// those into the hanzi would annotate 干干净净 as 干干-净净.
|
|
96
|
+
return source === undefined ? "" : escape(source);
|
|
97
|
+
}
|
|
98
|
+
if (source === undefined) {
|
|
99
|
+
// A reading whose piece never named what it reads. Nothing a conversion
|
|
100
|
+
// builds looks like this — every group is opened by a piece carrying its
|
|
101
|
+
// characters — but {@link toAnnotatedHtml} takes pieces from the caller,
|
|
102
|
+
// and there is no base to hang an annotation on, so it is written as the
|
|
103
|
+
// plain markup it would have got from {@link toHtml}.
|
|
104
|
+
return pieces.map((piece) => writePiece(piece, options)).join("");
|
|
105
|
+
}
|
|
106
|
+
const reading = pieces.map((piece) => writePiece(piece, options)).join("");
|
|
107
|
+
// The tag goes on the <ruby> rather than around the base, and the syllables
|
|
108
|
+
// inside the <rt> override it with their own. `<rb>` would be the obvious
|
|
109
|
+
// place for it and is not an element any more: the WHATWG parser drops it,
|
|
110
|
+
// leaving the base as bare text, so writing one would mean emitting markup
|
|
111
|
+
// that no browser keeps.
|
|
112
|
+
const opening = lang ? `<ruby lang="${BASE_TAG}">` : "<ruby>";
|
|
113
|
+
return `${opening}${escape(source)}<rp>(</rp><rt>${reading}</rt><rp>)</rp></ruby>`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Mark up a converted text as hanzi with its reading above, syllable by
|
|
117
|
+
* syllable.
|
|
118
|
+
*
|
|
119
|
+
* The output every other mode cannot give: `convert` and {@link toHtml} write
|
|
120
|
+
* the pinyin *instead of* the hanzi, and a learner's text, a subtitle and a
|
|
121
|
+
* dictionary entry all want both at once. The markup is `<ruby>`, which every
|
|
122
|
+
* current browser lays out natively and which degrades to parentheses through
|
|
123
|
+
* `<rp>` where it is not supported.
|
|
124
|
+
*
|
|
125
|
+
* ```html
|
|
126
|
+
* <ruby lang="zh">银<rp>(</rp><rt><span …>yín</span></rt><rp>)</rp></ruby>
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* Each `<rt>` holds whatever {@link toHtml} would have written for those
|
|
130
|
+
* syllables, so tone classes and uncertainty marking work inside an annotation
|
|
131
|
+
* exactly as they do outside one.
|
|
132
|
+
*
|
|
133
|
+
* **A base is not always one character.** 玩儿 is two characters and the one
|
|
134
|
+
* syllable `wánr`, and a read number reverses on the way — 95% is
|
|
135
|
+
* `bǎifēnzhījiǔshíwǔ` — so both are annotated whole. Splitting them per
|
|
136
|
+
* character is what everything that emits ruby from a pinyin library gets
|
|
137
|
+
* wrong, and it is why {@link ConvertedPiece.source} exists.
|
|
138
|
+
*/
|
|
139
|
+
export function toAnnotatedHtml(pieces, options = {}) {
|
|
140
|
+
return annotationsOf(pieces)
|
|
141
|
+
.map((annotation) => writeAnnotation(annotation, options))
|
|
142
|
+
.join("");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Convert hanzi to pinyin as HTML, hanzi and reading together.
|
|
146
|
+
*
|
|
147
|
+
* {@link toAnnotatedHtml} applied to a fresh conversion; see it for what the
|
|
148
|
+
* markup is and why a base is not always one character.
|
|
149
|
+
*/
|
|
150
|
+
export function convertToAnnotatedHtml(dictionary, text, options = {}) {
|
|
151
|
+
return toAnnotatedHtml(convertPieces(dictionary, text, options), options);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Convert hanzi to pinyin as HTML, one element per syllable.
|
|
155
|
+
*
|
|
156
|
+
* What per-syllable confidence is for, and the reason ALGORITHM.md asks for it:
|
|
157
|
+
* a reading the decode was guessing at can be *shown* to be a guess, which for
|
|
158
|
+
* a learner is a feature rather than a diagnostic. No styling is imposed — the
|
|
159
|
+
* classes are hooks, and the page decides whether a fourth tone is red and an
|
|
160
|
+
* uncertain reading is dotted underneath.
|
|
161
|
+
*
|
|
162
|
+
* Nothing is wrapped around the whole conversion, and anything that is not Han
|
|
163
|
+
* passes through escaped rather than marked up.
|
|
164
|
+
*/
|
|
165
|
+
export function convertToHtml(dictionary, text, options = {}) {
|
|
166
|
+
return toHtml(convertPieces(dictionary, text, options), options);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=annotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.js","sourceRoot":"","sources":["../../src/format/annotate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAoB,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAuB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAW7B;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,MAAiC;IAC7D,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,IAAI,EAAE,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG;gBAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;aAChC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,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/format/html.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
export { convertToAnnotatedHtml, convertToHtml, toAnnotatedHtml, } from "./annotate.js";
|
|
2
|
+
import type { ConvertedPiece, ConvertOptions } from "../decode/convert.js";
|
|
3
3
|
/**
|
|
4
4
|
* How a conversion is marked up.
|
|
5
5
|
*/
|
|
@@ -29,55 +29,24 @@ export interface HtmlOptions extends ConvertOptions {
|
|
|
29
29
|
readonly lang?: boolean;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* Takes the pieces {@link convertPieces} produces, so that a caller can convert
|
|
35
|
-
* once and render more than one way.
|
|
36
|
-
*/
|
|
37
|
-
export declare function toHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
|
|
38
|
-
/**
|
|
39
|
-
* Mark up a converted text as hanzi with its reading above, syllable by
|
|
40
|
-
* syllable.
|
|
41
|
-
*
|
|
42
|
-
* The output every other mode cannot give: `convert` and {@link toHtml} write
|
|
43
|
-
* the pinyin *instead of* the hanzi, and a learner's text, a subtitle and a
|
|
44
|
-
* dictionary entry all want both at once. The markup is `<ruby>`, which every
|
|
45
|
-
* current browser lays out natively and which degrades to parentheses through
|
|
46
|
-
* `<rp>` where it is not supported.
|
|
32
|
+
* Escape text for markup.
|
|
47
33
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* syllables, so tone classes and uncertainty marking work inside an annotation
|
|
54
|
-
* exactly as they do outside one.
|
|
55
|
-
*
|
|
56
|
-
* **A base is not always one character.** 玩儿 is two characters and the one
|
|
57
|
-
* syllable `wánr`, and a read number reverses on the way — 95% is
|
|
58
|
-
* `bǎifēnzhījiǔshíwǔ` — so both are annotated whole. Splitting them per
|
|
59
|
-
* character is what everything that emits ruby from a pinyin library gets
|
|
60
|
-
* wrong, and it is why {@link ConvertedPiece.source} exists.
|
|
34
|
+
* Applied to everything, including the source's own text: a conversion passes
|
|
35
|
+
* anything that is not Han through untouched, so `<script>` in the input
|
|
36
|
+
* reaches the output as written. The apostrophe is deliberately not escaped:
|
|
37
|
+
* every attribute here is double-quoted, and the 隔音符号 of `Xī'ān` is a
|
|
38
|
+
* letter of the orthography that a reader should see as one.
|
|
61
39
|
*/
|
|
62
|
-
export declare function
|
|
40
|
+
export declare function escape(text: string): string;
|
|
63
41
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* {@link toAnnotatedHtml} applied to a fresh conversion; see it for what the
|
|
67
|
-
* markup is and why a base is not always one character.
|
|
42
|
+
* Mark up one piece of a conversion.
|
|
68
43
|
*/
|
|
69
|
-
export declare function
|
|
44
|
+
export declare function writePiece(piece: ConvertedPiece, options: HtmlOptions): string;
|
|
70
45
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* What per-syllable confidence is for, and the reason ALGORITHM.md asks for it:
|
|
74
|
-
* a reading the decode was guessing at can be *shown* to be a guess, which for
|
|
75
|
-
* a learner is a feature rather than a diagnostic. No styling is imposed — the
|
|
76
|
-
* classes are hooks, and the page decides whether a fourth tone is red and an
|
|
77
|
-
* uncertain reading is dotted underneath.
|
|
46
|
+
* Mark up a converted text, one element per syllable.
|
|
78
47
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
48
|
+
* Takes the pieces {@link convertPieces} produces, so that a caller can convert
|
|
49
|
+
* once and render more than one way.
|
|
81
50
|
*/
|
|
82
|
-
export declare function
|
|
51
|
+
export declare function toHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
|
|
83
52
|
//# sourceMappingURL=html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/format/html.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/format/html.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3E;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAwDD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK3C;AAwBD;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,WAAW,GACnB,MAAM,CA4BR;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,OAAO,GAAE,WAAgB,GACxB,MAAM,CAER"}
|