@kensio/pinyinjs 1.7.8 → 1.7.10

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.
Files changed (97) hide show
  1. package/README.md +18 -2
  2. package/data/core.entries +2259 -2259
  3. package/data/core.freq +0 -0
  4. package/data/full.counts +0 -0
  5. package/data/full.entries +2289 -2289
  6. package/data/full.freq +0 -0
  7. package/data/manifest.json +8 -8
  8. package/data/standard.entries +2257 -2257
  9. package/data/standard.freq +0 -0
  10. package/dist/cli/flag-lists.d.ts +2 -1
  11. package/dist/cli/flag-lists.d.ts.map +1 -1
  12. package/dist/cli/flag-lists.js.map +1 -1
  13. package/dist/cli/format-options.d.ts +5 -1
  14. package/dist/cli/format-options.d.ts.map +1 -1
  15. package/dist/cli/format-options.js +9 -2
  16. package/dist/cli/format-options.js.map +1 -1
  17. package/dist/cli/html-commands.d.ts.map +1 -1
  18. package/dist/cli/html-commands.js +15 -3
  19. package/dist/cli/html-commands.js.map +1 -1
  20. package/dist/cli/systems.d.ts +15 -43
  21. package/dist/cli/systems.d.ts.map +1 -1
  22. package/dist/cli/systems.js +9 -12
  23. package/dist/cli/systems.js.map +1 -1
  24. package/dist/decode/guo-rule.d.ts +64 -0
  25. package/dist/decode/guo-rule.d.ts.map +1 -0
  26. package/dist/decode/guo-rule.js +138 -0
  27. package/dist/decode/guo-rule.js.map +1 -0
  28. package/dist/decode/reading-rules.d.ts +1 -0
  29. package/dist/decode/reading-rules.d.ts.map +1 -1
  30. package/dist/decode/reading-rules.js +3 -0
  31. package/dist/decode/reading-rules.js.map +1 -1
  32. package/dist/dictionary/artifact.js +2 -2
  33. package/dist/dictionary/artifact.js.map +1 -1
  34. package/dist/dictionary/frequency-table.d.ts +103 -0
  35. package/dist/dictionary/frequency-table.d.ts.map +1 -1
  36. package/dist/dictionary/frequency-table.js +96 -8
  37. package/dist/dictionary/frequency-table.js.map +1 -1
  38. package/dist/dictionary/merge-types.d.ts +12 -0
  39. package/dist/dictionary/merge-types.d.ts.map +1 -1
  40. package/dist/dictionary/merge-types.js.map +1 -1
  41. package/dist/dictionary/merge-word.d.ts.map +1 -1
  42. package/dist/dictionary/merge-word.js +2 -2
  43. package/dist/dictionary/merge-word.js.map +1 -1
  44. package/dist/dictionary/merge.d.ts.map +1 -1
  45. package/dist/dictionary/merge.js +11 -1
  46. package/dist/dictionary/merge.js.map +1 -1
  47. package/dist/dictionary/name-mass.d.ts +42 -0
  48. package/dist/dictionary/name-mass.d.ts.map +1 -0
  49. package/dist/dictionary/name-mass.js +66 -0
  50. package/dist/dictionary/name-mass.js.map +1 -0
  51. package/dist/dictionary/proper-noun.d.ts +8 -1
  52. package/dist/dictionary/proper-noun.d.ts.map +1 -1
  53. package/dist/dictionary/proper-noun.js +13 -3
  54. package/dist/dictionary/proper-noun.js.map +1 -1
  55. package/dist/dictionary/script-pairings.d.ts +12 -0
  56. package/dist/dictionary/script-pairings.d.ts.map +1 -1
  57. package/dist/dictionary/script-pairings.js +20 -0
  58. package/dist/dictionary/script-pairings.js.map +1 -1
  59. package/dist/dictionary/traditional-carry.d.ts +23 -0
  60. package/dist/dictionary/traditional-carry.d.ts.map +1 -0
  61. package/dist/dictionary/traditional-carry.js +201 -0
  62. package/dist/dictionary/traditional-carry.js.map +1 -0
  63. package/dist/format/annotate.d.ts.map +1 -1
  64. package/dist/format/annotate.js +3 -3
  65. package/dist/format/annotate.js.map +1 -1
  66. package/dist/format/html.d.ts +41 -6
  67. package/dist/format/html.d.ts.map +1 -1
  68. package/dist/format/html.js +34 -83
  69. package/dist/format/html.js.map +1 -1
  70. package/dist/format/language-tag.d.ts +57 -0
  71. package/dist/format/language-tag.d.ts.map +1 -0
  72. package/dist/format/language-tag.js +76 -0
  73. package/dist/format/language-tag.js.map +1 -0
  74. package/dist/format/syllable-span.d.ts +10 -0
  75. package/dist/format/syllable-span.d.ts.map +1 -0
  76. package/dist/format/syllable-span.js +87 -0
  77. package/dist/format/syllable-span.js.map +1 -0
  78. package/dist/format/transcribed.d.ts +36 -0
  79. package/dist/format/transcribed.d.ts.map +1 -0
  80. package/dist/format/transcribed.js +38 -0
  81. package/dist/format/transcribed.js.map +1 -0
  82. package/dist/format/transcription.d.ts.map +1 -1
  83. package/dist/format/transcription.js +7 -19
  84. package/dist/format/transcription.js.map +1 -1
  85. package/dist/index.d.ts +3 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/transcription/systems.d.ts +82 -0
  90. package/dist/transcription/systems.d.ts.map +1 -0
  91. package/dist/transcription/systems.js +64 -0
  92. package/dist/transcription/systems.js.map +1 -0
  93. package/package.json +2 -2
  94. package/dist/cli/system-table.d.ts +0 -12
  95. package/dist/cli/system-table.d.ts.map +0 -1
  96. package/dist/cli/system-table.js +0 -48
  97. package/dist/cli/system-table.js.map +0 -1
