@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,129 +1,10 @@
|
|
|
1
1
|
import { encodeReading } from "../dictionary/artifact.js";
|
|
2
|
+
import { readQuery } from "./candidate-query.js";
|
|
3
|
+
import { ERHUA, spells } from "./candidate-writings.js";
|
|
4
|
+
import { narrowCandidates, } from "./candidate-narrowing.js";
|
|
2
5
|
import { convertCharacters } from "../script/conversion.js";
|
|
3
6
|
import { toCanonicalGlyphs } from "../script/glyphs.js";
|
|
4
|
-
import { normaliseUmlaut, readSyllable, writeSyllable, } from "../syllable/syllable.js";
|
|
5
|
-
import { applyToneMark, stripToneMarks } from "../tone/tone-mark.js";
|
|
6
|
-
import { TONES } from "../tone/tone.js";
|
|
7
7
|
import { readingKey } from "./reverse-index.js";
|
|
8
|
-
/**
|
|
9
|
-
* What a query may write between syllables, all of which mean nothing here.
|
|
10
|
-
*
|
|
11
|
-
* The same set the matcher accepts, minus its meaning: `match` treats a written
|
|
12
|
-
* boundary as evidence, because a haystack it is filtering can be read more than
|
|
13
|
-
* one way. A reverse index is asked for one reading and answers with the words
|
|
14
|
-
* that have it, so `yin hang` and `yinhang` are the same question.
|
|
15
|
-
*/
|
|
16
|
-
const SEPARATORS = /[\s'’‘-]+/gu;
|
|
17
|
-
/**
|
|
18
|
-
* A tone written as a digit, which is the last character of a syllable.
|
|
19
|
-
*/
|
|
20
|
-
const TONE_DIGIT = /^[0-5]$/u;
|
|
21
|
-
/**
|
|
22
|
-
* Every tone a syllable that wrote none could be standing for.
|
|
23
|
-
*/
|
|
24
|
-
const TONE_DIGITS = ["1", "2", "3", "4", "5"];
|
|
25
|
-
/**
|
|
26
|
-
* The umlaut the readings are written with, and the letter a keyboard has.
|
|
27
|
-
*/
|
|
28
|
-
const UMLAUT = "ü";
|
|
29
|
-
const PLAIN_U = "u";
|
|
30
|
-
/**
|
|
31
|
-
* The 儿化 suffix, which is the one letter a reading key keeps and a query may
|
|
32
|
-
* leave off.
|
|
33
|
-
*/
|
|
34
|
-
const ERHUA = "r";
|
|
35
|
-
/**
|
|
36
|
-
* Put a typed query into both the forms a search needs.
|
|
37
|
-
*
|
|
38
|
-
* Case, spacing and the ways of writing ü are all noise on the way to the key,
|
|
39
|
-
* and the tone is noise there too — the index is keyed toneless. None of it is
|
|
40
|
-
* noise on the way to the *filter*, which is what honours a tone the query
|
|
41
|
-
* wrote, so the resolved spelling is kept alongside.
|
|
42
|
-
*
|
|
43
|
-
* A tone written as a mark counts here, unlike in `match`. The reason it cannot
|
|
44
|
-
* count there is that a mark says nothing about where its syllable ends and a
|
|
45
|
-
* half-typed query is exactly where that is unsettled; here the candidate's own
|
|
46
|
-
* reading says where every syllable ends, so the mark has somewhere to land.
|
|
47
|
-
*/
|
|
48
|
-
function readQuery(query) {
|
|
49
|
-
const written = normaliseUmlaut(query.normalize("NFC").toLowerCase()).replaceAll(SEPARATORS, "");
|
|
50
|
-
return { key: readingKey(stripToneMarks(written)), written };
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Every way a typist may write one syllable of a stored reading.
|
|
54
|
-
*
|
|
55
|
-
* `shi4` is written `shi`, `shi4` or `shì`; `lü4` adds `lu` and `lu4`, since ü
|
|
56
|
-
* is not on the keyboard; and an 儿化 `wanr2` adds the whole set again with the
|
|
57
|
-
* r left off, because 玩儿 is `wanr` to one typist and `wan` to another.
|
|
58
|
-
*
|
|
59
|
-
* The r comes off only where the syllable really is 儿化. 儿 itself is `er2`,
|
|
60
|
-
* and letting that shed its r would answer `e` with 儿.
|
|
61
|
-
*/
|
|
62
|
-
function writingsOf(token) {
|
|
63
|
-
const digit = token.slice(-1);
|
|
64
|
-
const toned = TONE_DIGIT.test(digit);
|
|
65
|
-
const spelling = toned ? token.slice(0, -1) : token;
|
|
66
|
-
const syllable = readSyllable(token);
|
|
67
|
-
// A reading with no tone written cannot contradict one, so a query is free to
|
|
68
|
-
// write any. Every reading the shipped artifacts hold has a tone digit on it,
|
|
69
|
-
// so this is a case a hand-built dictionary reaches rather than a real one.
|
|
70
|
-
const tones = toned ? [digit] : TONE_DIGITS;
|
|
71
|
-
const written = new Set();
|
|
72
|
-
const add = (form) => {
|
|
73
|
-
const plain = form.replaceAll(UMLAUT, PLAIN_U);
|
|
74
|
-
written.add(form);
|
|
75
|
-
written.add(plain);
|
|
76
|
-
for (const tone of tones) {
|
|
77
|
-
written.add(`${form}${tone}`);
|
|
78
|
-
written.add(`${plain}${tone}`);
|
|
79
|
-
}
|
|
80
|
-
if (!toned) {
|
|
81
|
-
for (const tone of TONES) {
|
|
82
|
-
written.add(applyToneMark(form, tone));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
add(spelling);
|
|
87
|
-
if (syllable !== undefined) {
|
|
88
|
-
written.add(writeSyllable(syllable, "marks"));
|
|
89
|
-
if (syllable.erhua === true) {
|
|
90
|
-
add(spelling.slice(0, -ERHUA.length));
|
|
91
|
-
written.add(writeSyllable({ ...syllable, erhua: false }, "marks"));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return [...written];
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Whether a query spells a reading, syllable by syllable.
|
|
98
|
-
*
|
|
99
|
-
* Walked as a set of positions the query can have been read up to rather than
|
|
100
|
-
* one cursor, because a syllable can be written more than one way and the ways
|
|
101
|
-
* are different lengths: `wanr2` is `wan` or `wanr`, and only what follows says
|
|
102
|
-
* which was meant.
|
|
103
|
-
*/
|
|
104
|
-
function spells(query, reading, writings) {
|
|
105
|
-
let reached = new Set([0]);
|
|
106
|
-
for (const token of reading.split(" ")) {
|
|
107
|
-
let forms = writings.get(token);
|
|
108
|
-
if (forms === undefined) {
|
|
109
|
-
forms = writingsOf(token);
|
|
110
|
-
writings.set(token, forms);
|
|
111
|
-
}
|
|
112
|
-
const next = new Set();
|
|
113
|
-
for (const at of reached) {
|
|
114
|
-
for (const form of forms) {
|
|
115
|
-
if (query.startsWith(form, at)) {
|
|
116
|
-
next.add(at + form.length);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (next.size === 0) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
reached = next;
|
|
124
|
-
}
|
|
125
|
-
return reached.has(query.length);
|
|
126
|
-
}
|
|
127
8
|
/**
|
|
128
9
|
* The reading the dictionary itself reports for a word, in numbered spelling.
|
|
129
10
|
*
|
|
@@ -156,37 +37,6 @@ function rankedPositions(index, key) {
|
|
|
156
37
|
// are short: the busiest reading in the full dictionary has 805 words in it.
|
|
157
38
|
return found.toSorted((left, right) => index.dictionary.frequencyAt(right) - index.dictionary.frequencyAt(left));
|
|
158
39
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Keep one writing of a word where the group holds both scripts.
|
|
161
|
-
*
|
|
162
|
-
* Paired by 简体 form in both directions rather than by converting toward the
|
|
163
|
-
* preference, because simplification is many-to-one and so the 简体 form is the
|
|
164
|
-
* one both writings agree on. Going the other way needs a reading to tell 發
|
|
165
|
-
* from 髮, and a pair that failed to meet would simply be left as two.
|
|
166
|
-
*
|
|
167
|
-
* The kept writing takes the rank of the better-placed of the two, so
|
|
168
|
-
* collapsing a list never reorders what is left of it.
|
|
169
|
-
*/
|
|
170
|
-
function preferScript(words, script) {
|
|
171
|
-
/** Whether a candidate is the writing the caller asked for. */
|
|
172
|
-
const isWanted = (word, simplified) => script.prefer === "Hans" ? word === simplified : word !== simplified;
|
|
173
|
-
const chosen = new Map();
|
|
174
|
-
const order = [];
|
|
175
|
-
for (const word of words) {
|
|
176
|
-
const simplified = convertCharacters(script.tables.toSimplified, word);
|
|
177
|
-
const held = chosen.get(simplified);
|
|
178
|
-
if (held === undefined) {
|
|
179
|
-
chosen.set(simplified, word);
|
|
180
|
-
order.push(simplified);
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
if (!isWanted(held, simplified) && isWanted(word, simplified)) {
|
|
184
|
-
chosen.set(simplified, word);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/* c8 ignore next -- every entry in `order` was put in `chosen` beside it */
|
|
188
|
-
return order.map((simplified) => chosen.get(simplified) ?? simplified);
|
|
189
|
-
}
|
|
190
40
|
/**
|
|
191
41
|
* The words a pinyin query could be spelling, likeliest first.
|
|
192
42
|
*
|
|
@@ -208,7 +58,8 @@ function preferScript(words, script) {
|
|
|
208
58
|
* spaces between syllables, and the r of 儿化.
|
|
209
59
|
*
|
|
210
60
|
* Both scripts are dictionary keys, so 银行 and 銀行 both come back unless a
|
|
211
|
-
* {@link ScriptPreference} says which to
|
|
61
|
+
* {@link import("./candidate-narrowing.js").ScriptPreference} says which to
|
|
62
|
+
* keep.
|
|
212
63
|
*/
|
|
213
64
|
export function candidates(index, query, options = {}) {
|
|
214
65
|
const { key, written } = readQuery(query);
|
|
@@ -232,10 +83,7 @@ export function candidates(index, query, options = {}) {
|
|
|
232
83
|
found.push(word);
|
|
233
84
|
}
|
|
234
85
|
}
|
|
235
|
-
|
|
236
|
-
return options.limit === undefined
|
|
237
|
-
? preferred
|
|
238
|
-
: preferred.slice(0, Math.max(0, options.limit));
|
|
86
|
+
return narrowCandidates(found, options);
|
|
239
87
|
}
|
|
240
88
|
/**
|
|
241
89
|
* The other words read exactly as this one is, likeliest first.
|
|
@@ -250,8 +98,9 @@ export function candidates(index, query, options = {}) {
|
|
|
250
98
|
* dictionary — 4,659 candidates — that narrowing costs 1.2 ms in total.
|
|
251
99
|
*
|
|
252
100
|
* The word itself is never in its own list. Neither is its other-script writing
|
|
253
|
-
* where a {@link ScriptPreference} is given,
|
|
254
|
-
* 银行 but the same word spelled for a
|
|
101
|
+
* where a {@link import("./candidate-narrowing.js").ScriptPreference} is given,
|
|
102
|
+
* since 銀行 is not a homophone of 银行 but the same word spelled for a
|
|
103
|
+
* different reader.
|
|
255
104
|
*
|
|
256
105
|
* Returns nothing for a word the dictionary does not hold, since a word with no
|
|
257
106
|
* reading has no homophones rather than all of them.
|
|
@@ -282,9 +131,6 @@ export function homophonesOf(index, word, options = {}) {
|
|
|
282
131
|
found.push(candidate);
|
|
283
132
|
}
|
|
284
133
|
}
|
|
285
|
-
|
|
286
|
-
return options.limit === undefined
|
|
287
|
-
? preferred
|
|
288
|
-
: preferred.slice(0, Math.max(0, options.limit));
|
|
134
|
+
return narrowCandidates(found, options);
|
|
289
135
|
}
|
|
290
136
|
//# sourceMappingURL=candidates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.js","sourceRoot":"","sources":["../../src/search/candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"candidates.js","sourceRoot":"","sources":["../../src/search/candidates.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of a query one whole reading can account for.
|
|
3
|
+
*
|
|
4
|
+
* The smallest step the search takes, and the only part of it that looks at the
|
|
5
|
+
* query's letters rather than at the haystack's characters. Kept apart from the
|
|
6
|
+
* walk because it is a pure question about two strings — no dictionary, no
|
|
7
|
+
* memo, no score — which is what makes the walk above it readable as a walk.
|
|
8
|
+
*/
|
|
9
|
+
import type { Syllable } from "../syllable/syllable.js";
|
|
10
|
+
import { type QueryChunk } from "./query.js";
|
|
11
|
+
/**
|
|
12
|
+
* Every position the query can be read up to by one whole reading.
|
|
13
|
+
*
|
|
14
|
+
* A reading is usually one syllable, and is not always: 瓩 is `qiānwǎ`, one
|
|
15
|
+
* character read as two. The query accounts for them in order, and may run
|
|
16
|
+
* out partway through, which is a query still being typed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function chunksFor(query: string, from: number, reading: readonly Syllable[]): readonly QueryChunk[];
|
|
19
|
+
//# sourceMappingURL=match-chunks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-chunks.d.ts","sourceRoot":"","sources":["../../src/search/match-chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,KAAK,UAAU,EAAmC,MAAM,YAAY,CAAC;AAE9E;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,QAAQ,EAAE,GAC3B,SAAS,UAAU,EAAE,CAoBvB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readQueryChunks, skipSeparators } from "./query.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every position the query can be read up to by one whole reading.
|
|
4
|
+
*
|
|
5
|
+
* A reading is usually one syllable, and is not always: 瓩 is `qiānwǎ`, one
|
|
6
|
+
* character read as two. The query accounts for them in order, and may run
|
|
7
|
+
* out partway through, which is a query still being typed.
|
|
8
|
+
*/
|
|
9
|
+
export function chunksFor(query, from, reading) {
|
|
10
|
+
let reached = [{ next: from, isFull: true }];
|
|
11
|
+
for (const syllable of reading) {
|
|
12
|
+
const found = [];
|
|
13
|
+
for (const chunk of reached) {
|
|
14
|
+
const start = skipSeparators(query, chunk.next);
|
|
15
|
+
if (start === query.length) {
|
|
16
|
+
found.push({ next: start, isFull: chunk.isFull });
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
for (const one of readQueryChunks(query, start, syllable)) {
|
|
20
|
+
found.push({
|
|
21
|
+
next: one.next,
|
|
22
|
+
isFull: chunk.isFull && one.isFull,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
reached = found;
|
|
27
|
+
}
|
|
28
|
+
return reached;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=match-chunks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-chunks.js","sourceRoot":"","sources":["../../src/search/match-chunks.ts"],"names":[],"mappings":"AASA,OAAO,EAAmB,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,KAAa,EACb,IAAY,EACZ,OAA4B;IAE5B,IAAI,OAAO,GAA0B,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC3B,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;gBAClD,SAAS;YACX,CAAC;YACD,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;gBAC1D,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM;iBACnC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,GAAG,KAAK,CAAC;IAClB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Choosing between the places a query matched.
|
|
3
|
+
*
|
|
4
|
+
* The walk in `match-search.ts` answers *where* and *how* the query reads; this
|
|
5
|
+
* answers *which of those is the match*. The two are separate because they weigh
|
|
6
|
+
* different things: the walk scores a reading against the query as it goes, and
|
|
7
|
+
* this scores a finished path against the haystack it lies in — how the text is
|
|
8
|
+
* actually read, whether the match starts a word, how early it falls.
|
|
9
|
+
*/
|
|
10
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
11
|
+
import { type MatchRange, type Path } from "./match-scoring.js";
|
|
12
|
+
/**
|
|
13
|
+
* What a query matched, and how well.
|
|
14
|
+
*/
|
|
15
|
+
export interface PinyinMatch {
|
|
16
|
+
/**
|
|
17
|
+
* The stretches of the haystack the query spelled, in order.
|
|
18
|
+
*
|
|
19
|
+
* Usually one. There is more than one where the query ran over something
|
|
20
|
+
* with no reading of its own: 北京·大学 is matched by `bjdx` as two ranges
|
|
21
|
+
* with the separator between them left out, so that highlighting them marks
|
|
22
|
+
* what was matched rather than what lay between.
|
|
23
|
+
*/
|
|
24
|
+
readonly ranges: readonly MatchRange[];
|
|
25
|
+
/**
|
|
26
|
+
* How good the match is, where higher is better.
|
|
27
|
+
*
|
|
28
|
+
* For ordering the haystacks one query matched — sort descending and the
|
|
29
|
+
* best is first. Comparable within a query and not across queries: what it
|
|
30
|
+
* weighs is described at {@link CONTEXT_READING}, and none of it is a
|
|
31
|
+
* probability.
|
|
32
|
+
*/
|
|
33
|
+
readonly score: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The best of the paths a query read, or undefined where it read none.
|
|
37
|
+
*/
|
|
38
|
+
export declare function bestMatch(dictionary: Dictionary, haystack: string, query: string, found: readonly Path[]): PinyinMatch | undefined;
|
|
39
|
+
//# sourceMappingURL=match-ranking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-ranking.d.ts","sourceRoot":"","sources":["../../src/search/match-ranking.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,IAAI,EAIV,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAgCD;;GAEG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,IAAI,EAAE,GACrB,WAAW,GAAG,SAAS,CAoBzB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { readQueryChunks } from "./query.js";
|
|
2
|
+
import { CONTEXT_READING, contextOf, EARLINESS, rangesOf, WORD_START, } from "./match-scoring.js";
|
|
3
|
+
/**
|
|
4
|
+
* How much of a match was written the way the text is actually read.
|
|
5
|
+
*
|
|
6
|
+
* Asked of what the query wrote rather than of the reading the search happened
|
|
7
|
+
* to take it by: 西 is stored with a neutral-toned `xi` and a first-tone `xī`,
|
|
8
|
+
* and a query writing `xi` has picked neither of them over the other. What it
|
|
9
|
+
* has done is write something the settled reading can account for, which is the
|
|
10
|
+
* question — and the one `yx` over 银行 answers differently from `yh`.
|
|
11
|
+
*/
|
|
12
|
+
function agreementOf(query, steps, preferred) {
|
|
13
|
+
let comparable = 0;
|
|
14
|
+
let agreeing = 0;
|
|
15
|
+
for (const step of steps) {
|
|
16
|
+
const settled = preferred[step.at];
|
|
17
|
+
if (!step.isRead || settled === undefined) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
comparable++;
|
|
21
|
+
const written = readQueryChunks(query, step.from, settled);
|
|
22
|
+
if (written.some((chunk) => chunk.next === step.next)) {
|
|
23
|
+
agreeing++;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return comparable === 0 ? 0 : agreeing / comparable;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The best of the paths a query read, or undefined where it read none.
|
|
30
|
+
*/
|
|
31
|
+
export function bestMatch(dictionary, haystack, query, found) {
|
|
32
|
+
const context = contextOf(dictionary, haystack);
|
|
33
|
+
let best;
|
|
34
|
+
for (const path of found) {
|
|
35
|
+
const ranges = rangesOf(path.steps);
|
|
36
|
+
/* c8 ignore next 3 -- a match always starts on a character it read */
|
|
37
|
+
if (ranges[0] === undefined) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const start = ranges[0].at;
|
|
41
|
+
const score = CONTEXT_READING * agreementOf(query, path.steps, context.preferred) +
|
|
42
|
+
(context.wordStarts.has(start) ? WORD_START : 0) +
|
|
43
|
+
EARLINESS / (1 + start);
|
|
44
|
+
// Strictly better, so that two matches worth the same keep the earlier.
|
|
45
|
+
if (best === undefined || score > best.score) {
|
|
46
|
+
best = { ranges, score };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return best;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=match-ranking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-ranking.js","sourceRoot":"","sources":["../../src/search/match-ranking.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,EAGT,QAAQ,EAER,UAAU,GACX,MAAM,oBAAoB,CAAC;AA0B5B;;;;;;;;GAQG;AACH,SAAS,WAAW,CAClB,KAAa,EACb,KAAsB,EACtB,SAA4C;IAE5C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1C,SAAS;QACX,CAAC;QACD,UAAU,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACtD,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IACD,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,UAAU,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,UAAsB,EACtB,QAAgB,EAChB,KAAa,EACb,KAAsB;IAEtB,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAChD,IAAI,IAA6B,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,sEAAsE;QACtE,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YAC5B,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GACT,eAAe,GAAG,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;YACnE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,SAAS,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QAC1B,wEAAwE;QACxE,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAC7C,IAAI,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a character in the haystack can be read as, asked once per position.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from the search itself because it is a different question: the
|
|
5
|
+
* search asks how a query walks over a text, and this asks only what each
|
|
6
|
+
* character offers it to walk on.
|
|
7
|
+
*/
|
|
8
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
9
|
+
import type { Syllable } from "../syllable/syllable.js";
|
|
10
|
+
import type { Candidate } from "./match-scoring.js";
|
|
11
|
+
export declare class CharacterReadings {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(dictionary: Dictionary, characters: readonly string[]);
|
|
14
|
+
/**
|
|
15
|
+
* Every reading a character offers, likeliest first, asked for once.
|
|
16
|
+
*
|
|
17
|
+
* Canonicalised here rather than left to the dictionary, so that a Hong Kong
|
|
18
|
+
* glyph form is matched by the readings of the Taiwan-standard key it folds
|
|
19
|
+
* to rather than by nothing.
|
|
20
|
+
*
|
|
21
|
+
* The 國語 reading goes on the end where it differs, so that 圾 answers to
|
|
22
|
+
* `se` as well as to `ji`. A search box is not the place to insist on one
|
|
23
|
+
* standard: somebody typing what they say is not typing it wrongly, and the
|
|
24
|
+
* decoder's own reading is what ranks the two afterwards.
|
|
25
|
+
*/
|
|
26
|
+
at(at: number): readonly (readonly Syllable[])[];
|
|
27
|
+
/**
|
|
28
|
+
* Every reading the query could be accounting for at a character.
|
|
29
|
+
*
|
|
30
|
+
* One per reading the character has — and one more for each of them where an
|
|
31
|
+
* 儿 follows, carrying the r suffix that character stands for. 玩儿 is
|
|
32
|
+
* `wánr`, one syllable over two characters, and somebody looking for it types
|
|
33
|
+
* `wanr`: the r is part of how the word is said, so it is part of how the
|
|
34
|
+
* word is searched for.
|
|
35
|
+
*
|
|
36
|
+
* Offered wherever an 儿 follows rather than only where the dictionary
|
|
37
|
+
* attests the 儿化, because the query is what decides which of them was
|
|
38
|
+
* meant. 女儿 is `nǚ'ér` and not `nǚr`, and typing `nvr` still finds it —
|
|
39
|
+
* below `nver`, since the reading the text takes is what ranks them.
|
|
40
|
+
*/
|
|
41
|
+
candidatesAt(at: number): readonly Candidate[];
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=match-readings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-readings.d.ts","sourceRoot":"","sources":["../../src/search/match-readings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,qBAAa,iBAAiB;;IAK5B,YAAY,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAGhE;IAED;;;;;;;;;;;OAWG;IACH,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,QAAQ,EAAE,CAAC,EAAE,CAgB/C;IAED;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CA2B7C;CACF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isSameReading } from "../dictionary/entry.js";
|
|
2
|
+
import { isErCharacter, withErhua } from "../dictionary/erhua.js";
|
|
3
|
+
import { toCanonicalGlyphs } from "../script/glyphs.js";
|
|
4
|
+
export class CharacterReadings {
|
|
5
|
+
#dictionary;
|
|
6
|
+
#characters;
|
|
7
|
+
#readings = [];
|
|
8
|
+
constructor(dictionary, characters) {
|
|
9
|
+
this.#dictionary = dictionary;
|
|
10
|
+
this.#characters = characters;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Every reading a character offers, likeliest first, asked for once.
|
|
14
|
+
*
|
|
15
|
+
* Canonicalised here rather than left to the dictionary, so that a Hong Kong
|
|
16
|
+
* glyph form is matched by the readings of the Taiwan-standard key it folds
|
|
17
|
+
* to rather than by nothing.
|
|
18
|
+
*
|
|
19
|
+
* The 國語 reading goes on the end where it differs, so that 圾 answers to
|
|
20
|
+
* `se` as well as to `ji`. A search box is not the place to insist on one
|
|
21
|
+
* standard: somebody typing what they say is not typing it wrongly, and the
|
|
22
|
+
* decoder's own reading is what ranks the two afterwards.
|
|
23
|
+
*/
|
|
24
|
+
at(at) {
|
|
25
|
+
const held = this.#readings[at];
|
|
26
|
+
if (held !== undefined) {
|
|
27
|
+
return held;
|
|
28
|
+
}
|
|
29
|
+
/* c8 ignore next -- only ever asked about a character that is there */
|
|
30
|
+
const character = toCanonicalGlyphs(this.#characters[at] ?? "");
|
|
31
|
+
const found = this.#dictionary.readingsOf(character);
|
|
32
|
+
const taiwan = this.#dictionary.lookup(character)?.taiwanReading;
|
|
33
|
+
const readings = taiwan === undefined ||
|
|
34
|
+
found.some((reading) => isSameReading(reading, taiwan))
|
|
35
|
+
? found
|
|
36
|
+
: [...found, taiwan];
|
|
37
|
+
this.#readings[at] = readings;
|
|
38
|
+
return readings;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every reading the query could be accounting for at a character.
|
|
42
|
+
*
|
|
43
|
+
* One per reading the character has — and one more for each of them where an
|
|
44
|
+
* 儿 follows, carrying the r suffix that character stands for. 玩儿 is
|
|
45
|
+
* `wánr`, one syllable over two characters, and somebody looking for it types
|
|
46
|
+
* `wanr`: the r is part of how the word is said, so it is part of how the
|
|
47
|
+
* word is searched for.
|
|
48
|
+
*
|
|
49
|
+
* Offered wherever an 儿 follows rather than only where the dictionary
|
|
50
|
+
* attests the 儿化, because the query is what decides which of them was
|
|
51
|
+
* meant. 女儿 is `nǚ'ér` and not `nǚr`, and typing `nvr` still finds it —
|
|
52
|
+
* below `nver`, since the reading the text takes is what ranks them.
|
|
53
|
+
*/
|
|
54
|
+
candidatesAt(at) {
|
|
55
|
+
const readings = this.at(at);
|
|
56
|
+
const plain = readings.map((reading, rank) => ({
|
|
57
|
+
reading,
|
|
58
|
+
rank,
|
|
59
|
+
characters: 1,
|
|
60
|
+
}));
|
|
61
|
+
if (!isErCharacter(this.#characters[at + 1] ?? "")) {
|
|
62
|
+
return plain;
|
|
63
|
+
}
|
|
64
|
+
return [
|
|
65
|
+
...plain,
|
|
66
|
+
...readings.flatMap((reading, rank) => {
|
|
67
|
+
const last = reading.at(-1);
|
|
68
|
+
/* c8 ignore next 3 -- a stored reading is never empty or already r-ed */
|
|
69
|
+
if (last === undefined || last.erhua === true) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
reading: [...reading.slice(0, -1), withErhua(last)],
|
|
75
|
+
rank,
|
|
76
|
+
characters: 2,
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
}),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=match-readings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-readings.js","sourceRoot":"","sources":["../../src/search/match-readings.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,MAAM,OAAO,iBAAiB;IACnB,WAAW,CAAa;IACxB,WAAW,CAAoB;IAC/B,SAAS,GAAyC,EAAE,CAAC;IAE9D,YAAY,UAAsB,EAAE,UAA6B;QAC/D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,EAAE,CAAC,EAAU;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,uEAAuE;QACvE,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;QACjE,MAAM,QAAQ,GACZ,MAAM,KAAK,SAAS;YACpB,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACrD,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAU;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7C,OAAO;YACP,IAAI;YACJ,UAAU,EAAE,CAAC;SACd,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO;YACL,GAAG,KAAK;YACR,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5B,yEAAyE;gBACzE,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;oBAC9C,OAAO,EAAE,CAAC;gBACZ,CAAC;gBACD,OAAO;oBACL;wBACE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;wBACnD,IAAI;wBACJ,UAAU,EAAE,CAAC;qBACd;iBACF,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
|