Skip to content

Commit

Permalink
C++ coding style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukhnos committed Jan 15, 2024
1 parent 2bc1b0a commit dc133de
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 106 deletions.
4 changes: 2 additions & 2 deletions src/Engine/McBopomofoLM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ bool McBopomofoLM::externalConverterEnabled() const
return m_externalConverterEnabled;
}

void McBopomofoLM::setExternalConverter(std::function<std::string(std::string)> externalConverter)
void McBopomofoLM::setExternalConverter(std::function<std::string(const std::string&)> externalConverter)
{
m_externalConverter = externalConverter;
}

void McBopomofoLM::setMacroConverter(std::function<std::string(std::string)> macroConverter)
void McBopomofoLM::setMacroConverter(std::function<std::string(const std::string&)> macroConverter)
{
m_macroConverter = macroConverter;
}
Expand Down
19 changes: 10 additions & 9 deletions src/Engine/McBopomofoLM.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
#ifndef SRC_ENGINE_MCBOPOMOFOLM_H_
#define SRC_ENGINE_MCBOPOMOFOLM_H_

#include "AssociatedPhrases.h"
#include "ParselessLM.h"
#include "PhraseReplacementMap.h"
#include "UserPhrasesLM.h"
#include "gramambular2/language_model.h"
#include <cstdio>
#include <functional>
#include <string>
#include <unordered_set>
#include <vector>

#include "AssociatedPhrases.h"
#include "ParselessLM.h"
#include "PhraseReplacementMap.h"
#include "UserPhrasesLM.h"
#include "gramambular2/language_model.h"

namespace McBopomofo {

/// McBopomofoLM is a facade for managing a set of models including
Expand Down Expand Up @@ -102,10 +103,10 @@ class McBopomofoLM : public Formosa::Gramambular2::LanguageModel {
/// If the external converted is enabled or not.
bool externalConverterEnabled() const;
/// Sets a lambda to let the values of unigrams could be converted by it.
void setExternalConverter(std::function<std::string(std::string)> externalConverter);
void setExternalConverter(std::function<std::string(const std::string&)> externalConverter);

/// Sets a lambda to convert the macro to a string.
void setMacroConverter(std::function<std::string(std::string)> macroConverter);
void setMacroConverter(std::function<std::string(const std::string&)> macroConverter);

const std::vector<std::string> associatedPhrasesForKey(const std::string& key);
bool hasAssociatedPhrasesForKey(const std::string& key);
Expand All @@ -130,10 +131,10 @@ class McBopomofoLM : public Formosa::Gramambular2::LanguageModel {
UserPhrasesLM m_excludedPhrases;
PhraseReplacementMap m_phraseReplacement;
AssociatedPhrases m_associatedPhrases;
std::function<std::string(std::string)> m_macroConverter;
std::function<std::string(const std::string&)> m_macroConverter;
bool m_phraseReplacementEnabled;
bool m_externalConverterEnabled;
std::function<std::string(std::string)> m_externalConverter;
std::function<std::string(const std::string&)> m_externalConverter;
};
} // namespace McBopomofo

Expand Down
Loading

0 comments on commit dc133de

Please # to comment.