@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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { readSyllable, writeSyllable } from "../syllable/syllable.js";
|
|
2
2
|
import { toCharacters } from "./characters.js";
|
|
3
|
+
export { readScriptTables } from "./conversion-read.js";
|
|
4
|
+
export { writeScriptTables } from "./conversion-write.js";
|
|
3
5
|
/**
|
|
4
6
|
* The key a reading is stored under: numbered pinyin, or the empty string.
|
|
5
7
|
*
|
|
@@ -67,121 +69,6 @@ export function convertCharacters(table, word, readings = []) {
|
|
|
67
69
|
}
|
|
68
70
|
return converted;
|
|
69
71
|
}
|
|
70
|
-
const COLUMN = "\t";
|
|
71
|
-
const LINE = "\n";
|
|
72
|
-
const READING = ",";
|
|
73
|
-
const READING_FORM = "=";
|
|
74
|
-
/**
|
|
75
|
-
* Line tags, one per table, so that all six ship as one fetchable file.
|
|
76
|
-
*/
|
|
77
|
-
const TAGS = {
|
|
78
|
-
toTraditional: "t",
|
|
79
|
-
toSimplified: "s",
|
|
80
|
-
traditionalWord: "w",
|
|
81
|
-
simplifiedWord: "x",
|
|
82
|
-
hansOnly: "h",
|
|
83
|
-
hantOnly: "H",
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Write one character table's lines.
|
|
87
|
-
*/
|
|
88
|
-
function writeCharacterTable(tag, table) {
|
|
89
|
-
return [...table].map(([character, conversion]) => {
|
|
90
|
-
const readings = [...(conversion.byReading ?? [])]
|
|
91
|
-
.map(([key, form]) => `${key}${READING_FORM}${form}`)
|
|
92
|
-
.join(READING);
|
|
93
|
-
const also = (conversion.also ?? []).join("");
|
|
94
|
-
const columns = [tag, character, conversion.to, readings, also];
|
|
95
|
-
// Trailing empty columns say nothing and are dropped, which is most lines:
|
|
96
|
-
// the common case is a character with one form and no reading to condition.
|
|
97
|
-
while (columns.at(-1) === "") {
|
|
98
|
-
columns.pop();
|
|
99
|
-
}
|
|
100
|
-
return columns.join(COLUMN);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Write the tables as the artifact text.
|
|
105
|
-
*
|
|
106
|
-
* One line per mapping, tagged by which table it belongs to, so the whole of
|
|
107
|
-
* script conversion is a single file to fetch and a single scan to read. The
|
|
108
|
-
* format is the same shape as the dictionary's: separators rather than syntax,
|
|
109
|
-
* so that reading it back is a split rather than a parse.
|
|
110
|
-
*/
|
|
111
|
-
export function writeScriptTables(tables) {
|
|
112
|
-
return [
|
|
113
|
-
...writeCharacterTable(TAGS.toTraditional, tables.toTraditional),
|
|
114
|
-
...writeCharacterTable(TAGS.toSimplified, tables.toSimplified),
|
|
115
|
-
...[...tables.traditionalWords].map(([hans, hant]) => [TAGS.traditionalWord, hans, hant].join(COLUMN)),
|
|
116
|
-
...[...tables.simplifiedWords].map(([hant, hans]) => [TAGS.simplifiedWord, hant, hans].join(COLUMN)),
|
|
117
|
-
...[...tables.hansOnly].map((character) => [TAGS.hansOnly, character].join(COLUMN)),
|
|
118
|
-
...[...tables.hantOnly].map((character) => [TAGS.hantOnly, character].join(COLUMN)),
|
|
119
|
-
"",
|
|
120
|
-
].join(LINE);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Read one character table line into its conversion.
|
|
124
|
-
*/
|
|
125
|
-
function readConversion(to, readings, also) {
|
|
126
|
-
const pairs = readings === "" ? [] : readings.split(READING);
|
|
127
|
-
const byReading = new Map();
|
|
128
|
-
for (const pair of pairs) {
|
|
129
|
-
const [key = "", form = ""] = pair.split(READING_FORM);
|
|
130
|
-
if (form !== "") {
|
|
131
|
-
byReading.set(key, form);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
to,
|
|
136
|
-
...(byReading.size > 0 && { byReading }),
|
|
137
|
-
...(also !== "" && { also: toCharacters(also) }),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Read the tables back from the artifact text.
|
|
142
|
-
*
|
|
143
|
-
* Unknown tags are skipped rather than rejected, so that a future table can be
|
|
144
|
-
* added without an older reader refusing the file outright.
|
|
145
|
-
*/
|
|
146
|
-
export function readScriptTables(text) {
|
|
147
|
-
const toTraditional = new Map();
|
|
148
|
-
const toSimplified = new Map();
|
|
149
|
-
const traditionalWords = new Map();
|
|
150
|
-
const simplifiedWords = new Map();
|
|
151
|
-
const hansOnly = new Set();
|
|
152
|
-
const hantOnly = new Set();
|
|
153
|
-
const characterTables = new Map([
|
|
154
|
-
[TAGS.toTraditional, toTraditional],
|
|
155
|
-
[TAGS.toSimplified, toSimplified],
|
|
156
|
-
]);
|
|
157
|
-
const wordTables = new Map([
|
|
158
|
-
[TAGS.traditionalWord, traditionalWords],
|
|
159
|
-
[TAGS.simplifiedWord, simplifiedWords],
|
|
160
|
-
]);
|
|
161
|
-
const characterSets = new Map([
|
|
162
|
-
[TAGS.hansOnly, hansOnly],
|
|
163
|
-
[TAGS.hantOnly, hantOnly],
|
|
164
|
-
]);
|
|
165
|
-
for (const line of text.split(LINE)) {
|
|
166
|
-
const [tag = "", from = "", to = "", readings = "", also = ""] = line.split(COLUMN);
|
|
167
|
-
if (from === "") {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
// Dispatching on a map rather than a switch keeps an unknown tag a no-op,
|
|
171
|
-
// so a file written by a later version reads as much as this one knows.
|
|
172
|
-
characterTables.get(tag)?.set(from, readConversion(to, readings, also));
|
|
173
|
-
wordTables.get(tag)?.set(from, to);
|
|
174
|
-
characterSets.get(tag)?.add(from);
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
toTraditional,
|
|
178
|
-
toSimplified,
|
|
179
|
-
traditionalWords,
|
|
180
|
-
simplifiedWords,
|
|
181
|
-
hansOnly,
|
|
182
|
-
hantOnly,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
72
|
/**
|
|
186
73
|
* Parse a stored reading key back into a syllable.
|
|
187
74
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.js","sourceRoot":"","sources":["../../src/script/conversion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversion.js","sourceRoot":"","sources":["../../src/script/conversion.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAkD1D;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,QAA8B;IAC1D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,oDAAoD;IACpD,OAAO,aAAa,CAAC,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAA+C,EAC/C,SAAiB,EACjB,QAA8B;IAE9B,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,GAAG,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAA+C,EAC/C,SAAiB;IAEjB,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,UAA2C;IAE3C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO;QACL,GAAG,IAAI,GAAG,CAAC;YACT,UAAU,CAAC,EAAE;YACb,GAAG,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YACzC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;SAC3B,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA+C,EAC/C,IAAY,EACZ,QAAQ,GAAsC,EAAE;IAEhD,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,KAAK,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3D,SAAS,IAAI,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a found candidate list is narrowed before it is handed back.
|
|
3
|
+
*
|
|
4
|
+
* Both of the searches in `candidates.ts` end the same way: they have every word
|
|
5
|
+
* a reading reaches, in rank order, and the caller wants fewer of them. The
|
|
6
|
+
* narrowing is the same for both — collapse the two scripts, then cut to the
|
|
7
|
+
* limit — so it lives here rather than twice there, and the options that drive
|
|
8
|
+
* it live beside it.
|
|
9
|
+
*/
|
|
10
|
+
import { type ScriptTables } from "../script/conversion.js";
|
|
11
|
+
import type { Script } from "../script/script.js";
|
|
12
|
+
/**
|
|
13
|
+
* Which script a caller wants a candidate list written in, and the tables that
|
|
14
|
+
* can tell.
|
|
15
|
+
*
|
|
16
|
+
* The two are one option because neither is any use without the other. Both
|
|
17
|
+
* scripts are dictionary keys, so a reading group holds 银行 *and* 銀行 — over a
|
|
18
|
+
* third of a typical list is that pairing — and the artifact deliberately does
|
|
19
|
+
* not record which 简体 form pairs with which 繁體 one, since conversion never
|
|
20
|
+
* needs it. So the index cannot pair them on its own, and honouring a
|
|
21
|
+
* preference means loading `script.map`: about 100 KB that the hanzi → pinyin
|
|
22
|
+
* path never fetches.
|
|
23
|
+
*
|
|
24
|
+
* Asking for the preference and the tables in one object is what keeps that
|
|
25
|
+
* cost visible at the call site rather than hidden inside a load.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const tables = await loadScriptTables(source);
|
|
29
|
+
* candidates(index, "yinhang", { script: { prefer: "Hans", tables } });
|
|
30
|
+
* // 银行, and not 銀行 beside it
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface ScriptPreference {
|
|
34
|
+
/** The script to keep where both writings of a word are candidates. */
|
|
35
|
+
readonly prefer: Script;
|
|
36
|
+
/** The conversion tables, from `loadScriptTables`. */
|
|
37
|
+
readonly tables: ScriptTables;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How a candidate list should be narrowed.
|
|
41
|
+
*/
|
|
42
|
+
export interface CandidateOptions {
|
|
43
|
+
/** How many candidates to return at most. */
|
|
44
|
+
readonly limit?: number;
|
|
45
|
+
/** Keep one writing of a word rather than both; see {@link ScriptPreference}. */
|
|
46
|
+
readonly script?: ScriptPreference;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Apply the caller's options to a ranked list of candidates.
|
|
50
|
+
*
|
|
51
|
+
* In that order, because a limit counts what the caller will actually see: a
|
|
52
|
+
* list of five that collapses to three should be cut to three, not cut to five
|
|
53
|
+
* and then collapsed to two.
|
|
54
|
+
*/
|
|
55
|
+
export declare function narrowCandidates(found: readonly string[], options: CandidateOptions): readonly string[];
|
|
56
|
+
//# sourceMappingURL=candidate-narrowing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-narrowing.d.ts","sourceRoot":"","sources":["../../src/search/candidate-narrowing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;CACpC;AAuCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,gBAAgB,GACxB,SAAS,MAAM,EAAE,CAMnB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a found candidate list is narrowed before it is handed back.
|
|
3
|
+
*
|
|
4
|
+
* Both of the searches in `candidates.ts` end the same way: they have every word
|
|
5
|
+
* a reading reaches, in rank order, and the caller wants fewer of them. The
|
|
6
|
+
* narrowing is the same for both — collapse the two scripts, then cut to the
|
|
7
|
+
* limit — so it lives here rather than twice there, and the options that drive
|
|
8
|
+
* it live beside it.
|
|
9
|
+
*/
|
|
10
|
+
import { convertCharacters } from "../script/conversion.js";
|
|
11
|
+
/**
|
|
12
|
+
* Keep one writing of a word where the group holds both scripts.
|
|
13
|
+
*
|
|
14
|
+
* Paired by 简体 form in both directions rather than by converting toward the
|
|
15
|
+
* preference, because simplification is many-to-one and so the 简体 form is the
|
|
16
|
+
* one both writings agree on. Going the other way needs a reading to tell 發
|
|
17
|
+
* from 髮, and a pair that failed to meet would simply be left as two.
|
|
18
|
+
*
|
|
19
|
+
* The kept writing takes the rank of the better-placed of the two, so
|
|
20
|
+
* collapsing a list never reorders what is left of it.
|
|
21
|
+
*/
|
|
22
|
+
function preferScript(words, script) {
|
|
23
|
+
/** Whether a candidate is the writing the caller asked for. */
|
|
24
|
+
const isWanted = (word, simplified) => script.prefer === "Hans" ? word === simplified : word !== simplified;
|
|
25
|
+
const chosen = new Map();
|
|
26
|
+
const order = [];
|
|
27
|
+
for (const word of words) {
|
|
28
|
+
const simplified = convertCharacters(script.tables.toSimplified, word);
|
|
29
|
+
const held = chosen.get(simplified);
|
|
30
|
+
if (held === undefined) {
|
|
31
|
+
chosen.set(simplified, word);
|
|
32
|
+
order.push(simplified);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!isWanted(held, simplified) && isWanted(word, simplified)) {
|
|
36
|
+
chosen.set(simplified, word);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/* c8 ignore next -- every entry in `order` was put in `chosen` beside it */
|
|
40
|
+
return order.map((simplified) => chosen.get(simplified) ?? simplified);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Apply the caller's options to a ranked list of candidates.
|
|
44
|
+
*
|
|
45
|
+
* In that order, because a limit counts what the caller will actually see: a
|
|
46
|
+
* list of five that collapses to three should be cut to three, not cut to five
|
|
47
|
+
* and then collapsed to two.
|
|
48
|
+
*/
|
|
49
|
+
export function narrowCandidates(found, options) {
|
|
50
|
+
const preferred = options.script === undefined ? found : preferScript(found, options.script);
|
|
51
|
+
return options.limit === undefined
|
|
52
|
+
? preferred
|
|
53
|
+
: preferred.slice(0, Math.max(0, options.limit));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=candidate-narrowing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-narrowing.js","sourceRoot":"","sources":["../../src/search/candidate-narrowing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAyC/E;;;;;;;;;;GAUG;AACH,SAAS,YAAY,CACnB,KAAwB,EACxB,MAAwB;IAExB,+DAA+D;IAC/D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAW,EAAE,CAC7D,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;IAEvE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACvB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;YAC9D,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,4EAA4E;IAC5E,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAwB,EACxB,OAAyB;IAEzB,MAAM,SAAS,GACb,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7E,OAAO,OAAO,CAAC,KAAK,KAAK,SAAS;QAChC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A query in the one form the index is searched by, and the one it is filtered
|
|
3
|
+
* by.
|
|
4
|
+
*/
|
|
5
|
+
export interface Query {
|
|
6
|
+
/** The folded spelling, which is a reading key: toneless, no ü, no spaces. */
|
|
7
|
+
readonly key: string;
|
|
8
|
+
/** What was typed, with `v` and `u:` resolved and any tone still on it. */
|
|
9
|
+
readonly written: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Put a typed query into both the forms a search needs.
|
|
13
|
+
*
|
|
14
|
+
* Case, spacing and the ways of writing ü are all noise on the way to the key,
|
|
15
|
+
* and the tone is noise there too — the index is keyed toneless. None of it is
|
|
16
|
+
* noise on the way to the *filter*, which is what honours a tone the query
|
|
17
|
+
* wrote, so the resolved spelling is kept alongside.
|
|
18
|
+
*
|
|
19
|
+
* A tone written as a mark counts here, unlike in `match`. The reason it cannot
|
|
20
|
+
* count there is that a mark says nothing about where its syllable ends and a
|
|
21
|
+
* half-typed query is exactly where that is unsettled; here the candidate's own
|
|
22
|
+
* reading says where every syllable ends, so the mark has somewhere to land.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readQuery(query: string): Query;
|
|
25
|
+
//# sourceMappingURL=candidate-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-query.d.ts","sourceRoot":"","sources":["../../src/search/candidate-query.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAK9C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a search query into the tokens it is matched by.
|
|
3
|
+
*
|
|
4
|
+
* A query is written with or without tones, with or without separators, and
|
|
5
|
+
* with v for ü, so it is normalised before anything is looked up.
|
|
6
|
+
*/
|
|
7
|
+
import { stripToneMarks } from "../tone/tone-mark.js";
|
|
8
|
+
import { readingKey } from "./reverse-index-format.js";
|
|
9
|
+
import { SEPARATORS } from "./candidate-writings.js";
|
|
10
|
+
import { normaliseUmlaut } from "../syllable/syllable.js";
|
|
11
|
+
/**
|
|
12
|
+
* Put a typed query into both the forms a search needs.
|
|
13
|
+
*
|
|
14
|
+
* Case, spacing and the ways of writing ü are all noise on the way to the key,
|
|
15
|
+
* and the tone is noise there too — the index is keyed toneless. None of it is
|
|
16
|
+
* noise on the way to the *filter*, which is what honours a tone the query
|
|
17
|
+
* wrote, so the resolved spelling is kept alongside.
|
|
18
|
+
*
|
|
19
|
+
* A tone written as a mark counts here, unlike in `match`. The reason it cannot
|
|
20
|
+
* count there is that a mark says nothing about where its syllable ends and a
|
|
21
|
+
* half-typed query is exactly where that is unsettled; here the candidate's own
|
|
22
|
+
* reading says where every syllable ends, so the mark has somewhere to land.
|
|
23
|
+
*/
|
|
24
|
+
export function readQuery(query) {
|
|
25
|
+
const written = normaliseUmlaut(query.normalize("NFC").toLowerCase()).replaceAll(SEPARATORS, "");
|
|
26
|
+
return { key: readingKey(stripToneMarks(written)), written };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=candidate-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-query.js","sourceRoot":"","sources":["../../src/search/candidate-query.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAa1D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,eAAe,CAC7B,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CACrC,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC7B,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a query may write between syllables, all of which mean nothing here.
|
|
3
|
+
*
|
|
4
|
+
* The same set the matcher accepts, minus its meaning: `match` treats a written
|
|
5
|
+
* boundary as evidence, because a haystack it is filtering can be read more than
|
|
6
|
+
* one way. A reverse index is asked for one reading and answers with the words
|
|
7
|
+
* that have it, so `yin hang` and `yinhang` are the same question.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SEPARATORS: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* The 儿化 suffix, which is the one letter a reading key keeps and a query may
|
|
12
|
+
* leave off.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ERHUA = "r";
|
|
15
|
+
/**
|
|
16
|
+
* Whether a query spells a reading, syllable by syllable.
|
|
17
|
+
*
|
|
18
|
+
* Walked as a set of positions the query can have been read up to rather than
|
|
19
|
+
* one cursor, because a syllable can be written more than one way and the ways
|
|
20
|
+
* are different lengths: `wanr2` is `wan` or `wanr`, and only what follows says
|
|
21
|
+
* which was meant.
|
|
22
|
+
*/
|
|
23
|
+
export declare function spells(query: string, reading: string, writings: Map<string, readonly string[]>): boolean;
|
|
24
|
+
//# sourceMappingURL=candidate-writings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-writings.d.ts","sourceRoot":"","sources":["../../src/search/candidate-writings.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,QAAgB,CAAC;AAmBxC;;;GAGG;AACH,eAAO,MAAM,KAAK,MAAM,CAAC;AAgDzB;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,GACvC,OAAO,CAsBT"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ways a typist may write a reading the dictionary stores one way.
|
|
3
|
+
*
|
|
4
|
+
* A stored reading is `yin2 hang2`: syllables separated, tones as digits, ü
|
|
5
|
+
* written as ü. A query for it is whatever a keyboard makes easy. This module
|
|
6
|
+
* holds the whole span between the two, so that the lookup itself can ask one
|
|
7
|
+
* question — does this query spell this reading? — and nothing else.
|
|
8
|
+
*/
|
|
9
|
+
import { applyToneMark } from "../tone/tone-mark.js";
|
|
10
|
+
import { readSyllable, writeSyllable } from "../syllable/syllable.js";
|
|
11
|
+
import { TONES } from "../tone/tone.js";
|
|
12
|
+
/**
|
|
13
|
+
* What a query may write between syllables, all of which mean nothing here.
|
|
14
|
+
*
|
|
15
|
+
* The same set the matcher accepts, minus its meaning: `match` treats a written
|
|
16
|
+
* boundary as evidence, because a haystack it is filtering can be read more than
|
|
17
|
+
* one way. A reverse index is asked for one reading and answers with the words
|
|
18
|
+
* that have it, so `yin hang` and `yinhang` are the same question.
|
|
19
|
+
*/
|
|
20
|
+
export const SEPARATORS = /[\s'’‘-]+/gu;
|
|
21
|
+
/**
|
|
22
|
+
* A tone written as a digit, which is the last character of a syllable.
|
|
23
|
+
*/
|
|
24
|
+
const TONE_DIGIT = /^[0-5]$/u;
|
|
25
|
+
/**
|
|
26
|
+
* Every tone a syllable that wrote none could be standing for.
|
|
27
|
+
*/
|
|
28
|
+
const TONE_DIGITS = ["1", "2", "3", "4", "5"];
|
|
29
|
+
/**
|
|
30
|
+
* The umlaut the readings are written with, and the letter a keyboard has.
|
|
31
|
+
*/
|
|
32
|
+
const UMLAUT = "ü";
|
|
33
|
+
const PLAIN_U = "u";
|
|
34
|
+
/**
|
|
35
|
+
* The 儿化 suffix, which is the one letter a reading key keeps and a query may
|
|
36
|
+
* leave off.
|
|
37
|
+
*/
|
|
38
|
+
export const ERHUA = "r";
|
|
39
|
+
/**
|
|
40
|
+
* Every way a typist may write one syllable of a stored reading.
|
|
41
|
+
*
|
|
42
|
+
* `shi4` is written `shi`, `shi4` or `shì`; `lü4` adds `lu` and `lu4`, since ü
|
|
43
|
+
* is not on the keyboard; and an 儿化 `wanr2` adds the whole set again with the
|
|
44
|
+
* r left off, because 玩儿 is `wanr` to one typist and `wan` to another.
|
|
45
|
+
*
|
|
46
|
+
* The r comes off only where the syllable really is 儿化. 儿 itself is `er2`,
|
|
47
|
+
* and letting that shed its r would answer `e` with 儿.
|
|
48
|
+
*/
|
|
49
|
+
function writingsOf(token) {
|
|
50
|
+
const digit = token.slice(-1);
|
|
51
|
+
const toned = TONE_DIGIT.test(digit);
|
|
52
|
+
const spelling = toned ? token.slice(0, -1) : token;
|
|
53
|
+
const syllable = readSyllable(token);
|
|
54
|
+
// A reading with no tone written cannot contradict one, so a query is free to
|
|
55
|
+
// write any. Every reading the shipped artifacts hold has a tone digit on it,
|
|
56
|
+
// so this is a case a hand-built dictionary reaches rather than a real one.
|
|
57
|
+
const tones = toned ? [digit] : TONE_DIGITS;
|
|
58
|
+
const written = new Set();
|
|
59
|
+
const add = (form) => {
|
|
60
|
+
const plain = form.replaceAll(UMLAUT, PLAIN_U);
|
|
61
|
+
written.add(form);
|
|
62
|
+
written.add(plain);
|
|
63
|
+
for (const tone of tones) {
|
|
64
|
+
written.add(`${form}${tone}`);
|
|
65
|
+
written.add(`${plain}${tone}`);
|
|
66
|
+
}
|
|
67
|
+
if (!toned) {
|
|
68
|
+
for (const tone of TONES) {
|
|
69
|
+
written.add(applyToneMark(form, tone));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
add(spelling);
|
|
74
|
+
if (syllable !== undefined) {
|
|
75
|
+
written.add(writeSyllable(syllable, "marks"));
|
|
76
|
+
if (syllable.erhua === true) {
|
|
77
|
+
add(spelling.slice(0, -ERHUA.length));
|
|
78
|
+
written.add(writeSyllable({ ...syllable, erhua: false }, "marks"));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return [...written];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Whether a query spells a reading, syllable by syllable.
|
|
85
|
+
*
|
|
86
|
+
* Walked as a set of positions the query can have been read up to rather than
|
|
87
|
+
* one cursor, because a syllable can be written more than one way and the ways
|
|
88
|
+
* are different lengths: `wanr2` is `wan` or `wanr`, and only what follows says
|
|
89
|
+
* which was meant.
|
|
90
|
+
*/
|
|
91
|
+
export function spells(query, reading, writings) {
|
|
92
|
+
let reached = new Set([0]);
|
|
93
|
+
for (const token of reading.split(" ")) {
|
|
94
|
+
let forms = writings.get(token);
|
|
95
|
+
if (forms === undefined) {
|
|
96
|
+
forms = writingsOf(token);
|
|
97
|
+
writings.set(token, forms);
|
|
98
|
+
}
|
|
99
|
+
const next = new Set();
|
|
100
|
+
for (const at of reached) {
|
|
101
|
+
for (const form of forms) {
|
|
102
|
+
if (query.startsWith(form, at)) {
|
|
103
|
+
next.add(at + form.length);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (next.size === 0) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
reached = next;
|
|
111
|
+
}
|
|
112
|
+
return reached.has(query.length);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=candidate-writings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-writings.js","sourceRoot":"","sources":["../../src/search/candidate-writings.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { Script } from "../script/script.js";
|
|
1
|
+
import { type CandidateOptions } from "./candidate-narrowing.js";
|
|
3
2
|
import { type ReverseIndex } from "./reverse-index.js";
|
|
4
|
-
|
|
5
|
-
* Which script a caller wants a candidate list written in, and the tables that
|
|
6
|
-
* can tell.
|
|
7
|
-
*
|
|
8
|
-
* The two are one option because neither is any use without the other. Both
|
|
9
|
-
* scripts are dictionary keys, so a reading group holds 银行 *and* 銀行 — over a
|
|
10
|
-
* third of a typical list is that pairing — and the artifact deliberately does
|
|
11
|
-
* not record which 简体 form pairs with which 繁體 one, since conversion never
|
|
12
|
-
* needs it. So the index cannot pair them on its own, and honouring a
|
|
13
|
-
* preference means loading `script.map`: about 100 KB that the hanzi → pinyin
|
|
14
|
-
* path never fetches.
|
|
15
|
-
*
|
|
16
|
-
* Asking for the preference and the tables in one object is what keeps that
|
|
17
|
-
* cost visible at the call site rather than hidden inside a load.
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* const tables = await loadScriptTables(source);
|
|
21
|
-
* candidates(index, "yinhang", { script: { prefer: "Hans", tables } });
|
|
22
|
-
* // 银行, and not 銀行 beside it
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export interface ScriptPreference {
|
|
26
|
-
/** The script to keep where both writings of a word are candidates. */
|
|
27
|
-
readonly prefer: Script;
|
|
28
|
-
/** The conversion tables, from `loadScriptTables`. */
|
|
29
|
-
readonly tables: ScriptTables;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* How a candidate list should be narrowed.
|
|
33
|
-
*/
|
|
34
|
-
export interface CandidateOptions {
|
|
35
|
-
/** How many candidates to return at most. */
|
|
36
|
-
readonly limit?: number;
|
|
37
|
-
/** Keep one writing of a word rather than both; see {@link ScriptPreference}. */
|
|
38
|
-
readonly script?: ScriptPreference;
|
|
39
|
-
}
|
|
3
|
+
export type { CandidateOptions, ScriptPreference, } from "./candidate-narrowing.js";
|
|
40
4
|
/**
|
|
41
5
|
* The words a pinyin query could be spelling, likeliest first.
|
|
42
6
|
*
|
|
@@ -58,7 +22,8 @@ export interface CandidateOptions {
|
|
|
58
22
|
* spaces between syllables, and the r of 儿化.
|
|
59
23
|
*
|
|
60
24
|
* Both scripts are dictionary keys, so 银行 and 銀行 both come back unless a
|
|
61
|
-
* {@link ScriptPreference} says which to
|
|
25
|
+
* {@link import("./candidate-narrowing.js").ScriptPreference} says which to
|
|
26
|
+
* keep.
|
|
62
27
|
*/
|
|
63
28
|
export declare function candidates(index: ReverseIndex, query: string, options?: CandidateOptions): readonly string[];
|
|
64
29
|
/**
|
|
@@ -74,8 +39,9 @@ export declare function candidates(index: ReverseIndex, query: string, options?:
|
|
|
74
39
|
* dictionary — 4,659 candidates — that narrowing costs 1.2 ms in total.
|
|
75
40
|
*
|
|
76
41
|
* The word itself is never in its own list. Neither is its other-script writing
|
|
77
|
-
* where a {@link ScriptPreference} is given,
|
|
78
|
-
* 银行 but the same word spelled for a
|
|
42
|
+
* where a {@link import("./candidate-narrowing.js").ScriptPreference} is given,
|
|
43
|
+
* since 銀行 is not a homophone of 银行 but the same word spelled for a
|
|
44
|
+
* different reader.
|
|
79
45
|
*
|
|
80
46
|
* Returns nothing for a word the dictionary does not hold, since a word with no
|
|
81
47
|
* reading has no homophones rather than all of them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../src/search/candidates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../src/search/candidates.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAuClC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,gBAAqB,GAC7B,SAAS,MAAM,EAAE,CAyBnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,gBAAqB,GAC7B,SAAS,MAAM,EAAE,CA8BnB"}
|