-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
59 additions
and
37 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
// | ||
// 2012-01-17 GONG Chen <[email protected]> | ||
// | ||
#include <boost/algorithm/string.hpp> | ||
#include <utf8.h> | ||
#include <rime/algo/calculus.h> | ||
#include <rime/algo/strings.h> | ||
#include <rime/common.h> | ||
|
||
namespace rime { | ||
|
@@ -31,9 +31,8 @@ Calculation* Calculus::Parse(const string& definition) { | |
size_t sep = definition.find_first_not_of("zyxwvutsrqponmlkjihgfedcba"); | ||
if (sep == string::npos) | ||
return NULL; | ||
vector<string> args; | ||
boost::split(args, definition, | ||
boost::is_from_range(definition[sep], definition[sep])); | ||
const string& delim = definition.substr(sep, 1); | ||
vector<string> args = strings::split(definition, delim); | ||
if (args.empty()) | ||
return NULL; | ||
auto it = factories_.find(args[0]); | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// | ||
// 2013-04-18 GONG Chen <[email protected]> | ||
// | ||
#include <boost/algorithm/string.hpp> | ||
#include <rime/algo/strings.h> | ||
#include <rime/dict/table_db.h> | ||
#include <rime/dict/user_db.h> | ||
|
||
|
@@ -22,7 +22,7 @@ static bool rime_table_entry_parser(const Tsv& row, | |
return false; | ||
} | ||
string code(row[1]); | ||
boost::algorithm::trim(code); | ||
strings::trim(code); | ||
*key = code + " \t" + row[0]; | ||
UserDbValue v; | ||
if (row.size() >= 3 && !row[2].empty()) { | ||
|
@@ -42,13 +42,13 @@ static bool rime_table_entry_formatter(const string& key, | |
Tsv* tsv) { | ||
Tsv& row(*tsv); | ||
// key ::= code <space> <Tab> phrase | ||
boost::algorithm::split(row, key, boost::algorithm::is_any_of("\t")); | ||
row = strings::split(key, "\t"); | ||
if (row.size() != 2 || row[0].empty() || row[1].empty()) | ||
return false; | ||
UserDbValue v(value); | ||
if (v.commits < 0) // deleted entry | ||
return false; | ||
boost::algorithm::trim(row[0]); // remove trailing space | ||
strings::trim(row[0]); // remove trailing space | ||
row[0].swap(row[1]); | ||
row.push_back(std::to_string(v.commits)); | ||
return true; | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
// 2013-04-14 GONG Chen <[email protected]> | ||
// | ||
#include <fstream> | ||
#include <boost/algorithm/string.hpp> | ||
#include <rime/algo/strings.h> | ||
#include <rime/common.h> | ||
#include <rime/dict/db_utils.h> | ||
#include <rime/dict/tsv.h> | ||
|
@@ -24,15 +24,15 @@ int TsvReader::operator()(Sink* sink) { | |
bool enable_comment = true; | ||
while (getline(fin, line)) { | ||
++line_no; | ||
boost::algorithm::trim_right(line); | ||
strings::trim_right(line); | ||
// skip empty lines and comments | ||
if (line.empty()) | ||
continue; | ||
if (enable_comment && line[0] == '#') { | ||
if (boost::starts_with(line, "#@")) { | ||
if (strings::starts_with(line, "#@")) { | ||
// metadata | ||
line.erase(0, 2); | ||
boost::algorithm::split(row, line, boost::algorithm::is_any_of("\t")); | ||
row = strings::split(line, "\t"); | ||
if (row.size() != 2 || !sink->MetaPut(row[0], row[1])) { | ||
LOG(WARNING) << "invalid metadata at line " << line_no << "."; | ||
} | ||
|
@@ -43,7 +43,7 @@ int TsvReader::operator()(Sink* sink) { | |
continue; | ||
} | ||
// read a tsv entry | ||
boost::algorithm::split(row, line, boost::algorithm::is_any_of("\t")); | ||
row = strings::split(line, "\t"); | ||
if (!parser_(row, &key, &value) || !sink->Put(key, value)) { | ||
LOG(WARNING) << "invalid entry at line " << line_no << "."; | ||
continue; | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// | ||
// 2013-05-26 GONG Chen <[email protected]> | ||
// | ||
#include <boost/algorithm/string.hpp> | ||
#include <rime/algo/strings.h> | ||
#include <rime/candidate.h> | ||
#include <rime/common.h> | ||
#include <rime/config.h> | ||
|
@@ -184,7 +184,7 @@ void FoldedOptions::Append(const SwitchOption& option, size_t state_index) { | |
} | ||
|
||
void FoldedOptions::Finish() { | ||
text_ = prefix_ + boost::algorithm::join(labels_, separator_) + suffix_; | ||
text_ = prefix_ + strings::join(labels_, separator_) + suffix_; | ||
} | ||
|
||
class SwitchTranslation : public FifoTranslation { | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// | ||
// 2013-08-31 GONG Chen <[email protected]> | ||
// | ||
#include <boost/algorithm/string.hpp> | ||
#include <rime/algo/strings.h> | ||
#include <rime/dict/dict_settings.h> | ||
#include <rime/dict/user_dictionary.h> | ||
#include <rime/dict/reverse_lookup_dictionary.h> | ||
|
@@ -62,7 +62,7 @@ bool UnityTableEncoder::TranslateWord(const string& word, | |
string str_list; | ||
if (rev_dict_->LookupStems(word, &str_list) || | ||
rev_dict_->ReverseLookup(word, &str_list)) { | ||
boost::split(*code, str_list, boost::is_any_of(" ")); | ||
*code = strings::split(str_list, " "); | ||
return !code->empty(); | ||
} | ||
return false; | ||
|
@@ -80,7 +80,7 @@ size_t UnityTableEncoder::LookupPhrases(UserDictEntryIterator* result, | |
} | ||
|
||
bool UnityTableEncoder::HasPrefix(const string& key) { | ||
return boost::starts_with(key, kEncodedPrefix); | ||
return strings::starts_with(key, kEncodedPrefix); | ||
} | ||
|
||
bool UnityTableEncoder::AddPrefix(string* key) { | ||
|