Skip to content

Commit

Permalink
fix(simplifier): opencc::DictEntry::Values() type change in opencc 1.1.0
Browse files Browse the repository at this point in the history
Closes #367
  • Loading branch information
lotem committed May 14, 2020
1 parent 7dbfe49 commit beae5b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/rime/gear/simplifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <boost/filesystem.hpp>
#include <stdint.h>
#include <utf8.h>
#include <utility>
#include <rime/candidate.h>
#include <rime/common.h>
#include <rime/config.h>
Expand Down Expand Up @@ -45,24 +46,22 @@ class Opencc {
}
}

bool ConvertWord(const string& text,
vector<string>* forms) {
bool ConvertWord(const string& text, vector<string>* forms) {
if (dict_ == nullptr) return false;
opencc::Optional<const opencc::DictEntry*> item = dict_->Match(text);
if (item.IsNull()) {
// Match not found
return false;
} else {
const opencc::DictEntry* entry = item.Get();
for (const char* value : entry->Values()) {
forms->push_back(value);
for (auto&& value : entry->Values()) {
forms->push_back(std::move(value));
}
return forms->size() > 0;
}
}

bool RandomConvertText(const string& text,
string* simplified) {
bool RandomConvertText(const string& text, string* simplified) {
if (dict_ == nullptr) return false;
const char *phrase = text.c_str();
std::ostringstream buffer;
Expand All @@ -83,8 +82,7 @@ class Opencc {
return *simplified != text;
}

bool ConvertText(const string& text,
string* simplified) {
bool ConvertText(const string& text, string* simplified) {
if (converter_ == nullptr) return false;
*simplified = converter_->Convert(text);
return *simplified != text;
Expand Down
5 changes: 3 additions & 2 deletions src/rime/gear/simplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Simplifier : public Filter, TagMatching {
explicit Simplifier(const Ticket& ticket);

virtual an<Translation> Apply(an<Translation> translation,
CandidateList* candidates);
CandidateList* candidates);


virtual bool AppliesToSegment(Segment* segment) {
Expand All @@ -35,7 +35,8 @@ class Simplifier : public Filter, TagMatching {

void Initialize();
void PushBack(const an<Candidate>& original,
CandidateQueue* result, const string& simplified);
CandidateQueue* result,
const string& simplified);

bool initialized_ = false;
the<Opencc> opencc_;
Expand Down

0 comments on commit beae5b1

Please sign in to comment.