@kensio/pinyinjs 1.7.4 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accuracy/score-case.d.ts +23 -0
- package/dist/accuracy/score-case.d.ts.map +1 -0
- package/dist/accuracy/score-case.js +63 -0
- package/dist/accuracy/score-case.js.map +1 -0
- package/dist/accuracy/score.d.ts +1 -8
- package/dist/accuracy/score.d.ts.map +1 -1
- package/dist/accuracy/score.js +1 -55
- package/dist/accuracy/score.js.map +1 -1
- package/dist/cli/arguments.d.ts +4 -290
- package/dist/cli/arguments.d.ts.map +1 -1
- package/dist/cli/arguments.js +5 -357
- package/dist/cli/arguments.js.map +1 -1
- package/dist/cli/check-command.d.ts +9 -0
- package/dist/cli/check-command.d.ts.map +1 -0
- package/dist/cli/check-command.js +95 -0
- package/dist/cli/check-command.js.map +1 -0
- package/dist/cli/cli-input.d.ts +49 -0
- package/dist/cli/cli-input.d.ts.map +1 -0
- package/dist/cli/cli-input.js +31 -0
- package/dist/cli/cli-input.js.map +1 -0
- package/dist/cli/command.d.ts +97 -0
- package/dist/cli/command.d.ts.map +1 -0
- package/dist/cli/command.js +40 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/commands.d.ts +7 -110
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +14 -991
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/convert-command.d.ts +6 -0
- package/dist/cli/convert-command.d.ts.map +1 -0
- package/dist/cli/convert-command.js +52 -0
- package/dist/cli/convert-command.js.map +1 -0
- package/dist/cli/environment.d.ts +1 -1
- package/dist/cli/environment.d.ts.map +1 -1
- package/dist/cli/explain-command.d.ts +6 -0
- package/dist/cli/explain-command.d.ts.map +1 -0
- package/dist/cli/explain-command.js +40 -0
- package/dist/cli/explain-command.js.map +1 -0
- package/dist/cli/explain-syllable.d.ts +10 -0
- package/dist/cli/explain-syllable.d.ts.map +1 -0
- package/dist/cli/explain-syllable.js +70 -0
- package/dist/cli/explain-syllable.js.map +1 -0
- package/dist/cli/flag-help.d.ts +18 -0
- package/dist/cli/flag-help.d.ts.map +1 -0
- package/dist/cli/flag-help.js +78 -0
- package/dist/cli/flag-help.js.map +1 -0
- package/dist/cli/flag-lists.d.ts +49 -0
- package/dist/cli/flag-lists.d.ts.map +1 -0
- package/dist/cli/flag-lists.js +58 -0
- package/dist/cli/flag-lists.js.map +1 -0
- package/dist/cli/flag-values.d.ts +44 -0
- package/dist/cli/flag-values.d.ts.map +1 -0
- package/dist/cli/flag-values.js +56 -0
- package/dist/cli/flag-values.js.map +1 -0
- package/dist/cli/flags.d.ts +193 -0
- package/dist/cli/flags.d.ts.map +1 -0
- package/dist/cli/flags.js +133 -0
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/format-options.d.ts +29 -0
- package/dist/cli/format-options.d.ts.map +1 -0
- package/dist/cli/format-options.js +72 -0
- package/dist/cli/format-options.js.map +1 -0
- package/dist/cli/global-help.d.ts +23 -0
- package/dist/cli/global-help.d.ts.map +1 -0
- package/dist/cli/global-help.js +40 -0
- package/dist/cli/global-help.js.map +1 -0
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +5 -99
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/html-commands.d.ts +13 -0
- package/dist/cli/html-commands.d.ts.map +1 -0
- package/dist/cli/html-commands.js +49 -0
- package/dist/cli/html-commands.js.map +1 -0
- package/dist/cli/info-command.d.ts +7 -0
- package/dist/cli/info-command.d.ts.map +1 -0
- package/dist/cli/info-command.js +39 -0
- package/dist/cli/info-command.js.map +1 -0
- package/dist/cli/lookup-commands.d.ts +10 -0
- package/dist/cli/lookup-commands.d.ts.map +1 -0
- package/dist/cli/lookup-commands.js +101 -0
- package/dist/cli/lookup-commands.js.map +1 -0
- package/dist/cli/match-command.d.ts +11 -0
- package/dist/cli/match-command.d.ts.map +1 -0
- package/dist/cli/match-command.js +76 -0
- package/dist/cli/match-command.js.map +1 -0
- package/dist/cli/number-command.d.ts +12 -0
- package/dist/cli/number-command.d.ts.map +1 -0
- package/dist/cli/number-command.js +89 -0
- package/dist/cli/number-command.js.map +1 -0
- package/dist/cli/options.d.ts +30 -0
- package/dist/cli/options.d.ts.map +1 -0
- package/dist/cli/options.js +54 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/cli/run-command.d.ts +24 -0
- package/dist/cli/run-command.d.ts.map +1 -0
- package/dist/cli/run-command.js +40 -0
- package/dist/cli/run-command.js.map +1 -0
- package/dist/cli/run.d.ts +4 -42
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +6 -61
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/script-command.d.ts +10 -0
- package/dist/cli/script-command.d.ts.map +1 -0
- package/dist/cli/script-command.js +58 -0
- package/dist/cli/script-command.js.map +1 -0
- package/dist/cli/segment-command.d.ts +11 -0
- package/dist/cli/segment-command.d.ts.map +1 -0
- package/dist/cli/segment-command.js +53 -0
- package/dist/cli/segment-command.js.map +1 -0
- package/dist/cli/slug-command.d.ts +10 -0
- package/dist/cli/slug-command.d.ts.map +1 -0
- package/dist/cli/slug-command.js +28 -0
- package/dist/cli/slug-command.js.map +1 -0
- package/dist/cli/syllable-command.d.ts +14 -0
- package/dist/cli/syllable-command.d.ts.map +1 -0
- package/dist/cli/syllable-command.js +82 -0
- package/dist/cli/syllable-command.js.map +1 -0
- package/dist/cli/system-table.d.ts +12 -0
- package/dist/cli/system-table.d.ts.map +1 -0
- package/dist/cli/system-table.js +48 -0
- package/dist/cli/system-table.js.map +1 -0
- package/dist/cli/systems.d.ts +57 -0
- package/dist/cli/systems.d.ts.map +1 -0
- package/dist/cli/systems.js +27 -0
- package/dist/cli/systems.js.map +1 -0
- package/dist/cli/transcribe-command.d.ts +18 -0
- package/dist/cli/transcribe-command.d.ts.map +1 -0
- package/dist/cli/transcribe-command.js +86 -0
- package/dist/cli/transcribe-command.js.map +1 -0
- package/dist/cli/transcribe-reading.d.ts +15 -0
- package/dist/cli/transcribe-reading.d.ts.map +1 -0
- package/dist/cli/transcribe-reading.js +90 -0
- package/dist/cli/transcribe-reading.js.map +1 -0
- package/dist/cli/transcribe-rows.d.ts +26 -0
- package/dist/cli/transcribe-rows.d.ts.map +1 -0
- package/dist/cli/transcribe-rows.js +30 -0
- package/dist/cli/transcribe-rows.js.map +1 -0
- package/dist/cli/usage-error.d.ts +9 -0
- package/dist/cli/usage-error.d.ts.map +1 -0
- package/dist/cli/usage-error.js +9 -0
- package/dist/cli/usage-error.js.map +1 -0
- package/dist/decode/alternatives.d.ts +16 -0
- package/dist/decode/alternatives.d.ts.map +1 -0
- package/dist/decode/alternatives.js +31 -0
- package/dist/decode/alternatives.js.map +1 -0
- package/dist/decode/confidence.d.ts.map +1 -1
- package/dist/decode/confidence.js +3 -118
- package/dist/decode/confidence.js.map +1 -1
- package/dist/decode/convert-options.d.ts +116 -0
- package/dist/decode/convert-options.d.ts.map +1 -0
- package/dist/decode/convert-options.js +2 -0
- package/dist/decode/convert-options.js.map +1 -0
- package/dist/decode/convert-pipeline.d.ts +18 -0
- package/dist/decode/convert-pipeline.d.ts.map +1 -0
- package/dist/decode/convert-pipeline.js +66 -0
- package/dist/decode/convert-pipeline.js.map +1 -0
- package/dist/decode/convert.d.ts +9 -118
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +5 -453
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/decode.d.ts +2 -15
- package/dist/decode/decode.d.ts.map +1 -1
- package/dist/decode/decode.js +2 -121
- package/dist/decode/decode.js.map +1 -1
- package/dist/decode/decoders.d.ts +32 -0
- package/dist/decode/decoders.d.ts.map +1 -0
- package/dist/decode/decoders.js +29 -0
- package/dist/decode/decoders.js.map +1 -0
- package/dist/decode/edge-context.d.ts +38 -0
- package/dist/decode/edge-context.d.ts.map +1 -0
- package/dist/decode/edge-context.js +57 -0
- package/dist/decode/edge-context.js.map +1 -0
- package/dist/decode/hint-lattice.d.ts +45 -0
- package/dist/decode/hint-lattice.d.ts.map +1 -0
- package/dist/decode/hint-lattice.js +140 -0
- package/dist/decode/hint-lattice.js.map +1 -0
- package/dist/decode/hints.d.ts +2 -45
- package/dist/decode/hints.d.ts.map +1 -1
- package/dist/decode/hints.js +1 -139
- package/dist/decode/hints.js.map +1 -1
- package/dist/decode/jiao-rule.d.ts +58 -0
- package/dist/decode/jiao-rule.d.ts.map +1 -0
- package/dist/decode/jiao-rule.js +76 -0
- package/dist/decode/jiao-rule.js.map +1 -0
- package/dist/decode/lattice-costs.d.ts +55 -0
- package/dist/decode/lattice-costs.d.ts.map +1 -0
- package/dist/decode/lattice-costs.js +90 -0
- package/dist/decode/lattice-costs.js.map +1 -0
- package/dist/decode/lattice-edges.d.ts +29 -0
- package/dist/decode/lattice-edges.d.ts.map +1 -0
- package/dist/decode/lattice-edges.js +78 -0
- package/dist/decode/lattice-edges.js.map +1 -0
- package/dist/decode/lattice-slice.d.ts +37 -0
- package/dist/decode/lattice-slice.d.ts.map +1 -0
- package/dist/decode/lattice-slice.js +43 -0
- package/dist/decode/lattice-slice.js.map +1 -0
- package/dist/decode/lattice-types.d.ts +82 -0
- package/dist/decode/lattice-types.d.ts.map +1 -0
- package/dist/decode/lattice-types.js +44 -0
- package/dist/decode/lattice-types.js.map +1 -0
- package/dist/decode/lattice.d.ts +2 -59
- package/dist/decode/lattice.d.ts.map +1 -1
- package/dist/decode/lattice.js +2 -118
- package/dist/decode/lattice.js.map +1 -1
- package/dist/decode/number-pieces.d.ts +62 -0
- package/dist/decode/number-pieces.d.ts.map +1 -0
- package/dist/decode/number-pieces.js +106 -0
- package/dist/decode/number-pieces.js.map +1 -0
- package/dist/decode/numbers.d.ts +53 -0
- package/dist/decode/numbers.d.ts.map +1 -0
- package/dist/decode/numbers.js +69 -0
- package/dist/decode/numbers.js.map +1 -0
- package/dist/decode/pieces.d.ts +78 -0
- package/dist/decode/pieces.d.ts.map +1 -0
- package/dist/decode/pieces.js +136 -0
- package/dist/decode/pieces.js.map +1 -0
- package/dist/decode/polyphone-rules.d.ts +31 -0
- package/dist/decode/polyphone-rules.d.ts.map +1 -0
- package/dist/decode/polyphone-rules.js +159 -0
- package/dist/decode/polyphone-rules.js.map +1 -0
- package/dist/decode/reading-rules.d.ts +2 -97
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +4 -365
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/rules.d.ts +1 -17
- package/dist/decode/rules.d.ts.map +1 -1
- package/dist/decode/rules.js +1 -43
- package/dist/decode/rules.js.map +1 -1
- package/dist/decode/run-lattice.d.ts +52 -0
- package/dist/decode/run-lattice.d.ts.map +1 -0
- package/dist/decode/run-lattice.js +91 -0
- package/dist/decode/run-lattice.js.map +1 -0
- package/dist/decode/sandhi-tones.d.ts +69 -0
- package/dist/decode/sandhi-tones.d.ts.map +1 -0
- package/dist/decode/sandhi-tones.js +88 -0
- package/dist/decode/sandhi-tones.js.map +1 -0
- package/dist/decode/sandhi.d.ts +1 -1
- package/dist/decode/sandhi.d.ts.map +1 -1
- package/dist/decode/sandhi.js +1 -81
- package/dist/decode/sandhi.js.map +1 -1
- package/dist/decode/script-types.d.ts +76 -0
- package/dist/decode/script-types.d.ts.map +1 -0
- package/dist/decode/script-types.js +35 -0
- package/dist/decode/script-types.js.map +1 -0
- package/dist/decode/script-words.d.ts +32 -0
- package/dist/decode/script-words.d.ts.map +1 -0
- package/dist/decode/script-words.js +77 -0
- package/dist/decode/script-words.js.map +1 -0
- package/dist/decode/script.d.ts +3 -73
- package/dist/decode/script.d.ts.map +1 -1
- package/dist/decode/script.js +3 -109
- package/dist/decode/script.js.map +1 -1
- package/dist/decode/tan-rule.d.ts +68 -0
- package/dist/decode/tan-rule.d.ts.map +1 -0
- package/dist/decode/tan-rule.js +131 -0
- package/dist/decode/tan-rule.js.map +1 -0
- package/dist/decode/write-run.d.ts +28 -0
- package/dist/decode/write-run.d.ts.map +1 -0
- package/dist/decode/write-run.js +77 -0
- package/dist/decode/write-run.js.map +1 -0
- package/dist/dictionary/artifact-claims.d.ts +25 -0
- package/dist/dictionary/artifact-claims.d.ts.map +1 -0
- package/dist/dictionary/artifact-claims.js +47 -0
- package/dist/dictionary/artifact-claims.js.map +1 -0
- package/dist/dictionary/artifact-format.d.ts +86 -0
- package/dist/dictionary/artifact-format.d.ts.map +1 -0
- package/dist/dictionary/artifact-format.js +91 -0
- package/dist/dictionary/artifact-format.js.map +1 -0
- package/dist/dictionary/artifact-read.d.ts +34 -0
- package/dist/dictionary/artifact-read.d.ts.map +1 -0
- package/dist/dictionary/artifact-read.js +114 -0
- package/dist/dictionary/artifact-read.js.map +1 -0
- package/dist/dictionary/artifact.d.ts +4 -63
- package/dist/dictionary/artifact.d.ts.map +1 -1
- package/dist/dictionary/artifact.js +12 -229
- package/dist/dictionary/artifact.js.map +1 -1
- package/dist/dictionary/assertions.d.ts +5 -57
- package/dist/dictionary/assertions.d.ts.map +1 -1
- package/dist/dictionary/assertions.js +4 -317
- package/dist/dictionary/assertions.js.map +1 -1
- package/dist/dictionary/build-assertions.d.ts +12 -0
- package/dist/dictionary/build-assertions.d.ts.map +1 -0
- package/dist/dictionary/build-assertions.js +13 -0
- package/dist/dictionary/build-assertions.js.map +1 -0
- package/dist/dictionary/built-dictionary.d.ts +46 -0
- package/dist/dictionary/built-dictionary.d.ts.map +1 -0
- package/dist/dictionary/built-dictionary.js +97 -0
- package/dist/dictionary/built-dictionary.js.map +1 -0
- package/dist/dictionary/cedict-senses.d.ts +80 -0
- package/dist/dictionary/cedict-senses.d.ts.map +1 -0
- package/dist/dictionary/cedict-senses.js +114 -0
- package/dist/dictionary/cedict-senses.js.map +1 -0
- package/dist/dictionary/character-defaults.d.ts +26 -0
- package/dist/dictionary/character-defaults.d.ts.map +1 -0
- package/dist/dictionary/character-defaults.js +67 -0
- package/dist/dictionary/character-defaults.js.map +1 -0
- package/dist/dictionary/character-readings.d.ts +10 -0
- package/dist/dictionary/character-readings.d.ts.map +1 -0
- package/dist/dictionary/character-readings.js +25 -0
- package/dist/dictionary/character-readings.js.map +1 -0
- package/dist/dictionary/dictionary-entry.d.ts +37 -0
- package/dist/dictionary/dictionary-entry.d.ts.map +1 -0
- package/dist/dictionary/dictionary-entry.js +41 -0
- package/dist/dictionary/dictionary-entry.js.map +1 -0
- package/dist/dictionary/dictionary-readings.d.ts +56 -0
- package/dist/dictionary/dictionary-readings.d.ts.map +1 -0
- package/dist/dictionary/dictionary-readings.js +93 -0
- package/dist/dictionary/dictionary-readings.js.map +1 -0
- package/dist/dictionary/dictionary.d.ts +6 -60
- package/dist/dictionary/dictionary.d.ts.map +1 -1
- package/dist/dictionary/dictionary.js +9 -169
- package/dist/dictionary/dictionary.js.map +1 -1
- package/dist/dictionary/entry-invariants.d.ts +3 -0
- package/dist/dictionary/entry-invariants.d.ts.map +1 -0
- package/dist/dictionary/entry-invariants.js +67 -0
- package/dist/dictionary/entry-invariants.js.map +1 -0
- package/dist/dictionary/entry-lines.d.ts +35 -0
- package/dist/dictionary/entry-lines.d.ts.map +1 -0
- package/dist/dictionary/entry-lines.js +70 -0
- package/dist/dictionary/entry-lines.js.map +1 -0
- package/dist/dictionary/erhua-repair.d.ts +26 -0
- package/dist/dictionary/erhua-repair.d.ts.map +1 -0
- package/dist/dictionary/erhua-repair.js +49 -0
- package/dist/dictionary/erhua-repair.js.map +1 -0
- package/dist/dictionary/frequency-tones.d.ts +74 -0
- package/dist/dictionary/frequency-tones.d.ts.map +1 -0
- package/dist/dictionary/frequency-tones.js +128 -0
- package/dist/dictionary/frequency-tones.js.map +1 -0
- package/dist/dictionary/inventory-invariants.d.ts +3 -0
- package/dist/dictionary/inventory-invariants.d.ts.map +1 -0
- package/dist/dictionary/inventory-invariants.js +54 -0
- package/dist/dictionary/inventory-invariants.js.map +1 -0
- package/dist/dictionary/locale-candidates.d.ts +40 -0
- package/dist/dictionary/locale-candidates.d.ts.map +1 -0
- package/dist/dictionary/locale-candidates.js +77 -0
- package/dist/dictionary/locale-candidates.js.map +1 -0
- package/dist/dictionary/locale-segments.d.ts +47 -0
- package/dist/dictionary/locale-segments.d.ts.map +1 -0
- package/dist/dictionary/locale-segments.js +141 -0
- package/dist/dictionary/locale-segments.js.map +1 -0
- package/dist/dictionary/locale.d.ts +1 -21
- package/dist/dictionary/locale.d.ts.map +1 -1
- package/dist/dictionary/locale.js +9 -198
- package/dist/dictionary/locale.js.map +1 -1
- package/dist/dictionary/merge-types.d.ts +121 -0
- package/dist/dictionary/merge-types.d.ts.map +1 -0
- package/dist/dictionary/merge-types.js +35 -0
- package/dist/dictionary/merge-types.js.map +1 -0
- package/dist/dictionary/merge-word.d.ts +7 -0
- package/dist/dictionary/merge-word.d.ts.map +1 -0
- package/dist/dictionary/merge-word.js +91 -0
- package/dist/dictionary/merge-word.js.map +1 -0
- package/dist/dictionary/merge.d.ts +5 -62
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +30 -713
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/proper-noun.d.ts +28 -0
- package/dist/dictionary/proper-noun.d.ts.map +1 -0
- package/dist/dictionary/proper-noun.js +43 -0
- package/dist/dictionary/proper-noun.js.map +1 -0
- package/dist/dictionary/reading-agreement.d.ts +71 -0
- package/dist/dictionary/reading-agreement.d.ts.map +1 -0
- package/dist/dictionary/reading-agreement.js +156 -0
- package/dist/dictionary/reading-agreement.js.map +1 -0
- package/dist/dictionary/script-conversion.d.ts +28 -0
- package/dist/dictionary/script-conversion.d.ts.map +1 -0
- package/dist/dictionary/script-conversion.js +58 -0
- package/dist/dictionary/script-conversion.js.map +1 -0
- package/dist/dictionary/script-pairings.d.ts +74 -0
- package/dist/dictionary/script-pairings.d.ts.map +1 -0
- package/dist/dictionary/script-pairings.js +120 -0
- package/dist/dictionary/script-pairings.js.map +1 -0
- package/dist/dictionary/script-tables.d.ts.map +1 -1
- package/dist/dictionary/script-tables.js +2 -165
- package/dist/dictionary/script-tables.js.map +1 -1
- package/dist/dictionary/taiwan-reading.d.ts +8 -0
- package/dist/dictionary/taiwan-reading.d.ts.map +1 -0
- package/dist/dictionary/taiwan-reading.js +38 -0
- package/dist/dictionary/taiwan-reading.js.map +1 -0
- package/dist/dictionary/tone-invariants.d.ts +3 -0
- package/dist/dictionary/tone-invariants.d.ts.map +1 -0
- package/dist/dictionary/tone-invariants.js +64 -0
- package/dist/dictionary/tone-invariants.js.map +1 -0
- package/dist/dictionary/traditional-form.d.ts +21 -0
- package/dist/dictionary/traditional-form.d.ts.map +1 -0
- package/dist/dictionary/traditional-form.js +59 -0
- package/dist/dictionary/traditional-form.js.map +1 -0
- package/dist/dictionary/traditional-ranking.d.ts +22 -0
- package/dist/dictionary/traditional-ranking.d.ts.map +1 -0
- package/dist/dictionary/traditional-ranking.js +74 -0
- package/dist/dictionary/traditional-ranking.js.map +1 -0
- package/dist/dictionary/traditional-table.d.ts +51 -0
- package/dist/dictionary/traditional-table.d.ts.map +1 -0
- package/dist/dictionary/traditional-table.js +98 -0
- package/dist/dictionary/traditional-table.js.map +1 -0
- package/dist/dictionary/traditional.d.ts +3 -56
- package/dist/dictionary/traditional.d.ts.map +1 -1
- package/dist/dictionary/traditional.js +3 -186
- package/dist/dictionary/traditional.js.map +1 -1
- package/dist/dictionary/variant-counts.d.ts +39 -0
- package/dist/dictionary/variant-counts.d.ts.map +1 -0
- package/dist/dictionary/variant-counts.js +38 -0
- package/dist/dictionary/variant-counts.js.map +1 -0
- package/dist/dictionary/word-reading.d.ts +26 -0
- package/dist/dictionary/word-reading.d.ts.map +1 -0
- package/dist/dictionary/word-reading.js +76 -0
- package/dist/dictionary/word-reading.js.map +1 -0
- package/dist/dictionary/word-readings.d.ts +15 -0
- package/dist/dictionary/word-readings.d.ts.map +1 -0
- package/dist/dictionary/word-readings.js +38 -0
- package/dist/dictionary/word-readings.js.map +1 -0
- package/dist/format/annotate.d.ts +90 -0
- package/dist/format/annotate.d.ts.map +1 -0
- package/dist/format/annotate.js +168 -0
- package/dist/format/annotate.js.map +1 -0
- package/dist/format/html.d.ts +15 -46
- package/dist/format/html.d.ts.map +1 -1
- package/dist/format/html.js +3 -162
- package/dist/format/html.js.map +1 -1
- package/dist/format/slug-hash.d.ts +51 -0
- package/dist/format/slug-hash.d.ts.map +1 -0
- package/dist/format/slug-hash.js +74 -0
- package/dist/format/slug-hash.js.map +1 -0
- package/dist/format/slug-options.d.ts +98 -0
- package/dist/format/slug-options.d.ts.map +1 -0
- package/dist/format/slug-options.js +2 -0
- package/dist/format/slug-options.js.map +1 -0
- package/dist/format/slug-words.d.ts +27 -0
- package/dist/format/slug-words.d.ts.map +1 -0
- package/dist/format/slug-words.js +0 -0
- package/dist/format/slug-words.js.map +1 -0
- package/dist/format/slug.d.ts +3 -128
- package/dist/format/slug.d.ts.map +1 -1
- package/dist/format/slug.js +0 -0
- package/dist/format/slug.js.map +1 -1
- package/dist/grade/check-readings.d.ts +41 -0
- package/dist/grade/check-readings.d.ts.map +1 -0
- package/dist/grade/check-readings.js +36 -0
- package/dist/grade/check-readings.js.map +1 -0
- package/dist/grade/check.d.ts +4 -4
- package/dist/grade/check.d.ts.map +1 -1
- package/dist/grade/check.js +5 -270
- package/dist/grade/check.js.map +1 -1
- package/dist/grade/pair-syllables.d.ts +48 -0
- package/dist/grade/pair-syllables.d.ts.map +1 -0
- package/dist/grade/pair-syllables.js +71 -0
- package/dist/grade/pair-syllables.js.map +1 -0
- package/dist/grade/reading-syllables.d.ts +62 -0
- package/dist/grade/reading-syllables.d.ts.map +1 -0
- package/dist/grade/reading-syllables.js +58 -0
- package/dist/grade/reading-syllables.js.map +1 -0
- package/dist/grade/reading-tolerance.d.ts +72 -0
- package/dist/grade/reading-tolerance.d.ts.map +1 -0
- package/dist/grade/reading-tolerance.js +107 -0
- package/dist/grade/reading-tolerance.js.map +1 -0
- package/dist/grade/typed-reading.d.ts +28 -0
- package/dist/grade/typed-reading.d.ts.map +1 -0
- package/dist/grade/typed-reading.js +36 -0
- package/dist/grade/typed-reading.js.map +1 -0
- package/dist/numerals/numeral-parse.d.ts +32 -0
- package/dist/numerals/numeral-parse.d.ts.map +1 -0
- package/dist/numerals/numeral-parse.js +44 -0
- package/dist/numerals/numeral-parse.js.map +1 -0
- package/dist/numerals/numeral-shapes.d.ts +89 -0
- package/dist/numerals/numeral-shapes.d.ts.map +1 -0
- package/dist/numerals/numeral-shapes.js +99 -0
- package/dist/numerals/numeral-shapes.js.map +1 -0
- package/dist/numerals/numerals.d.ts.map +1 -1
- package/dist/numerals/numerals.js +2 -36
- package/dist/numerals/numerals.js.map +1 -1
- package/dist/numerals/read-numeral.d.ts +76 -0
- package/dist/numerals/read-numeral.d.ts.map +1 -0
- package/dist/numerals/read-numeral.js +88 -0
- package/dist/numerals/read-numeral.js.map +1 -0
- package/dist/numerals/text.d.ts +3 -37
- package/dist/numerals/text.d.ts.map +1 -1
- package/dist/numerals/text.js +3 -254
- package/dist/numerals/text.js.map +1 -1
- package/dist/numerals/time.d.ts +34 -0
- package/dist/numerals/time.d.ts.map +1 -0
- package/dist/numerals/time.js +93 -0
- package/dist/numerals/time.js.map +1 -0
- package/dist/orthography/address-grouping.d.ts +34 -0
- package/dist/orthography/address-grouping.d.ts.map +1 -0
- package/dist/orthography/address-grouping.js +52 -0
- package/dist/orthography/address-grouping.js.map +1 -0
- package/dist/orthography/grouping.d.ts +3 -87
- package/dist/orthography/grouping.d.ts.map +1 -1
- package/dist/orthography/grouping.js +4 -270
- package/dist/orthography/grouping.js.map +1 -1
- package/dist/orthography/place-grouping.d.ts +39 -0
- package/dist/orthography/place-grouping.d.ts.map +1 -0
- package/dist/orthography/place-grouping.js +83 -0
- package/dist/orthography/place-grouping.js.map +1 -0
- package/dist/orthography/word-grouping.d.ts +48 -0
- package/dist/orthography/word-grouping.d.ts.map +1 -0
- package/dist/orthography/word-grouping.js +147 -0
- package/dist/orthography/word-grouping.js.map +1 -0
- package/dist/script/conversion-format.d.ts +22 -0
- package/dist/script/conversion-format.d.ts.map +1 -0
- package/dist/script/conversion-format.js +22 -0
- package/dist/script/conversion-format.js.map +1 -0
- package/dist/script/conversion-read.d.ts +9 -0
- package/dist/script/conversion-read.d.ts.map +1 -0
- package/dist/script/conversion-read.js +69 -0
- package/dist/script/conversion-read.js.map +1 -0
- package/dist/script/conversion-write.d.ts +14 -0
- package/dist/script/conversion-write.d.ts.map +1 -0
- package/dist/script/conversion-write.js +34 -0
- package/dist/script/conversion-write.js.map +1 -0
- package/dist/script/conversion.d.ts +10 -16
- package/dist/script/conversion.d.ts.map +1 -1
- package/dist/script/conversion.js +2 -115
- package/dist/script/conversion.js.map +1 -1
- package/dist/search/candidate-narrowing.d.ts +56 -0
- package/dist/search/candidate-narrowing.d.ts.map +1 -0
- package/dist/search/candidate-narrowing.js +55 -0
- package/dist/search/candidate-narrowing.js.map +1 -0
- package/dist/search/candidate-query.d.ts +25 -0
- package/dist/search/candidate-query.d.ts.map +1 -0
- package/dist/search/candidate-query.js +28 -0
- package/dist/search/candidate-query.js.map +1 -0
- package/dist/search/candidate-writings.d.ts +24 -0
- package/dist/search/candidate-writings.d.ts.map +1 -0
- package/dist/search/candidate-writings.js +114 -0
- package/dist/search/candidate-writings.js.map +1 -0
- package/dist/search/candidates.d.ts +7 -41
- package/dist/search/candidates.d.ts.map +1 -1
- package/dist/search/candidates.js +10 -164
- package/dist/search/candidates.js.map +1 -1
- package/dist/search/match-chunks.d.ts +19 -0
- package/dist/search/match-chunks.d.ts.map +1 -0
- package/dist/search/match-chunks.js +30 -0
- package/dist/search/match-chunks.js.map +1 -0
- package/dist/search/match-ranking.d.ts +39 -0
- package/dist/search/match-ranking.d.ts.map +1 -0
- package/dist/search/match-ranking.js +51 -0
- package/dist/search/match-ranking.js.map +1 -0
- package/dist/search/match-readings.d.ts +43 -0
- package/dist/search/match-readings.d.ts.map +1 -0
- package/dist/search/match-readings.js +83 -0
- package/dist/search/match-readings.js.map +1 -0
- package/dist/search/match-scoring.d.ts +146 -0
- package/dist/search/match-scoring.d.ts.map +1 -0
- package/dist/search/match-scoring.js +114 -0
- package/dist/search/match-scoring.js.map +1 -0
- package/dist/search/match-search.d.ts +28 -0
- package/dist/search/match-search.d.ts.map +1 -0
- package/dist/search/match-search.js +128 -0
- package/dist/search/match-search.js.map +1 -0
- package/dist/search/match.d.ts +5 -36
- package/dist/search/match.d.ts.map +1 -1
- package/dist/search/match.js +2 -379
- package/dist/search/match.js.map +1 -1
- package/dist/search/reverse-index-build.d.ts +30 -0
- package/dist/search/reverse-index-build.d.ts.map +1 -0
- package/dist/search/reverse-index-build.js +72 -0
- package/dist/search/reverse-index-build.js.map +1 -0
- package/dist/search/reverse-index-format.d.ts +60 -0
- package/dist/search/reverse-index-format.d.ts.map +1 -0
- package/dist/search/reverse-index-format.js +54 -0
- package/dist/search/reverse-index-format.js.map +1 -0
- package/dist/search/reverse-index-groups.d.ts +37 -0
- package/dist/search/reverse-index-groups.d.ts.map +1 -0
- package/dist/search/reverse-index-groups.js +71 -0
- package/dist/search/reverse-index-groups.js.map +1 -0
- package/dist/search/reverse-index-passes.d.ts +78 -0
- package/dist/search/reverse-index-passes.d.ts.map +1 -0
- package/dist/search/reverse-index-passes.js +59 -0
- package/dist/search/reverse-index-passes.js.map +1 -0
- package/dist/search/reverse-index-state.d.ts +36 -0
- package/dist/search/reverse-index-state.d.ts.map +1 -0
- package/dist/search/reverse-index-state.js +95 -0
- package/dist/search/reverse-index-state.js.map +1 -0
- package/dist/search/reverse-index.d.ts +8 -67
- package/dist/search/reverse-index.d.ts.map +1 -1
- package/dist/search/reverse-index.js +4 -255
- package/dist/search/reverse-index.js.map +1 -1
- package/dist/sources/unihan-readings.d.ts +58 -0
- package/dist/sources/unihan-readings.d.ts.map +1 -0
- package/dist/sources/unihan-readings.js +95 -0
- package/dist/sources/unihan-readings.js.map +1 -0
- package/dist/sources/unihan.d.ts +6 -9
- package/dist/sources/unihan.d.ts.map +1 -1
- package/dist/sources/unihan.js +2 -85
- package/dist/sources/unihan.js.map +1 -1
- package/dist/syllable/final-tables.d.ts +23 -0
- package/dist/syllable/final-tables.d.ts.map +1 -0
- package/dist/syllable/final-tables.js +50 -0
- package/dist/syllable/final-tables.js.map +1 -0
- package/dist/syllable/inventory.d.ts +8 -42
- package/dist/syllable/inventory.d.ts.map +1 -1
- package/dist/syllable/inventory.js +9 -918
- package/dist/syllable/inventory.js.map +1 -1
- package/dist/syllable/spellings.d.ts +40 -0
- package/dist/syllable/spellings.d.ts.map +1 -0
- package/dist/syllable/spellings.js +469 -0
- package/dist/syllable/spellings.js.map +1 -0
- package/dist/syllable/syllable-parts.d.ts +31 -0
- package/dist/syllable/syllable-parts.d.ts.map +1 -0
- package/dist/syllable/syllable-parts.js +105 -0
- package/dist/syllable/syllable-parts.js.map +1 -0
- package/dist/syllable/syllable.d.ts +1 -14
- package/dist/syllable/syllable.d.ts.map +1 -1
- package/dist/syllable/syllable.js +3 -144
- package/dist/syllable/syllable.js.map +1 -1
- package/dist/syllable/written-tones.d.ts +6 -0
- package/dist/syllable/written-tones.d.ts.map +1 -0
- package/dist/syllable/written-tones.js +453 -0
- package/dist/syllable/written-tones.js.map +1 -0
- package/dist/transcription/bopomofo-parse.d.ts +42 -0
- package/dist/transcription/bopomofo-parse.d.ts.map +1 -0
- package/dist/transcription/bopomofo-parse.js +92 -0
- package/dist/transcription/bopomofo-parse.js.map +1 -0
- package/dist/transcription/bopomofo-reverse.d.ts +31 -0
- package/dist/transcription/bopomofo-reverse.d.ts.map +1 -0
- package/dist/transcription/bopomofo-reverse.js +48 -0
- package/dist/transcription/bopomofo-reverse.js.map +1 -0
- package/dist/transcription/bopomofo-symbols.d.ts +36 -0
- package/dist/transcription/bopomofo-symbols.d.ts.map +1 -0
- package/dist/transcription/bopomofo-symbols.js +41 -0
- package/dist/transcription/bopomofo-symbols.js.map +1 -0
- package/dist/transcription/bopomofo-tables.d.ts +87 -0
- package/dist/transcription/bopomofo-tables.d.ts.map +1 -0
- package/dist/transcription/bopomofo-tables.js +180 -0
- package/dist/transcription/bopomofo-tables.js.map +1 -0
- package/dist/transcription/bopomofo.d.ts +14 -32
- package/dist/transcription/bopomofo.d.ts.map +1 -1
- package/dist/transcription/bopomofo.js +5 -343
- package/dist/transcription/bopomofo.js.map +1 -1
- package/dist/transcription/gwoyeu-first-second.d.ts +36 -0
- package/dist/transcription/gwoyeu-first-second.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-first-second.js +75 -0
- package/dist/transcription/gwoyeu-first-second.js.map +1 -0
- package/dist/transcription/gwoyeu-spelling.d.ts +38 -0
- package/dist/transcription/gwoyeu-spelling.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-spelling.js +124 -0
- package/dist/transcription/gwoyeu-spelling.js.map +1 -0
- package/dist/transcription/gwoyeu-tables.d.ts +93 -0
- package/dist/transcription/gwoyeu-tables.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-tables.js +205 -0
- package/dist/transcription/gwoyeu-tables.js.map +1 -0
- package/dist/transcription/gwoyeu-tonal-forms.d.ts +49 -0
- package/dist/transcription/gwoyeu-tonal-forms.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-tonal-forms.js +89 -0
- package/dist/transcription/gwoyeu-tonal-forms.js.map +1 -0
- package/dist/transcription/gwoyeu-vowels.d.ts +51 -0
- package/dist/transcription/gwoyeu-vowels.d.ts.map +1 -0
- package/dist/transcription/gwoyeu-vowels.js +58 -0
- package/dist/transcription/gwoyeu-vowels.js.map +1 -0
- package/dist/transcription/gwoyeu.d.ts +1 -26
- package/dist/transcription/gwoyeu.d.ts.map +1 -1
- package/dist/transcription/gwoyeu.js +2 -540
- package/dist/transcription/gwoyeu.js.map +1 -1
- package/dist/transcription/ipa-symbols.d.ts +67 -0
- package/dist/transcription/ipa-symbols.d.ts.map +1 -0
- package/dist/transcription/ipa-symbols.js +135 -0
- package/dist/transcription/ipa-symbols.js.map +1 -0
- package/dist/transcription/ipa.d.ts +2 -10
- package/dist/transcription/ipa.d.ts.map +1 -1
- package/dist/transcription/ipa.js +2 -134
- package/dist/transcription/ipa.js.map +1 -1
- package/dist/transcription/wade-giles-index.d.ts +35 -0
- package/dist/transcription/wade-giles-index.d.ts.map +1 -0
- package/dist/transcription/wade-giles-index.js +110 -0
- package/dist/transcription/wade-giles-index.js.map +1 -0
- package/dist/transcription/wade-giles-parse.d.ts +36 -0
- package/dist/transcription/wade-giles-parse.d.ts.map +1 -0
- package/dist/transcription/wade-giles-parse.js +84 -0
- package/dist/transcription/wade-giles-parse.js.map +1 -0
- package/dist/transcription/wade-giles-spelling.d.ts +61 -0
- package/dist/transcription/wade-giles-spelling.d.ts.map +1 -0
- package/dist/transcription/wade-giles-spelling.js +107 -0
- package/dist/transcription/wade-giles-spelling.js.map +1 -0
- package/dist/transcription/wade-giles-syllable.d.ts +29 -0
- package/dist/transcription/wade-giles-syllable.d.ts.map +1 -0
- package/dist/transcription/wade-giles-syllable.js +90 -0
- package/dist/transcription/wade-giles-syllable.js.map +1 -0
- package/dist/transcription/wade-giles-tables.d.ts +80 -0
- package/dist/transcription/wade-giles-tables.d.ts.map +1 -0
- package/dist/transcription/wade-giles-tables.js +178 -0
- package/dist/transcription/wade-giles-tables.js.map +1 -0
- package/dist/transcription/wade-giles.d.ts +9 -60
- package/dist/transcription/wade-giles.d.ts.map +1 -1
- package/dist/transcription/wade-giles.js +6 -543
- package/dist/transcription/wade-giles.js.map +1 -1
- package/dist/transcription/yale-tables.d.ts +54 -0
- package/dist/transcription/yale-tables.d.ts.map +1 -0
- package/dist/transcription/yale-tables.js +125 -0
- package/dist/transcription/yale-tables.js.map +1 -0
- package/dist/transcription/yale.d.ts.map +1 -1
- package/dist/transcription/yale.js +1 -124
- package/dist/transcription/yale.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What ranking a match costs, and what a match is made of.
|
|
3
|
+
*
|
|
4
|
+
* The weights, the shape of a partial match, and the one decode the ranking
|
|
5
|
+
* leans on. `match.ts` searches; this says how the searching is scored.
|
|
6
|
+
*/
|
|
7
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
8
|
+
import type { Syllable } from "../syllable/syllable.js";
|
|
9
|
+
/**
|
|
10
|
+
* A stretch of the haystack the query spelled out.
|
|
11
|
+
*/
|
|
12
|
+
export interface MatchRange {
|
|
13
|
+
/**
|
|
14
|
+
* Where it starts, in code points from the start of the haystack.
|
|
15
|
+
*
|
|
16
|
+
* Code points rather than UTF-16 units, exactly as `Segment.at` is, so that a
|
|
17
|
+
* character outside the basic plane counts as the one character it is.
|
|
18
|
+
*/
|
|
19
|
+
readonly at: number;
|
|
20
|
+
/** How many characters it covers. */
|
|
21
|
+
readonly length: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* What a match scores for reading its characters the way the text reads them.
|
|
25
|
+
*
|
|
26
|
+
* The one thing this has that a reverse index cannot: every reading a character
|
|
27
|
+
* takes is matchable, so 行 is found by both `xing` and `hang` — and the decoder
|
|
28
|
+
* has already settled which of them the text in front of it means. So 银行 ranks
|
|
29
|
+
* `yh` above `yx`, and 长江 ranks `cj` above `zj`, without either being refused.
|
|
30
|
+
*
|
|
31
|
+
* Weighted by the share of the matched characters that agree, rather than by how
|
|
32
|
+
* many, so that a long match and a short one are scored on the same scale.
|
|
33
|
+
*/
|
|
34
|
+
export declare const CONTEXT_READING = 4;
|
|
35
|
+
/**
|
|
36
|
+
* What a match scores for starting where a word starts.
|
|
37
|
+
*
|
|
38
|
+
* 大学 in 北京大学 is the second half of a word a reader thinks of as one thing;
|
|
39
|
+
* 大学 in 大学生 starts it. Both are matches and the second is the better one.
|
|
40
|
+
*/
|
|
41
|
+
export declare const WORD_START = 2;
|
|
42
|
+
/**
|
|
43
|
+
* What a match at the very start of the haystack scores, decaying with position.
|
|
44
|
+
*
|
|
45
|
+
* A tie-break rather than a judgement, and deliberately smaller than
|
|
46
|
+
* {@link WORD_START}: it settles two matches that are otherwise alike, and never
|
|
47
|
+
* outranks starting a word.
|
|
48
|
+
*/
|
|
49
|
+
export declare const EARLINESS = 1;
|
|
50
|
+
/**
|
|
51
|
+
* What one character scores for being written out in full rather than initialled.
|
|
52
|
+
*
|
|
53
|
+
* Only used to choose between the ways one query can be read over one haystack,
|
|
54
|
+
* never in the score a caller sees: `beij` over 北京大学 is 北 spelled out and 京
|
|
55
|
+
* initialled, and no other reading of it is on offer. Where two are — `xian` is
|
|
56
|
+
* both 西安 and 县 — the fuller spelling is the one the typist meant.
|
|
57
|
+
*
|
|
58
|
+
* Per character, which is what settles 这儿 against `zher`: read as 这 `zhèr` it
|
|
59
|
+
* spells two characters out at once, where 这 abbreviated to `zh` and 儿 as `er`
|
|
60
|
+
* spells one of them and initials the other.
|
|
61
|
+
*/
|
|
62
|
+
export declare const SPELLED_OUT = 1;
|
|
63
|
+
/**
|
|
64
|
+
* What one step down a character's reading list costs, likeliest reading first.
|
|
65
|
+
*
|
|
66
|
+
* The dictionary's own order, applied before the decoder has been asked
|
|
67
|
+
* anything: it is what separates 行 `xíng` from 行 `hàng` when the query could
|
|
68
|
+
* be either and the surrounding text says nothing.
|
|
69
|
+
*/
|
|
70
|
+
export declare const RARE_READING = 2;
|
|
71
|
+
/**
|
|
72
|
+
* What crossing one character with no reading costs.
|
|
73
|
+
*
|
|
74
|
+
* A separator inside a name is worth stepping over — 北京·大学 is one thing
|
|
75
|
+
* with a mark in the middle of it — and a query that steps over half a line of
|
|
76
|
+
* Latin to reach its second half has found something more tenuous.
|
|
77
|
+
*/
|
|
78
|
+
export declare const CROSSED = 0.5;
|
|
79
|
+
/**
|
|
80
|
+
* One character on the way through a match.
|
|
81
|
+
*
|
|
82
|
+
* What the query wrote for it is held as the stretch of the query it took
|
|
83
|
+
* rather than as the reading it was taken by, because the question ranking asks
|
|
84
|
+
* later is whether the reading the text settles on could have taken that same
|
|
85
|
+
* stretch — and a character often offers two readings that would.
|
|
86
|
+
*/
|
|
87
|
+
export interface Step {
|
|
88
|
+
readonly at: number;
|
|
89
|
+
/** Whether the query spelled this character, rather than stepping over it. */
|
|
90
|
+
readonly isRead: boolean;
|
|
91
|
+
/** Where in the query this character's spelling starts. */
|
|
92
|
+
readonly from: number;
|
|
93
|
+
/** Where the query has been read up to once it is taken. */
|
|
94
|
+
readonly next: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* One way of reading a query over a stretch of the haystack.
|
|
98
|
+
*/
|
|
99
|
+
export interface Path {
|
|
100
|
+
readonly steps: readonly Step[];
|
|
101
|
+
/** What choosing this way of reading it is worth; see {@link SPELLED_OUT}. */
|
|
102
|
+
readonly score: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The query having been read to its end, with nothing left to account for.
|
|
106
|
+
*/
|
|
107
|
+
export declare const COMPLETE: Path;
|
|
108
|
+
/**
|
|
109
|
+
* One reading a character can be matched by, and how much it covers.
|
|
110
|
+
*/
|
|
111
|
+
export interface Candidate {
|
|
112
|
+
readonly reading: readonly Syllable[];
|
|
113
|
+
/** How far down the character's list of readings it is. */
|
|
114
|
+
readonly rank: number;
|
|
115
|
+
/** How many characters it reads: two only for 儿化. */
|
|
116
|
+
readonly characters: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* What the decoder made of the haystack, for ranking rather than for matching.
|
|
120
|
+
*/
|
|
121
|
+
export interface Context {
|
|
122
|
+
/**
|
|
123
|
+
* The reading the decoder settled on for each character.
|
|
124
|
+
*
|
|
125
|
+
* A syllable covering two characters is recorded against both of them, which
|
|
126
|
+
* is what 儿化 is: 玩儿 is `wánr`, and that one syllable is how the decoder
|
|
127
|
+
* read the 玩 and the 儿 alike. Undefined where the alignment does not work
|
|
128
|
+
* out at all.
|
|
129
|
+
*/
|
|
130
|
+
readonly preferred: readonly (Syllable | undefined)[];
|
|
131
|
+
/** Where each of the decoder's words starts, in code points. */
|
|
132
|
+
readonly wordStarts: ReadonlySet<number>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The steps of a match, gathered into the stretches they cover.
|
|
136
|
+
*/
|
|
137
|
+
export declare function rangesOf(steps: readonly Step[]): readonly MatchRange[];
|
|
138
|
+
/**
|
|
139
|
+
* Ask the decoder what the haystack says, for the two things ranking needs.
|
|
140
|
+
*
|
|
141
|
+
* Worked out once a match is known to exist rather than before, because this is
|
|
142
|
+
* a decode of the whole text and matching is not: a search box filtering a list
|
|
143
|
+
* asks the cheap question of every item and pays for this on the few that hit.
|
|
144
|
+
*/
|
|
145
|
+
export declare function contextOf(dictionary: Dictionary, haystack: string): Context;
|
|
146
|
+
//# sourceMappingURL=match-scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-scoring.d.ts","sourceRoot":"","sources":["../../src/search/match-scoring.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,MAAM,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,IAA8B,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IACtC,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,CAAC;IACtD,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,UAAU,EAAE,CActE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CA0B3E"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { sourcesOf } from "../decode/convert.js";
|
|
2
|
+
import { segment } from "../decode/segment.js";
|
|
3
|
+
import { toCharacters } from "../script/characters.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a match scores for reading its characters the way the text reads them.
|
|
6
|
+
*
|
|
7
|
+
* The one thing this has that a reverse index cannot: every reading a character
|
|
8
|
+
* takes is matchable, so 行 is found by both `xing` and `hang` — and the decoder
|
|
9
|
+
* has already settled which of them the text in front of it means. So 银行 ranks
|
|
10
|
+
* `yh` above `yx`, and 长江 ranks `cj` above `zj`, without either being refused.
|
|
11
|
+
*
|
|
12
|
+
* Weighted by the share of the matched characters that agree, rather than by how
|
|
13
|
+
* many, so that a long match and a short one are scored on the same scale.
|
|
14
|
+
*/
|
|
15
|
+
export const CONTEXT_READING = 4;
|
|
16
|
+
/**
|
|
17
|
+
* What a match scores for starting where a word starts.
|
|
18
|
+
*
|
|
19
|
+
* 大学 in 北京大学 is the second half of a word a reader thinks of as one thing;
|
|
20
|
+
* 大学 in 大学生 starts it. Both are matches and the second is the better one.
|
|
21
|
+
*/
|
|
22
|
+
export const WORD_START = 2;
|
|
23
|
+
/**
|
|
24
|
+
* What a match at the very start of the haystack scores, decaying with position.
|
|
25
|
+
*
|
|
26
|
+
* A tie-break rather than a judgement, and deliberately smaller than
|
|
27
|
+
* {@link WORD_START}: it settles two matches that are otherwise alike, and never
|
|
28
|
+
* outranks starting a word.
|
|
29
|
+
*/
|
|
30
|
+
export const EARLINESS = 1;
|
|
31
|
+
/**
|
|
32
|
+
* What one character scores for being written out in full rather than initialled.
|
|
33
|
+
*
|
|
34
|
+
* Only used to choose between the ways one query can be read over one haystack,
|
|
35
|
+
* never in the score a caller sees: `beij` over 北京大学 is 北 spelled out and 京
|
|
36
|
+
* initialled, and no other reading of it is on offer. Where two are — `xian` is
|
|
37
|
+
* both 西安 and 县 — the fuller spelling is the one the typist meant.
|
|
38
|
+
*
|
|
39
|
+
* Per character, which is what settles 这儿 against `zher`: read as 这 `zhèr` it
|
|
40
|
+
* spells two characters out at once, where 这 abbreviated to `zh` and 儿 as `er`
|
|
41
|
+
* spells one of them and initials the other.
|
|
42
|
+
*/
|
|
43
|
+
export const SPELLED_OUT = 1;
|
|
44
|
+
/**
|
|
45
|
+
* What one step down a character's reading list costs, likeliest reading first.
|
|
46
|
+
*
|
|
47
|
+
* The dictionary's own order, applied before the decoder has been asked
|
|
48
|
+
* anything: it is what separates 行 `xíng` from 行 `hàng` when the query could
|
|
49
|
+
* be either and the surrounding text says nothing.
|
|
50
|
+
*/
|
|
51
|
+
export const RARE_READING = 2;
|
|
52
|
+
/**
|
|
53
|
+
* What crossing one character with no reading costs.
|
|
54
|
+
*
|
|
55
|
+
* A separator inside a name is worth stepping over — 北京·大学 is one thing
|
|
56
|
+
* with a mark in the middle of it — and a query that steps over half a line of
|
|
57
|
+
* Latin to reach its second half has found something more tenuous.
|
|
58
|
+
*/
|
|
59
|
+
export const CROSSED = 0.5;
|
|
60
|
+
/**
|
|
61
|
+
* The query having been read to its end, with nothing left to account for.
|
|
62
|
+
*/
|
|
63
|
+
export const COMPLETE = { steps: [], score: 0 };
|
|
64
|
+
/**
|
|
65
|
+
* The steps of a match, gathered into the stretches they cover.
|
|
66
|
+
*/
|
|
67
|
+
export function rangesOf(steps) {
|
|
68
|
+
const ranges = [];
|
|
69
|
+
for (const step of steps) {
|
|
70
|
+
if (!step.isRead) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const last = ranges.at(-1);
|
|
74
|
+
if (last !== undefined && last.at + last.length === step.at) {
|
|
75
|
+
ranges[ranges.length - 1] = { at: last.at, length: last.length + 1 };
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
ranges.push({ at: step.at, length: 1 });
|
|
79
|
+
}
|
|
80
|
+
return ranges;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Ask the decoder what the haystack says, for the two things ranking needs.
|
|
84
|
+
*
|
|
85
|
+
* Worked out once a match is known to exist rather than before, because this is
|
|
86
|
+
* a decode of the whole text and matching is not: a search box filtering a list
|
|
87
|
+
* asks the cheap question of every item and pays for this on the few that hit.
|
|
88
|
+
*/
|
|
89
|
+
export function contextOf(dictionary, haystack) {
|
|
90
|
+
const preferred = [];
|
|
91
|
+
const wordStarts = new Set();
|
|
92
|
+
for (const word of segment(dictionary, haystack)) {
|
|
93
|
+
if (word.reading.length === 0) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
wordStarts.add(word.at);
|
|
97
|
+
// `sourcesOf` is the decoder's own answer to which characters a syllable
|
|
98
|
+
// reads, 儿化 included. It names the whole word and then nothing where it
|
|
99
|
+
// cannot say, which is not an alignment and is dropped rather than guessed.
|
|
100
|
+
const sources = sourcesOf(word.text, word.reading).filter((source) => source !== undefined);
|
|
101
|
+
if (sources.length !== word.reading.length) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let at = word.at;
|
|
105
|
+
for (const [index, source] of sources.entries()) {
|
|
106
|
+
for (const _ of toCharacters(source)) {
|
|
107
|
+
preferred[at] = word.reading[index];
|
|
108
|
+
at++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { preferred, wordStarts };
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=match-scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-scoring.js","sourceRoot":"","sources":["../../src/search/match-scoring.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walking a query over a haystack.
|
|
3
|
+
*
|
|
4
|
+
* The search is a walk over two sequences at once — the haystack's characters
|
|
5
|
+
* and the query's letters — where each character may account for some of the
|
|
6
|
+
* query in more than one way. `match.ts` is the one call that starts it.
|
|
7
|
+
*/
|
|
8
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
9
|
+
import { type PinyinMatch } from "./match-ranking.js";
|
|
10
|
+
export type { PinyinMatch } from "./match-ranking.js";
|
|
11
|
+
/**
|
|
12
|
+
* One query being read over one haystack.
|
|
13
|
+
*
|
|
14
|
+
* The search is a walk over two sequences at once — the haystack's characters
|
|
15
|
+
* and the query's letters — where each character may account for some of the
|
|
16
|
+
* query in more than one way, since it may have more than one reading and each
|
|
17
|
+
* reading may be written out or abbreviated. Memoised on the pair of positions,
|
|
18
|
+
* which is what stops the ways of splitting a long query multiplying out.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Search {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(dictionary: Dictionary, haystack: string, query: string);
|
|
23
|
+
/**
|
|
24
|
+
* The best match, or undefined where the query matches nowhere.
|
|
25
|
+
*/
|
|
26
|
+
best(): PinyinMatch | undefined;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=match-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-search.d.ts","sourceRoot":"","sources":["../../src/search/match-search.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;GAQG;AACH,qBAAa,MAAM;;IAQjB,YAAY,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAMlE;IAgGD;;OAEG;IACH,IAAI,IAAI,WAAW,GAAG,SAAS,CAK9B;CACF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { toCharacters } from "../script/characters.js";
|
|
2
|
+
import { chunksFor } from "./match-chunks.js";
|
|
3
|
+
import { bestMatch } from "./match-ranking.js";
|
|
4
|
+
import { CharacterReadings } from "./match-readings.js";
|
|
5
|
+
import { skipSeparators } from "./query.js";
|
|
6
|
+
import { COMPLETE, CROSSED, RARE_READING, SPELLED_OUT, } from "./match-scoring.js";
|
|
7
|
+
/**
|
|
8
|
+
* One query being read over one haystack.
|
|
9
|
+
*
|
|
10
|
+
* The search is a walk over two sequences at once — the haystack's characters
|
|
11
|
+
* and the query's letters — where each character may account for some of the
|
|
12
|
+
* query in more than one way, since it may have more than one reading and each
|
|
13
|
+
* reading may be written out or abbreviated. Memoised on the pair of positions,
|
|
14
|
+
* which is what stops the ways of splitting a long query multiplying out.
|
|
15
|
+
*/
|
|
16
|
+
export class Search {
|
|
17
|
+
#dictionary;
|
|
18
|
+
#haystack;
|
|
19
|
+
#characters;
|
|
20
|
+
#query;
|
|
21
|
+
#readings;
|
|
22
|
+
#paths = new Map();
|
|
23
|
+
constructor(dictionary, haystack, query) {
|
|
24
|
+
this.#dictionary = dictionary;
|
|
25
|
+
this.#haystack = haystack;
|
|
26
|
+
this.#characters = toCharacters(haystack);
|
|
27
|
+
this.#readings = new CharacterReadings(dictionary, this.#characters);
|
|
28
|
+
this.#query = query;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The best way of reading the rest of the query from a character, or nothing.
|
|
32
|
+
*/
|
|
33
|
+
#from(at, offset) {
|
|
34
|
+
const start = skipSeparators(this.#query, offset);
|
|
35
|
+
if (start === this.#query.length) {
|
|
36
|
+
return COMPLETE;
|
|
37
|
+
}
|
|
38
|
+
if (at >= this.#characters.length) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const key = `${String(at)}:${String(start)}`;
|
|
42
|
+
const held = this.#paths.get(key);
|
|
43
|
+
if (held !== undefined || this.#paths.has(key)) {
|
|
44
|
+
return held;
|
|
45
|
+
}
|
|
46
|
+
const found = this.#read(at, start);
|
|
47
|
+
this.#paths.set(key, found);
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Read one character, every way it can be read, and keep the best.
|
|
52
|
+
*/
|
|
53
|
+
#read(at, start) {
|
|
54
|
+
const candidates = this.#readings.candidatesAt(at);
|
|
55
|
+
if (candidates.length === 0) {
|
|
56
|
+
return this.#cross(at, start);
|
|
57
|
+
}
|
|
58
|
+
let best;
|
|
59
|
+
for (const candidate of candidates) {
|
|
60
|
+
for (const chunk of chunksFor(this.#query, start, candidate.reading)) {
|
|
61
|
+
const rest = this.#from(at + candidate.characters, chunk.next);
|
|
62
|
+
if (rest === undefined) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const score = rest.score +
|
|
66
|
+
(chunk.isFull ? SPELLED_OUT * candidate.characters : 0) -
|
|
67
|
+
candidate.rank * RARE_READING;
|
|
68
|
+
if (best === undefined || score > best.score) {
|
|
69
|
+
best = {
|
|
70
|
+
steps: [
|
|
71
|
+
...Array.from({ length: candidate.characters }, (_, covered) => ({
|
|
72
|
+
at: at + covered,
|
|
73
|
+
isRead: true,
|
|
74
|
+
from: start,
|
|
75
|
+
next: chunk.next,
|
|
76
|
+
})),
|
|
77
|
+
...rest.steps,
|
|
78
|
+
],
|
|
79
|
+
score,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return best;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Step over a character with no reading, which a match may span but not end
|
|
88
|
+
* on: the query is checked for having been read to its end first.
|
|
89
|
+
*/
|
|
90
|
+
#cross(at, start) {
|
|
91
|
+
const rest = this.#from(at + 1, start);
|
|
92
|
+
return rest === undefined
|
|
93
|
+
? undefined
|
|
94
|
+
: {
|
|
95
|
+
steps: [
|
|
96
|
+
{ at, isRead: false, from: start, next: start },
|
|
97
|
+
...rest.steps,
|
|
98
|
+
],
|
|
99
|
+
score: rest.score - CROSSED,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Where the query matches at all, and how it reads at each of those places.
|
|
104
|
+
*/
|
|
105
|
+
#everyMatch() {
|
|
106
|
+
const found = [];
|
|
107
|
+
for (const [at] of this.#characters.entries()) {
|
|
108
|
+
if (this.#readings.at(at).length === 0) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const path = this.#from(at, 0);
|
|
112
|
+
if (path !== undefined) {
|
|
113
|
+
found.push(path);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return found;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The best match, or undefined where the query matches nowhere.
|
|
120
|
+
*/
|
|
121
|
+
best() {
|
|
122
|
+
const found = this.#everyMatch();
|
|
123
|
+
return found.length === 0
|
|
124
|
+
? undefined
|
|
125
|
+
: bestMatch(this.#dictionary, this.#haystack, this.#query, found);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=match-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-search.js","sourceRoot":"","sources":["../../src/search/match-search.ts"],"names":[],"mappings":"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"}
|
package/dist/search/match.d.ts
CHANGED
|
@@ -1,41 +1,10 @@
|
|
|
1
|
-
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
2
|
-
/**
|
|
3
|
-
* A stretch of the haystack the query spelled out.
|
|
4
|
-
*/
|
|
5
|
-
export interface MatchRange {
|
|
6
|
-
/**
|
|
7
|
-
* Where it starts, in code points from the start of the haystack.
|
|
8
|
-
*
|
|
9
|
-
* Code points rather than UTF-16 units, exactly as `Segment.at` is, so that a
|
|
10
|
-
* character outside the basic plane counts as the one character it is.
|
|
11
|
-
*/
|
|
12
|
-
readonly at: number;
|
|
13
|
-
/** How many characters it covers. */
|
|
14
|
-
readonly length: number;
|
|
15
|
-
}
|
|
16
1
|
/**
|
|
17
|
-
*
|
|
2
|
+
* Finding where a pinyin query occurs in a Chinese text.
|
|
18
3
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* Usually one. There is more than one where the query ran over something
|
|
24
|
-
* with no reading of its own: 北京·大学 is matched by `bjdx` as two ranges
|
|
25
|
-
* with the separator between them left out, so that highlighting them marks
|
|
26
|
-
* what was matched rather than what lay between.
|
|
27
|
-
*/
|
|
28
|
-
readonly ranges: readonly MatchRange[];
|
|
29
|
-
/**
|
|
30
|
-
* How good the match is, where higher is better.
|
|
31
|
-
*
|
|
32
|
-
* For ordering the haystacks one query matched — sort descending and the
|
|
33
|
-
* best is first. Comparable within a query and not across queries: what it
|
|
34
|
-
* weighs is described at {@link CONTEXT_READING}, and none of it is a
|
|
35
|
-
* probability.
|
|
36
|
-
*/
|
|
37
|
-
readonly score: number;
|
|
38
|
-
}
|
|
4
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
5
|
+
import { type PinyinMatch } from "./match-search.js";
|
|
6
|
+
export type { MatchRange } from "./match-scoring.js";
|
|
7
|
+
export type { PinyinMatch } from "./match-search.js";
|
|
39
8
|
/**
|
|
40
9
|
* Find where a pinyin query matches a Chinese text, for filtering and
|
|
41
10
|
* highlighting.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/search/match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/search/match.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAE7D,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,KAAK,CACnB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,WAAW,GAAG,SAAS,CAMzB"}
|