如何将汉字转换为拼音 [英] How to convert Chinese characters to Pinyin

查看:106
本文介绍了如何将汉字转换为拼音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了对中文文本进行排序,我想将汉字转换为拼音,正确地分隔每个汉字并将连续的字符分组在一起.

For sorting Chinese language text, I want to convert Chinese characters to Pinyin, properly separating each Chinese character and grouping successive characters together.

您能通过提供执行此操作的逻辑或源代码来帮助我吗?

Can you please help me in this task by providing the logic or source code for doing this?

请让我知道是否已经为此提供了任何开源或库.

Please let me know if any open source or lib already present for this.

推荐答案

简短的回答:您没有.

长答案:汉字到汉语拼音没有一对一的映射.只是一些简单的例子:

Long answer: There is no one-to-one mapping for 汉字 to 汉语拼音. Just some quick examples:

  • 把可以是第三声调或第四声调的"ba".
  • 了可以是"le"无声或"liao"第三声.
  • 乐可以是"le"或"yue",都可以是第四音.
  • 落在第四个基调中可以是"luo","la"或"lao".

以此类推.关于这一主题,我有一本初学者的书,其中包含207个示例.我强调这是一本初学者的书,绝不是一本完整的书.每个页面都有一两个页面,分别是用法和条件的示例,您可以在其中选择适当的发音.这不是很容易编程的东西(如果有的话).

And so on. I have a beginners' book on this topic that has 207 examples. I stress that this is a beginners' book and is by no means complete. Each one has a page or two of examples of use and conditions under which you choose the appropriate pronunciation. It is not something that could be easily programmed (if at all).

这甚至还没有解决您要处理的另一项棘手问题:将字符分隔为成组的单词.一个单词的概念在中文中有点滑. (例如,两个词大致对应于中文中的单词":字和词.第一个是字符,第二个字符组合成一个概念.(我经常说中文的人问有多少个在某些情况下,区别很明显(例如,乌鸦"是乌鸦"),这两个词必须在一起才能正确地表达这个想法,在某些情况下,它们之间的区别很明显(例如,乌鸦"一词是乌鸦").并且将其翻译为黑乌鸦"是不正确的),在其他方面则不太清楚.你好"是什么意思?字面上的意思是你好"吗?每个涉及的字符都是单独站立或与其他词一起成组,但在一起的含义完全不同于各自的含义.因此,您打算如何将汉语拼音音译归为一类(首先很难甚至不可能做到!)变成单词"?

And this doesn't even address the other slippery thing you want to deal with: the separation of characters into grouped words. The very notion of a word is a bit slippery in Chinese. (There's two terms that correspond, roughly to "word" in Chinese for example: 字 and 词. The first is the character, the second groups of characters that are put together into one concept. (I frequently get asked by Chinese speakers how many "words" I can read when they really mean "characters".) While in some cases the distinction is clear (the 词 "乌鸦", for example, is "crow" -- the two 字 must be together to express the idea properly and it would be incorrect to translate it as "black crow"), in others it is not so clear. What does "你好" translate to? Is it one word meaning, idiomatically, "hello"? Or is it two words translating literally to "you good"? Each of the characters involved stands alone or in groups with other words, but together they mean something entirely different from their individual meanings. Given this, how, precisely, do you plan to group the 汉语拼音 transliterations (which are difficult to impossible to get right in the first place!) into "words"?

这篇关于如何将汉字转换为拼音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