Add space for pinyin translation#235
Conversation
| { | ||
| var result = WordsHelper.GetPinyin(content, ";"); | ||
| result = GetFirstPinyinChar(result) + result.Replace(";", ""); | ||
| var result = WordsHelper.GetPinyin(content, " "); |
There was a problem hiding this comment.
with this change, when i pinyin search '你好' for 'nihao' it doesnt hit as it return splitted up 'ni hao'
There was a problem hiding this comment.
I don't think anybody would use Chinese to search for pinyin like characters.... If both are chinese, it will be fine because the string to compare will also contain space.
There was a problem hiding this comment.
I don't think anybody would use Chinese to search for pinyin like characters.... If both are chinese, it will be fine because the string to compare will also contain space.
There was a problem hiding this comment.
ok so we dont need to worry about chinese to pinyin.
There was a problem hiding this comment.
No, because the reason using pinyin is to make searching faster by reducing the process of typing Chinese, since typing Chinese require extra typing.
| private string GetFirstPinyinChar(string content) | ||
| { | ||
| return string.Concat(content.Split(';').Select(x => x.First())); | ||
| return string.Concat(content.Split(' ').Select(x => x.First())); |
There was a problem hiding this comment.
need to add remove empty entries otherwise it will throw because you are doing First():
return string.Concat(content.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(x => x.First()));
There was a problem hiding this comment.
Well it isn't an issue before because the translated query won't contain something like ;;, but since we now use space to split. I will take a look on the translated query when the original query contain both Chinese and letter and space.
|
@jjw24 I manually set the space instead of using the method provided by the library. It seems works fine, now. |
optimize Chinese character check logic Co-Authored-By: ToolGood <toolgood@qq.com>

close #229