Comments (7)
顺便小问一下,为什么重启翻译出来时ZhongQi hhhhhh
from toolgood.words.pinyin.
提供一个可行的方案,但是有一点丑陋
var resultList = WordsHelper.GetPinyinList(content);
List<int> chineseIndexs = new List<int>();
for (int i = 0; i < content.Length; i++)
{
if (resultList[i].Length != 1 || !(resultList[i][0] == content[i]))
chineseIndexs.Add(i);
}
int currentChineseIndex = 0;
int lastChineseIndex = -1;
for (int i = 0; i < resultList.Length; i++)
{
if (currentChineseIndex < chineseIndexs.Count && chineseIndexs[currentChineseIndex] == i)
{
resultBuilder.Append(' ');
resultBuilder.Append(resultList[i]);
currentChineseIndex++;
lastChineseIndex = i;
}
else
{
if (i == lastChineseIndex + 1)
{
resultBuilder.Append(' ');
}
resultBuilder.Append(resultList[i]);
}
}
from toolgood.words.pinyin.
顺便小问一下,为什么重启翻译出来时ZhongQi hhhhhh
拼音库不全,所以会出现这个问题
from toolgood.words.pinyin.
var pys = PinyinDict.GetPinyinList(text, tone ? 1 : 0);
StringBuilder stringBuilder = new StringBuilder();
bool pre = false;
for (int i = 0; i < text.Length; i++) {
var py = pys[i];
if (py.Length > 1 || (text[i] >= 0x3400 && text[i]<= 0x9FD5)) {
if (stringBuilder.Length > 0) {
stringBuilder.Append(' ');
}
stringBuilder.Append(py);
pre = true;
} else {
if (pre) {
stringBuilder.Append(' ');
}
stringBuilder.Append(text[i]);
pre = false;
}
}
return stringBuilder.ToString();
from toolgood.words.pinyin.
if (py.Length > 1 || (text[i] >= 0x3400 && text[i]<= 0x9FD5)) {
可以再次简化
if (text[i] >= 0x3400 && text[i]<= 0x9FD5) {
from toolgood.words.pinyin.
谢谢!
from toolgood.words.pinyin.
是不是没有合并到主版本啊,我的也会这样,英文被拆成了单个字母。
from toolgood.words.pinyin.
Related Issues (7)
- 覃字为姓时读qin HOT 1
- WordsHelper.GetPinyin("什么"); 输出: "ShiYao" HOT 3
- 3.0.26 内存占用似乎有点高? HOT 2
- 能否加入一个获取声调的函数或者支持声调输出格式 HOT 4
- 莎/露 姓名转换错误 HOT 1
- 行不行简拼
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toolgood.words.pinyin.