-
-
Notifications
You must be signed in to change notification settings - Fork 455
Add space for pinyin translation #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| var result = WordsHelper.GetPinyin(content, ";"); | ||
| result = GetFirstPinyinChar(result) + result.Replace(";", ""); | ||
| var result = WordsHelper.GetPinyin(content, " "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so we dont need to worry about chinese to pinyin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>

close #229