Repo // Remove a useless namespace.

- The name "Taiyan" will be used as a new namespace instead.
- Mandarin and Gramambular modules (from libFormosana) will use their individual namespaces instead without a shared root namespace.
This commit is contained in:
ShikiSuen 2022-02-28 16:39:06 +08:00
parent a69d1ca9f7
commit 11be31f731
24 changed files with 100 additions and 113 deletions

View File

@ -22,7 +22,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include <algorithm>
#include <cctype>
namespace Taiyan {
namespace Mandarin {
class PinyinParseHelper {
@ -1034,5 +1033,5 @@ const BopomofoKeyboardLayout* BopomofoKeyboardLayout::HanyuPinyinLayout() {
}
} // namespace Mandarin
} // namespace Taiyan

View File

@ -25,7 +25,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include <string>
#include <vector>
namespace Taiyan {
namespace Mandarin {
class BopomofoSyllable {
@ -471,6 +470,6 @@ protected:
std::string pinyin_sequence_;
};
} // namespace Mandarin
} // namespace Taiyan
#endif // MANDARIN_H_

View File

@ -33,7 +33,7 @@ InputMode imeModeNULL = @"org.atelierInmu.inputmethod.vChewing.IMENULL";
static const double kEpsilon = 0.000001;
static double FindHighestScore(const std::vector<Taiyan::Gramambular::NodeAnchor> &nodes, double epsilon) {
static double FindHighestScore(const std::vector<Gramambular::NodeAnchor> &nodes, double epsilon) {
double highestScore = 0.0;
for (auto ni = nodes.begin(), ne = nodes.end(); ni != ne; ++ni) {
double score = ni->node->highestUnigramScore();
@ -46,7 +46,7 @@ static double FindHighestScore(const std::vector<Taiyan::Gramambular::NodeAnchor
class NodeAnchorDescendingSorter {
public:
bool operator()(const Taiyan::Gramambular::NodeAnchor &a, const Taiyan::Gramambular::NodeAnchor &b) const
bool operator()(const Gramambular::NodeAnchor &a, const Gramambular::NodeAnchor &b) const
{
return a.node->key().length() > b.node->key().length();
}
@ -62,7 +62,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
@implementation KeyHandler
{
// the reading buffer that takes user input
Taiyan::Mandarin::BopomofoReadingBuffer *_bpmfReadingBuffer;
Mandarin::BopomofoReadingBuffer *_bpmfReadingBuffer;
// language model
vChewing::LMInstantiator *_languageModel;
@ -71,10 +71,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
vChewing::UserOverrideModel *_userOverrideModel;
// the grid (lattice) builder for the unigrams (and bigrams)
Taiyan::Gramambular::BlockReadingBuilder *_builder;
Gramambular::BlockReadingBuilder *_builder;
// latest walked path (trellis) using the Viterbi algorithm
std::vector<Taiyan::Gramambular::NodeAnchor> _walkedNodes;
std::vector<Gramambular::NodeAnchor> _walkedNodes;
NSString *_inputMode;
}
@ -122,7 +122,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (_builder) {
delete _builder;
_builder = new Taiyan::Gramambular::BlockReadingBuilder(_languageModel);
_builder = new Gramambular::BlockReadingBuilder(_languageModel);
_builder->setJoinSeparator("-");
}
@ -148,7 +148,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
{
self = [super init];
if (self) {
_bpmfReadingBuffer = new Taiyan::Mandarin::BopomofoReadingBuffer(Taiyan::Mandarin::BopomofoKeyboardLayout::StandardLayout());
_bpmfReadingBuffer = new Mandarin::BopomofoReadingBuffer(Mandarin::BopomofoKeyboardLayout::StandardLayout());
// create the lattice builder
_languageModel = [mgrLangModel lmCHT];
@ -156,7 +156,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
_languageModel->setCNSEnabled(Preferences.cns11643Enabled);
_userOverrideModel = [mgrLangModel userOverrideModelCHT];
_builder = new Taiyan::Gramambular::BlockReadingBuilder(_languageModel);
_builder = new Gramambular::BlockReadingBuilder(_languageModel);
// each Mandarin syllable is separated by a hyphen
_builder->setJoinSeparator("-");
@ -170,31 +170,31 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
NSInteger layout = Preferences.keyboardLayout;
switch (layout) {
case KeyboardLayoutStandard:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::StandardLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout());
break;
case KeyboardLayoutEten:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::ETenLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::ETenLayout());
break;
case KeyboardLayoutHsu:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::HsuLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::HsuLayout());
break;
case KeyboardLayoutEten26:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::ETen26Layout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::ETen26Layout());
break;
case KeyboardLayoutIBM:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::IBMLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::IBMLayout());
break;
case KeyboardLayoutMiTAC:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::MiTACLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::MiTACLayout());
break;
case KeyboardLayoutFakeSeigyou:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::FakeSeigyouLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::FakeSeigyouLayout());
break;
case KeyboardLayoutHanyuPinyin:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::HanyuPinyinLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::HanyuPinyinLayout());
break;
default:
_bpmfReadingBuffer->setKeyboardLayout(Taiyan::Mandarin::BopomofoKeyboardLayout::StandardLayout());
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout());
Preferences.keyboardLayout = KeyboardLayoutStandard;
}
}
@ -203,7 +203,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
{
size_t cursorIndex = [self _actualCandidateCursorIndex];
std::string stringValue(value.UTF8String);
Taiyan::Gramambular::NodeAnchor selectedNode = _builder->grid().fixNodeSelectedCandidate(cursorIndex, stringValue);
Gramambular::NodeAnchor selectedNode = _builder->grid().fixNodeSelectedCandidate(cursorIndex, stringValue);
if (!Preferences.useSCPCTypingMode) { // 不要針對逐字選字模式啟用臨時半衰記憶模型。
// If the length of the readings and the characters do not match,
// it often means it is a special symbol and it should not be stored
@ -383,7 +383,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (!overrideValue.empty()) {
size_t cursorIndex = [self _actualCandidateCursorIndex];
std::vector<Taiyan::Gramambular::NodeAnchor> nodes = _builder->grid().nodesCrossingOrEndingAt(cursorIndex);
std::vector<Gramambular::NodeAnchor> nodes = _builder->grid().nodesCrossingOrEndingAt(cursorIndex);
double highestScore = FindHighestScore(nodes, kEpsilon);
_builder->grid().overrideNodeScoreForSelectedCandidate(cursorIndex, overrideValue, static_cast<float>(highestScore));
}
@ -1275,7 +1275,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// we must do some Unicode codepoint counting to find the actual cursor location for the client
// i.e. we need to take UTF-16 into consideration, for which a surrogate pair takes 2 UniChars
// locations
for (std::vector<Taiyan::Gramambular::NodeAnchor>::iterator wi = _walkedNodes.begin(), we = _walkedNodes.end(); wi != we; ++wi) {
for (std::vector<Gramambular::NodeAnchor>::iterator wi = _walkedNodes.begin(), we = _walkedNodes.end(); wi != we; ++wi) {
if ((*wi).node) {
std::string nodeStr = (*wi).node->currentKeyValue().value;
NSString *valueString = [NSString stringWithUTF8String:nodeStr.c_str()];
@ -1343,7 +1343,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// retrieve the most likely trellis, i.e. a Maximum Likelihood Estimation
// of the best possible Mandarain characters given the input syllables,
// using the Viterbi algorithm implemented in the Gramambular library
Taiyan::Gramambular::Walker walker(&_builder->grid());
Gramambular::Walker walker(&_builder->grid());
// the reverse walk traces the trellis from the end
_walkedNodes = walker.reverseWalk(_builder->grid().width());
@ -1376,7 +1376,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (_builder->grid().width() > (size_t) composingBufferSize) {
if (_walkedNodes.size() > 0) {
Taiyan::Gramambular::NodeAnchor &anchor = _walkedNodes[0];
Gramambular::NodeAnchor &anchor = _walkedNodes[0];
poppedText = [NSString stringWithUTF8String:anchor.node->currentKeyValue().value.c_str()];
_builder->removeHeadReadings(anchor.spanningLength);
}
@ -1391,15 +1391,15 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
NSMutableArray *candidatesArray = [[NSMutableArray alloc] init];
size_t cursorIndex = [self _actualCandidateCursorIndex];
std::vector<Taiyan::Gramambular::NodeAnchor> nodes = _builder->grid().nodesCrossingOrEndingAt(cursorIndex);
std::vector<Gramambular::NodeAnchor> nodes = _builder->grid().nodesCrossingOrEndingAt(cursorIndex);
// sort the nodes, so that longer nodes (representing longer phrases) are placed at the top of the candidate list
stable_sort(nodes.begin(), nodes.end(), NodeAnchorDescendingSorter());
// then use the C++ trick to retrieve the candidates for each node at/crossing the cursor
for (std::vector<Taiyan::Gramambular::NodeAnchor>::iterator ni = nodes.begin(), ne = nodes.end(); ni != ne; ++ni) {
const std::vector<Taiyan::Gramambular::KeyValuePair> &candidates = (*ni).node->candidates();
for (std::vector<Taiyan::Gramambular::KeyValuePair>::const_iterator ci = candidates.begin(), ce = candidates.end(); ci != ce; ++ci) {
for (std::vector<Gramambular::NodeAnchor>::iterator ni = nodes.begin(), ne = nodes.end(); ni != ne; ++ni) {
const std::vector<Gramambular::KeyValuePair> &candidates = (*ni).node->candidates();
for (std::vector<Gramambular::KeyValuePair>::const_iterator ci = candidates.begin(), ce = candidates.end(); ci != ce; ++ci) {
[candidatesArray addObject:[NSString stringWithUTF8String:(*ci).value.c_str()]];
}
}

View File

@ -32,7 +32,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
namespace vChewing {
using namespace Taiyan::Gramambular;
using namespace Gramambular;
/// LMInstantiator is a facade for managing a set of models including
/// the input method language model, user phrases and excluded phrases.
@ -56,7 +56,7 @@ using namespace Taiyan::Gramambular;
/// model while launching and to load the user phrases anytime if the custom
/// files are modified. It does not keep the reference of the data pathes but
/// you have to pass the paths when you ask it to do loading.
class LMInstantiator : public Taiyan::Gramambular::LanguageModel {
class LMInstantiator : public Gramambular::LanguageModel {
public:
LMInstantiator();
~LMInstantiator();
@ -97,11 +97,11 @@ public:
void loadPhraseReplacementMap(const char* phraseReplacementPath);
/// Not implemented since we do not have data to provide bigram function.
const std::vector<Taiyan::Gramambular::Bigram> bigramsForKeys(const std::string& preceedingKey, const std::string& key);
const std::vector<Gramambular::Bigram> bigramsForKeys(const std::string& preceedingKey, const std::string& key);
/// Returns a list of available unigram for the given key.
/// @param key A std::string represents the BPMF reading or a symbol key. For
/// example, it you pass "ㄇㄚ", it returns "嗎", "媽", and so on.
const std::vector<Taiyan::Gramambular::Unigram> unigramsForKey(const std::string& key);
const std::vector<Gramambular::Unigram> unigramsForKey(const std::string& key);
/// If the model has unigrams for the given key.
/// @param key The key.
bool hasUnigramsForKey(const std::string& key);
@ -135,7 +135,7 @@ protected:
/// @param insertedValues The values for unigrams already in the results.
/// It helps to prevent duplicated unigrams. Please note that the method
/// has a side effect that it inserts values to `insertedValues`.
const std::vector<Taiyan::Gramambular::Unigram> filterAndTransformUnigrams(const std::vector<Taiyan::Gramambular::Unigram> unigrams,
const std::vector<Gramambular::Unigram> filterAndTransformUnigrams(const std::vector<Gramambular::Unigram> unigrams,
const std::unordered_set<std::string>& excludedValues,
std::unordered_set<std::string>& insertedValues);

View File

@ -119,16 +119,16 @@ void LMInstantiator::loadPhraseReplacementMap(const char* phraseReplacementPath)
}
}
const std::vector<Taiyan::Gramambular::Bigram> LMInstantiator::bigramsForKeys(const std::string& preceedingKey, const std::string& key)
const std::vector<Gramambular::Bigram> LMInstantiator::bigramsForKeys(const std::string& preceedingKey, const std::string& key)
{
return std::vector<Taiyan::Gramambular::Bigram>();
return std::vector<Gramambular::Bigram>();
}
const std::vector<Taiyan::Gramambular::Unigram> LMInstantiator::unigramsForKey(const std::string& key)
const std::vector<Gramambular::Unigram> LMInstantiator::unigramsForKey(const std::string& key)
{
if (key == " ") {
std::vector<Taiyan::Gramambular::Unigram> spaceUnigrams;
Taiyan::Gramambular::Unigram g;
std::vector<Gramambular::Unigram> spaceUnigrams;
Gramambular::Unigram g;
g.keyValue.key = " ";
g.keyValue.value = " ";
g.score = 0;
@ -136,24 +136,24 @@ const std::vector<Taiyan::Gramambular::Unigram> LMInstantiator::unigramsForKey(c
return spaceUnigrams;
}
std::vector<Taiyan::Gramambular::Unigram> allUnigrams;
std::vector<Taiyan::Gramambular::Unigram> miscUnigrams;
std::vector<Taiyan::Gramambular::Unigram> symbolUnigrams;
std::vector<Taiyan::Gramambular::Unigram> userUnigrams;
std::vector<Taiyan::Gramambular::Unigram> cnsUnigrams;
std::vector<Gramambular::Unigram> allUnigrams;
std::vector<Gramambular::Unigram> miscUnigrams;
std::vector<Gramambular::Unigram> symbolUnigrams;
std::vector<Gramambular::Unigram> userUnigrams;
std::vector<Gramambular::Unigram> cnsUnigrams;
std::unordered_set<std::string> excludedValues;
std::unordered_set<std::string> insertedValues;
if (m_excludedPhrases.hasUnigramsForKey(key)) {
std::vector<Taiyan::Gramambular::Unigram> excludedUnigrams = m_excludedPhrases.unigramsForKey(key);
std::vector<Gramambular::Unigram> excludedUnigrams = m_excludedPhrases.unigramsForKey(key);
transform(excludedUnigrams.begin(), excludedUnigrams.end(),
inserter(excludedValues, excludedValues.end()),
[](const Taiyan::Gramambular::Unigram& u) { return u.keyValue.value; });
[](const Gramambular::Unigram& u) { return u.keyValue.value; });
}
if (m_userPhrases.hasUnigramsForKey(key)) {
std::vector<Taiyan::Gramambular::Unigram> rawUserUnigrams = m_userPhrases.unigramsForKey(key);
std::vector<Gramambular::Unigram> rawUserUnigrams = m_userPhrases.unigramsForKey(key);
// 用這句指令讓使用者語彙檔案內的詞條優先順序隨著行數增加而逐漸增高。
// 這樣一來就可以在就地新增語彙時徹底複寫優先權。
std::reverse(rawUserUnigrams.begin(), rawUserUnigrams.end());
@ -161,22 +161,22 @@ const std::vector<Taiyan::Gramambular::Unigram> LMInstantiator::unigramsForKey(c
}
if (m_languageModel.hasUnigramsForKey(key)) {
std::vector<Taiyan::Gramambular::Unigram> rawGlobalUnigrams = m_languageModel.unigramsForKey(key);
std::vector<Gramambular::Unigram> rawGlobalUnigrams = m_languageModel.unigramsForKey(key);
allUnigrams = filterAndTransformUnigrams(rawGlobalUnigrams, excludedValues, insertedValues);
}
if (m_miscModel.hasUnigramsForKey(key)) {
std::vector<Taiyan::Gramambular::Unigram> rawMiscUnigrams = m_miscModel.unigramsForKey(key);
std::vector<Gramambular::Unigram> rawMiscUnigrams = m_miscModel.unigramsForKey(key);
miscUnigrams = filterAndTransformUnigrams(rawMiscUnigrams, excludedValues, insertedValues);
}
if (m_symbolModel.hasUnigramsForKey(key)) {
std::vector<Taiyan::Gramambular::Unigram> rawSymbolUnigrams = m_symbolModel.unigramsForKey(key);
std::vector<Gramambular::Unigram> rawSymbolUnigrams = m_symbolModel.unigramsForKey(key);
symbolUnigrams = filterAndTransformUnigrams(rawSymbolUnigrams, excludedValues, insertedValues);
}
if (m_cnsModel.hasUnigramsForKey(key) && m_cnsEnabled) {
std::vector<Taiyan::Gramambular::Unigram> rawCNSUnigrams = m_cnsModel.unigramsForKey(key);
std::vector<Gramambular::Unigram> rawCNSUnigrams = m_cnsModel.unigramsForKey(key);
cnsUnigrams = filterAndTransformUnigrams(rawCNSUnigrams, excludedValues, insertedValues);
}
@ -234,9 +234,9 @@ void LMInstantiator::setExternalConverter(std::function<std::string(std::string)
m_externalConverter = externalConverter;
}
const std::vector<Taiyan::Gramambular::Unigram> LMInstantiator::filterAndTransformUnigrams(const std::vector<Taiyan::Gramambular::Unigram> unigrams, const std::unordered_set<std::string>& excludedValues, std::unordered_set<std::string>& insertedValues)
const std::vector<Gramambular::Unigram> LMInstantiator::filterAndTransformUnigrams(const std::vector<Gramambular::Unigram> unigrams, const std::unordered_set<std::string>& excludedValues, std::unordered_set<std::string>& insertedValues)
{
std::vector<Taiyan::Gramambular::Unigram> results;
std::vector<Gramambular::Unigram> results;
for (auto&& unigram : unigrams) {
// excludedValues filters out the unigrams with the original value.
@ -258,7 +258,7 @@ const std::vector<Taiyan::Gramambular::Unigram> LMInstantiator::filterAndTransfo
value = replacement;
}
if (insertedValues.find(value) == insertedValues.end()) {
Taiyan::Gramambular::Unigram g;
Gramambular::Unigram g;
g.keyValue.value = value;
g.keyValue.key = unigram.keyValue.key;
g.score = unigram.score;

View File

@ -31,11 +31,11 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
// to avoid creating new string objects; the parser is a simple DFA
using namespace std;
using namespace Taiyan::Gramambular;
using namespace Gramambular;
namespace vChewing {
class CoreLM : public Taiyan::Gramambular::LanguageModel {
class CoreLM : public Gramambular::LanguageModel {
public:
CoreLM();
~CoreLM();
@ -45,8 +45,8 @@ public:
void close();
void dump();
virtual const std::vector<Taiyan::Gramambular::Bigram> bigramsForKeys(const string& preceedingKey, const string& key);
virtual const std::vector<Taiyan::Gramambular::Unigram> unigramsForKey(const string& key);
virtual const std::vector<Gramambular::Bigram> bigramsForKeys(const string& preceedingKey, const string& key);
virtual const std::vector<Gramambular::Unigram> unigramsForKey(const string& key);
virtual bool hasUnigramsForKey(const string& key);
protected:

View File

@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include <unistd.h>
#include <syslog.h>
using namespace Taiyan::Gramambular;
using namespace Gramambular;
vChewing::CoreLM::CoreLM()
: fd(-1)
@ -292,14 +292,14 @@ void vChewing::CoreLM::dump()
}
}
const std::vector<Taiyan::Gramambular::Bigram> vChewing::CoreLM::bigramsForKeys(const string& preceedingKey, const string& key)
const std::vector<Gramambular::Bigram> vChewing::CoreLM::bigramsForKeys(const string& preceedingKey, const string& key)
{
return std::vector<Taiyan::Gramambular::Bigram>();
return std::vector<Gramambular::Bigram>();
}
const std::vector<Taiyan::Gramambular::Unigram> vChewing::CoreLM::unigramsForKey(const string& key)
const std::vector<Gramambular::Unigram> vChewing::CoreLM::unigramsForKey(const string& key)
{
std::vector<Taiyan::Gramambular::Unigram> v;
std::vector<Gramambular::Unigram> v;
map<const char *, vector<Row> >::const_iterator i = keyRowMap.find(key.c_str());
if (i != keyRowMap.end()) {

View File

@ -80,23 +80,23 @@ void vChewing::ParselessLM::close()
}
}
const std::vector<Taiyan::Gramambular::Bigram>
const std::vector<Gramambular::Bigram>
vChewing::ParselessLM::bigramsForKeys(
const std::string& preceedingKey, const std::string& key)
{
return std::vector<Taiyan::Gramambular::Bigram>();
return std::vector<Gramambular::Bigram>();
}
const std::vector<Taiyan::Gramambular::Unigram>
const std::vector<Gramambular::Unigram>
vChewing::ParselessLM::unigramsForKey(const std::string& key)
{
if (db_ == nullptr) {
return std::vector<Taiyan::Gramambular::Unigram>();
return std::vector<Gramambular::Unigram>();
}
std::vector<Taiyan::Gramambular::Unigram> results;
std::vector<Gramambular::Unigram> results;
for (const auto& row : db_->findRows(key + " ")) {
Taiyan::Gramambular::Unigram unigram;
Gramambular::Unigram unigram;
// Move ahead until we encounter the first space. This is the key.
auto it = row.begin();

View File

@ -29,7 +29,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
namespace vChewing {
class ParselessLM : public Taiyan::Gramambular::LanguageModel {
class ParselessLM : public Gramambular::LanguageModel {
public:
~ParselessLM() override;
@ -37,9 +37,9 @@ public:
bool open(const std::string_view& path);
void close();
const std::vector<Taiyan::Gramambular::Bigram> bigramsForKeys(
const std::vector<Gramambular::Bigram> bigramsForKeys(
const std::string& preceedingKey, const std::string& key) override;
const std::vector<Taiyan::Gramambular::Unigram> unigramsForKey(
const std::vector<Gramambular::Unigram> unigramsForKey(
const std::string& key) override;
bool hasUnigramsForKey(const std::string& key) override;

View File

@ -34,7 +34,7 @@ static double Score(size_t eventCount,
double timestamp,
double lambda);
static bool IsEndingPunctuation(const std::string& value);
static std::string WalkedNodesToKey(const std::vector<Taiyan::Gramambular::NodeAnchor>& walkedNodes,
static std::string WalkedNodesToKey(const std::vector<Gramambular::NodeAnchor>& walkedNodes,
size_t cursorIndex);
UserOverrideModel::UserOverrideModel(size_t capacity, double decayConstant)
@ -43,7 +43,7 @@ UserOverrideModel::UserOverrideModel(size_t capacity, double decayConstant)
m_decayExponent = log(0.5) / decayConstant;
}
void UserOverrideModel::observe(const std::vector<Taiyan::Gramambular::NodeAnchor>& walkedNodes,
void UserOverrideModel::observe(const std::vector<Gramambular::NodeAnchor>& walkedNodes,
size_t cursorIndex,
const std::string& candidate,
double timestamp) {
@ -76,7 +76,7 @@ void UserOverrideModel::observe(const std::vector<Taiyan::Gramambular::NodeAncho
}
}
std::string UserOverrideModel::suggest(const std::vector<Taiyan::Gramambular::NodeAnchor>& walkedNodes,
std::string UserOverrideModel::suggest(const std::vector<Gramambular::NodeAnchor>& walkedNodes,
size_t cursorIndex,
double timestamp) {
std::string key = WalkedNodesToKey(walkedNodes, cursorIndex);
@ -138,12 +138,12 @@ static bool IsEndingPunctuation(const std::string& value) {
return value == "" || value == "" || value== "" || value == "" ||
value == "" || value == "" || value== "" || value == "";
}
static std::string WalkedNodesToKey(const std::vector<Taiyan::Gramambular::NodeAnchor>& walkedNodes,
static std::string WalkedNodesToKey(const std::vector<Gramambular::NodeAnchor>& walkedNodes,
size_t cursorIndex) {
std::stringstream s;
std::vector<Taiyan::Gramambular::NodeAnchor> n;
std::vector<Gramambular::NodeAnchor> n;
size_t ll = 0;
for (std::vector<Taiyan::Gramambular::NodeAnchor>::const_iterator i = walkedNodes.begin();
for (std::vector<Gramambular::NodeAnchor>::const_iterator i = walkedNodes.begin();
i != walkedNodes.end();
++i) {
const auto& nn = *i;
@ -154,7 +154,7 @@ static std::string WalkedNodesToKey(const std::vector<Taiyan::Gramambular::NodeA
}
}
std::vector<Taiyan::Gramambular::NodeAnchor>::const_reverse_iterator r = n.rbegin();
std::vector<Gramambular::NodeAnchor>::const_reverse_iterator r = n.rbegin();
if (r == n.rend()) {
return "";

View File

@ -27,18 +27,18 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
namespace vChewing {
using namespace Taiyan::Gramambular;
using namespace Gramambular;
class UserOverrideModel {
public:
UserOverrideModel(size_t capacity, double decayConstant);
void observe(const std::vector<Taiyan::Gramambular::NodeAnchor>& walkedNodes,
void observe(const std::vector<Gramambular::NodeAnchor>& walkedNodes,
size_t cursorIndex,
const std::string& candidate,
double timestamp);
std::string suggest(const std::vector<Taiyan::Gramambular::NodeAnchor>& walkedNodes,
std::string suggest(const std::vector<Gramambular::NodeAnchor>& walkedNodes,
size_t cursorIndex,
double timestamp);

View File

@ -27,7 +27,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
namespace vChewing {
class UserPhrasesLM : public Taiyan::Gramambular::LanguageModel
class UserPhrasesLM : public Gramambular::LanguageModel
{
public:
UserPhrasesLM();
@ -46,8 +46,8 @@ public:
return 0.0;
}
virtual const std::vector<Taiyan::Gramambular::Bigram> bigramsForKeys(const std::string& preceedingKey, const std::string& key);
virtual const std::vector<Taiyan::Gramambular::Unigram> unigramsForKey(const std::string& key);
virtual const std::vector<Gramambular::Bigram> bigramsForKeys(const std::string& preceedingKey, const std::string& key);
virtual const std::vector<Gramambular::Unigram> unigramsForKey(const std::string& key);
virtual bool hasUnigramsForKey(const std::string& key);
protected:

View File

@ -121,19 +121,19 @@ void UserPhrasesLM::dump()
}
}
const std::vector<Taiyan::Gramambular::Bigram> UserPhrasesLM::bigramsForKeys(const std::string& preceedingKey, const std::string& key)
const std::vector<Gramambular::Bigram> UserPhrasesLM::bigramsForKeys(const std::string& preceedingKey, const std::string& key)
{
return std::vector<Taiyan::Gramambular::Bigram>();
return std::vector<Gramambular::Bigram>();
}
const std::vector<Taiyan::Gramambular::Unigram> UserPhrasesLM::unigramsForKey(const std::string& key)
const std::vector<Gramambular::Unigram> UserPhrasesLM::unigramsForKey(const std::string& key)
{
std::vector<Taiyan::Gramambular::Unigram> v;
std::vector<Gramambular::Unigram> v;
auto iter = keyRowMap.find(key);
if (iter != keyRowMap.end()) {
const std::vector<Row>& rows = iter->second;
for (const auto& row : rows) {
Taiyan::Gramambular::Unigram g;
Gramambular::Unigram g;
g.keyValue.key = row.key;
g.keyValue.value = row.value;
g.score = overridedValue();

View File

@ -24,7 +24,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "KeyValuePair.h"
namespace Taiyan {
namespace Gramambular {
class Bigram {
public:
@ -88,6 +87,6 @@ inline bool Bigram::operator<(const Bigram& another) const {
return false;
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -26,7 +26,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "Grid.h"
#include "LanguageModel.h"
namespace Taiyan {
namespace Gramambular {
class BlockReadingBuilder {
@ -201,6 +200,6 @@ inline const std::string BlockReadingBuilder::Join(
return result;
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -27,7 +27,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "NodeAnchor.h"
#include "Span.h"
namespace Taiyan {
namespace Gramambular {
class Grid {
@ -218,6 +217,6 @@ inline void Grid::overrideNodeScoreForSelectedCandidate(
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -22,7 +22,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include <iostream>
#include <string>
namespace Taiyan {
namespace Gramambular {
std::string Grid::dumpDOT() {
@ -67,4 +66,4 @@ std::string Grid::dumpDOT() {
}
} // namespace Gramambular
} // namespace Taiyan

View File

@ -23,7 +23,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include <ostream>
#include <string>
namespace Taiyan {
namespace Gramambular {
class KeyValuePair {
@ -54,6 +53,6 @@ inline bool KeyValuePair::operator<(const KeyValuePair& another) const {
return false;
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -26,7 +26,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "Bigram.h"
#include "Unigram.h"
namespace Taiyan {
namespace Gramambular {
class LanguageModel {
@ -39,6 +38,6 @@ public:
virtual bool hasUnigramsForKey(const std::string& key) = 0;
};
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -27,7 +27,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "LanguageModel.h"
namespace Taiyan {
namespace Gramambular {
class Node {
@ -209,6 +208,6 @@ inline const KeyValuePair Node::currentKeyValue() const {
}
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -24,7 +24,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "Node.h"
namespace Taiyan {
namespace Gramambular {
struct NodeAnchor {
@ -59,6 +58,6 @@ inline std::ostream& operator<<(std::ostream& stream,
return stream;
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -26,7 +26,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "Node.h"
namespace Taiyan {
namespace Gramambular {
class Span {
public:
@ -88,6 +87,6 @@ inline Node* Span::nodeOfLength(size_t length) {
inline size_t Span::maximumLength() const { return m_maximumLength; }
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -24,7 +24,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "KeyValuePair.h"
namespace Taiyan {
namespace Gramambular {
class Unigram {
@ -86,6 +85,6 @@ inline bool Unigram::ScoreCompare(const Unigram& a, const Unigram& b) {
return a.score > b.score;
}
} // namespace Gramambular
} // namespace Taiyan
#endif

View File

@ -25,7 +25,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "Grid.h"
namespace Taiyan {
namespace Gramambular {
class Walker {
@ -80,6 +79,6 @@ inline const std::vector<NodeAnchor> Walker::reverseWalk(
return *result;
}
} // namespace Gramambular
} // namespace Taiyan
#endif