-
Notifications
You must be signed in to change notification settings - Fork 563
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
feat(language): shared user dictionary per language (Closes #184) #214
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f9f9976
feat(language): shared user dictionary per language (Closes #184)
lotem 91775a6
fix(language, memory, user_dictionary): a translator without user dic…
lotem db519e6
fix(memory): avoid null pointer access after dynamic casting
nameoverflow 4c2aa3c
fix(language): add null check
lotem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Copyright RIME Developers | ||
// Distributed under the BSD License | ||
// | ||
#include <rime/common.h> | ||
#include <rime/language.h> | ||
|
||
namespace rime { | ||
|
||
// "luna_pinyin.extra" has language component "luna_pinyin". | ||
string Language::get_language_component(const string& name) { | ||
size_t dot = name.find('.'); | ||
if (dot != string::npos && dot != 0) | ||
return name.substr(0, dot); | ||
return name; | ||
} | ||
|
||
} // namespace rime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Copyright RIME Developers | ||
// Distributed under the BSD License | ||
// | ||
#ifndef RIME_LANGUAGE_H_ | ||
#define RIME_LANGUAGE_H_ | ||
|
||
#include <rime/common.h> | ||
|
||
namespace rime { | ||
|
||
class Language { | ||
const string name_; | ||
|
||
public: | ||
Language(const string& name) : name_(name) {} | ||
string name() const { return name_; } | ||
|
||
bool operator== (const Language& other) const { | ||
return name_ == other.name_; | ||
} | ||
|
||
template <class T, class U> | ||
static bool intelligible(const T& t, const U& u) { | ||
return t->language() && u->language() && *t->language() == *u->language(); | ||
} | ||
|
||
static string get_language_component(const string& name); | ||
}; | ||
|
||
} // namespace rime | ||
|
||
#endif // RIME_LANGUAGE_H_ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
有没有办法给
T
和U
类型增加一个必须有language
方法的约束,类似interface
或者trait
机制?似乎直接使用 template 一旦intelligible
方法使用出错编译器的报错就完全不能看了。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.
講究。你當是寫 Rust?
雖然有,但我不想爲了類型檢查寫一堆模板庫函。滿足於代碼簡單可工作。
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.
有道理