package/README.md CHANGED
@@ -69,7 +69,7 @@ běijīng běijīng ㄅㄟˇ ㄐㄧㄥ pei³-ching¹ běijīng beeij
69
69
  | ------------ | --------------------------------------------------- |
70
70
  | `convert` | hanzi to pinyin |
71
71
  | `html` | the same, as HTML |
72
- | `annotate` | hanzi with its pinyin above, as ruby HTML |
72
+ | `annotate` | hanzi with its reading above, as ruby HTML |
73
73
  | `segment` | split text into words |
74
74
  | `match` | filter text by a pinyin query, best first |
75
75
  | `check` | mark typed pinyin against the text |
@@ -398,6 +398,22 @@ ruby rt {
398
398
  }
399
399
  ```
400
400
 
401
+ **The reading does not have to be pinyin.** `transcription` writes it in
402
+ bopomofo, Wade-Giles, Yale, Gwoyeu Romatzyh or the IPA, which is what a page
403
+ offering a reader 注音符號 over the characters needs:
404
+
405
+ ```ts
406
+ import { convertToAnnotatedHtml, BOPOMOFO } from "@kensio/pinyinjs";
407
+
408
+ convertToAnnotatedHtml(dictionary, "银", { transcription: BOPOMOFO });
409
+ // <ruby lang="zh">银<rp>(</rp><rt><span class="py-syllable py-tone-2"
410
+ // lang="zh-Bopo-CN">ㄧㄣˊ</span></rt><rp>)</rp></ruby>
411
+ ```
412
+
413
+ The tone class does not move, since the tone belongs to the syllable rather than
414
+ to the spelling, so one CSS rule colours a second tone in either. The `lang`
415
+ follows the system. More in [HTML output](docs/html/).
416
+
401
417
  `toAnnotatedHtml(pieces, options)` renders pieces you already have, and
402
418
  `ConvertedPiece.source` is what makes that possible, holding the characters each
403
419
  piece reads, or undefined where it reads on into the ones before it.
@@ -483,7 +499,7 @@ import { candidates, homophonesOf, ReverseIndex } from "@kensio/pinyinjs";
483
499
 
484
500
  const index = ReverseIndex.of(dictionary);
485
501
 
486
- candidates(index, "shi", { limit: 5 }); // ["是", "时", "事", "使", "市"]
502
+ candidates(index, "shi", { limit: 5 }); // ["是", "时", "時", "事", "使"]
487
503
  candidates(index, "yinhang"); // ["銀行", "银行", "引吭", "引航", "印航"]
488
504
  candidates(index, "yínháng"); // ["銀行", "银行"], narrowed by tone
489
505
  homophonesOf(index, "长城"); // ["長城", "長程", "长程", "常程"]