converter.pyi 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. from typing import Any
  2. from typing import List
  3. from typing import Union
  4. from typing import Callable
  5. from typing import Optional
  6. from typing import Text
  7. from pypinyin.constants import Style
  8. TStyle = Style
  9. TErrors = Union[Callable[[Text], Text], Text]
  10. TPinyinResult = List[List[Text]]
  11. TErrorResult = Union[Text, List[Text], None]
  12. TNoPinyinResult = Union[TPinyinResult, List[Text], Text, None]
  13. class Converter(object):
  14. def convert(self, words: Text, style: TStyle, heteronym: bool,
  15. errors: TErrors, strict: bool = ...,
  16. **kwargs: Any) -> TPinyinResult: ...
  17. class DefaultConverter(Converter):
  18. def __init__(self, **kwargs: Any) -> None: ...
  19. def convert(self, words: Text, style: TStyle, heteronym: bool,
  20. errors: TErrors, strict: bool = ...,
  21. **kwargs: Any) -> TPinyinResult: ...
  22. def pre_convert_style(self, han: Text, orig_pinyin: Text, style: TStyle,
  23. strict: bool, **kwargs: Any) -> Optional[Text]: ...
  24. def convert_style(self, han: Text, orig_pinyin: Text, style: TStyle,
  25. strict: bool, **kwargs: Any) -> Text: ...
  26. def post_convert_style(self, han: Text, orig_pinyin: Text,
  27. converted_pinyin: Text, style: TStyle,
  28. strict: bool, **kwargs: Any) -> Optional[Text]: ...
  29. def pre_handle_nopinyin(self, chars: Text, style: TStyle, heteronym: bool,
  30. errors: TErrors, strict: bool
  31. ) -> TNoPinyinResult: ...
  32. def handle_nopinyin(self, chars: Text, style: TStyle, heteronym: bool,
  33. errors: TErrors, strict: bool, **kwargs: Any
  34. ) -> TPinyinResult: ...
  35. def post_handle_nopinyin(self, chars: Text, style: Style, heteronym: bool,
  36. errors: TErrors, strict: bool,
  37. pinyin: TNoPinyinResult, **kwargs: Any
  38. ) -> TNoPinyinResult: ...
  39. def post_pinyin(self, han: Text, heteronym: bool,
  40. pinyin: TPinyinResult,
  41. **kwargs: Any) -> Union[TPinyinResult, None]: ...
  42. def convert_styles(self, pinyin_list: TPinyinResult,
  43. phrase: Text, style: TStyle, heteronym: bool,
  44. errors: TErrors, strict: bool, **kwargs: Any,
  45. ) -> TPinyinResult: ...
  46. def _phrase_pinyin(self, phrase: Text, style: TStyle, heteronym: bool,
  47. errors: TErrors, strict: bool
  48. ) -> TPinyinResult: ...
  49. def _single_pinyin(self, han: Text, style: TStyle, heteronym: bool,
  50. errors: TErrors, strict: bool
  51. ) -> TPinyinResult: ...
  52. def _convert_style(self, han: Text, pinyin: Text, style: TStyle,
  53. strict: bool, default: Text, **kwargs: Any
  54. ) -> Text: ...
  55. def _convert_nopinyin_chars(self, chars: Text, style: TStyle,
  56. heteronym: bool, errors: TErrors,
  57. strict: bool
  58. ) -> TNoPinyinResult: ...
  59. class UltimateConverter(DefaultConverter):
  60. def __init__(self, **kwargs: Any) -> None:
  61. self._tone_sandhi = ...
  62. self._neutral_tone_with_five = ...
  63. self._v_to_u = ...
  64. ...
  65. def convert(self, words: Text, style: TStyle, heteronym: bool,
  66. errors: TErrors, strict: bool = ...,
  67. **kwargs: Any) -> TPinyinResult: ...
  68. def pre_convert_style(self, han: Text, orig_pinyin: Text, style: TStyle,
  69. strict: bool, **kwargs: Any) -> Optional[Text]: ...
  70. def convert_style(self, han: Text, orig_pinyin: Text, style: TStyle,
  71. strict: bool, **kwargs: Any) -> Text: ...
  72. def post_convert_style(self, han: Text, orig_pinyin: Text,
  73. converted_pinyin: Text, style: TStyle,
  74. strict: bool, **kwargs: Any) -> Optional[Text]: ...
  75. def pre_handle_nopinyin(self, chars: Text, style: TStyle, heteronym: bool,
  76. errors: TErrors, strict: bool
  77. ) -> TNoPinyinResult: ...
  78. def handle_nopinyin(self, chars: Text, style: TStyle, heteronym: bool,
  79. errors: TErrors, strict: bool, **kwargs: Any
  80. ) -> TPinyinResult: ...
  81. def post_handle_nopinyin(self, chars: Text, style: Style, heteronym: bool,
  82. errors: TErrors, strict: bool,
  83. pinyin: TNoPinyinResult, **kwargs: Any
  84. ) -> TNoPinyinResult: ...
  85. def post_pinyin(self, han: Text, heteronym: bool,
  86. pinyin: TPinyinResult,
  87. **kwargs: Any) -> Union[TPinyinResult, None]: ...
  88. def _phrase_pinyin(self, phrase: Text, style: TStyle, heteronym: bool,
  89. errors: TErrors, strict: bool
  90. ) -> TPinyinResult: ...
  91. def _single_pinyin(self, han: Text, style: TStyle, heteronym: bool,
  92. errors: TErrors, strict: bool
  93. ) -> TPinyinResult: ...
  94. def _convert_style(self, han: Text, pinyin: Text, style: TStyle,
  95. strict: bool, default: Text, **kwargs: Any
  96. ) -> Text: ...
  97. def _convert_nopinyin_chars(self, chars: Text, style: TStyle,
  98. heteronym: bool, errors: TErrors,
  99. strict: bool
  100. ) -> TNoPinyinResult: ...