-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(algo, dict, translators): use logarithmic weights internally
- Loading branch information
Showing
20 changed files
with
69 additions
and
64 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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
// 2011-11-27 GONG Chen <[email protected]> | ||
// | ||
#include <boost/filesystem.hpp> | ||
#include <cfloat> | ||
#include <fstream> | ||
#include <rime/algo/algebra.h> | ||
#include <rime/algo/utilities.h> | ||
|
@@ -176,7 +177,7 @@ bool DictCompiler::BuildTable(DictSettings* settings, | |
auto e = New<DictEntry>(); | ||
e->code.swap(code); | ||
e->text.swap(r.text); | ||
e->weight = r.weight; | ||
e->weight = log(r.weight > 0 ? r.weight : DBL_EPSILON); | ||
ls->push_back(e); | ||
} | ||
if (settings->sort_order() != "original") { | ||
|
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
// 2011-10-30 GONG Chen <[email protected]> | ||
// | ||
#include <algorithm> | ||
#include <cfloat> | ||
#include <boost/algorithm/string.hpp> | ||
#include <boost/lexical_cast.hpp> | ||
#include <boost/scope_exit.hpp> | ||
|
@@ -225,7 +226,7 @@ void UserDictionary::DfsLookup(const SyllableGraph& syll_graph, | |
if (i > 0 && props->type >= kAbbreviation) | ||
continue; | ||
state->credibility.push_back( | ||
state->credibility.back() * props->credibility); | ||
state->credibility.back() + props->credibility); | ||
BOOST_SCOPE_EXIT( (&state) ) { | ||
state->credibility.pop_back(); | ||
} | ||
|
@@ -479,10 +480,11 @@ an<DictEntry> UserDictionary::CreateDictEntry(const string& key, | |
e->text = key.substr(separator_pos + 1); | ||
e->commit_count = v.commits; | ||
// TODO: argument s not defined... | ||
e->weight = algo::formula_p(0, | ||
(double)v.commits / present_tick, | ||
(double)present_tick, | ||
v.dee) * credibility; | ||
double weight = algo::formula_p(0, | ||
(double)v.commits / present_tick, | ||
(double)present_tick, | ||
v.dee); | ||
e->weight = log(weight > 0 ? weight : DBL_EPSILON) + credibility; | ||
if (full_code) { | ||
*full_code = key.substr(0, separator_pos); | ||
} | ||
|
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
Oops, something went wrong.