From ea477d6c5bfbffc5b3847f03e09c96cf386777fa Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Sat, 19 Feb 2022 10:22:24 -0800 Subject: [PATCH] Fix cpplint --- Source/Engine/Gramambular/Bigram.h | 4 ++-- Source/Engine/Gramambular/BlockReadingBuilder.h | 7 ++++--- Source/Engine/Gramambular/Gramambular.h | 4 ++-- Source/Engine/Gramambular/Grid.cpp | 6 +++--- Source/Engine/Gramambular/Grid.h | 7 ++++--- Source/Engine/Gramambular/KeyValuePair.h | 4 ++-- Source/Engine/Gramambular/LanguageModel.h | 5 +++-- Source/Engine/Gramambular/Node.h | 10 ++++++---- Source/Engine/Gramambular/NodeAnchor.h | 6 ++++-- Source/Engine/Gramambular/Span.h | 4 ++-- Source/Engine/Gramambular/Unigram.h | 4 ++-- Source/Engine/Gramambular/Walker.h | 7 ++++--- 12 files changed, 38 insertions(+), 30 deletions(-) diff --git a/Source/Engine/Gramambular/Bigram.h b/Source/Engine/Gramambular/Bigram.h index 1b30fc96..51b257d2 100644 --- a/Source/Engine/Gramambular/Bigram.h +++ b/Source/Engine/Gramambular/Bigram.h @@ -25,8 +25,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Bigram_h -#define Bigram_h +#ifndef BIGRAM_H_ +#define BIGRAM_H_ #include diff --git a/Source/Engine/Gramambular/BlockReadingBuilder.h b/Source/Engine/Gramambular/BlockReadingBuilder.h index dac88a12..5183df32 100644 --- a/Source/Engine/Gramambular/BlockReadingBuilder.h +++ b/Source/Engine/Gramambular/BlockReadingBuilder.h @@ -25,9 +25,10 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef BlockReadingBuilder_h -#define BlockReadingBuilder_h +#ifndef BLOCKREADINGBUILDER_H_ +#define BLOCKREADINGBUILDER_H_ +#include #include #include "Grid.h" @@ -38,7 +39,7 @@ namespace Gramambular { class BlockReadingBuilder { public: - BlockReadingBuilder(LanguageModel* lm); + explicit BlockReadingBuilder(LanguageModel* lm); void clear(); size_t length() const; diff --git a/Source/Engine/Gramambular/Gramambular.h b/Source/Engine/Gramambular/Gramambular.h index 1036ff70..ceaf7eab 100644 --- a/Source/Engine/Gramambular/Gramambular.h +++ b/Source/Engine/Gramambular/Gramambular.h @@ -25,8 +25,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Gramambular_h -#define Gramambular_h +#ifndef GRAMAMBULAR_H_ +#define GRAMAMBULAR_H_ #include "Bigram.h" #include "BlockReadingBuilder.h" diff --git a/Source/Engine/Gramambular/Grid.cpp b/Source/Engine/Gramambular/Grid.cpp index 2019e139..55011175 100644 --- a/Source/Engine/Gramambular/Grid.cpp +++ b/Source/Engine/Gramambular/Grid.cpp @@ -35,9 +35,9 @@ std::string Grid::dumpDOT() { sst << "graph [ rankdir=LR ];" << std::endl; sst << "BOS;" << std::endl; - for (unsigned long p = 0; p < m_spans.size(); p++) { + for (size_t p = 0; p < m_spans.size(); p++) { Span& span = m_spans[p]; - for (unsigned long ni = 0; ni <= span.maximumLength(); ni++) { + for (size_t ni = 0; ni <= span.maximumLength(); ni++) { Node* np = span.nodeOfLength(ni); if (np) { if (!p) { @@ -48,7 +48,7 @@ std::string Grid::dumpDOT() { if (p + ni < m_spans.size()) { Span& dstSpan = m_spans[p + ni]; - for (unsigned long q = 0; q <= dstSpan.maximumLength(); q++) { + for (size_t q = 0; q <= dstSpan.maximumLength(); q++) { Node* dn = dstSpan.nodeOfLength(q); if (dn) { sst << np->currentKeyValue().value << " -> " diff --git a/Source/Engine/Gramambular/Grid.h b/Source/Engine/Gramambular/Grid.h index 2653074a..b11add0a 100644 --- a/Source/Engine/Gramambular/Grid.h +++ b/Source/Engine/Gramambular/Grid.h @@ -25,10 +25,12 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Grid_h -#define Grid_h +#ifndef GRID_H_ +#define GRID_H_ #include +#include +#include #include "NodeAnchor.h" #include "Span.h" @@ -198,7 +200,6 @@ inline NodeAnchor Grid::fixNodeSelectedCandidate(size_t location, const_cast(nodeAnchor.node)->selectCandidateAtIndex(i); node = nodeAnchor; break; - ; } } } diff --git a/Source/Engine/Gramambular/KeyValuePair.h b/Source/Engine/Gramambular/KeyValuePair.h index 1059dfdc..ba33668a 100644 --- a/Source/Engine/Gramambular/KeyValuePair.h +++ b/Source/Engine/Gramambular/KeyValuePair.h @@ -25,8 +25,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef KeyValuePair_h -#define KeyValuePair_h +#ifndef KEYVALUEPAIR_H_ +#define KEYVALUEPAIR_H_ #include #include diff --git a/Source/Engine/Gramambular/LanguageModel.h b/Source/Engine/Gramambular/LanguageModel.h index 79ae6ee2..39b19823 100644 --- a/Source/Engine/Gramambular/LanguageModel.h +++ b/Source/Engine/Gramambular/LanguageModel.h @@ -25,9 +25,10 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef LanguageModel_h -#define LanguageModel_h +#ifndef LANGUAGEMODEL_H_ +#define LANGUAGEMODEL_H_ +#include #include #include "Bigram.h" diff --git a/Source/Engine/Gramambular/Node.h b/Source/Engine/Gramambular/Node.h index a442c77f..3059c64b 100644 --- a/Source/Engine/Gramambular/Node.h +++ b/Source/Engine/Gramambular/Node.h @@ -25,10 +25,12 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Node_h -#define Node_h +#ifndef NODE_H_ +#define NODE_H_ #include +#include +#include #include #include "LanguageModel.h" @@ -53,7 +55,7 @@ class Node { const std::string& key() const; double score() const; - double scoreForCandidate(std::string& candidate) const; + double scoreForCandidate(const std::string& candidate) const; const KeyValuePair currentKeyValue() const; double highestUnigramScore() const; @@ -190,7 +192,7 @@ inline const std::string& Node::key() const { return m_key; } inline double Node::score() const { return m_score; } -inline double Node::scoreForCandidate(std::string& candidate) const { +inline double Node::scoreForCandidate(const std::string& candidate) const { for (auto unigram : m_unigrams) { if (unigram.keyValue.value == candidate) { return unigram.score; diff --git a/Source/Engine/Gramambular/NodeAnchor.h b/Source/Engine/Gramambular/NodeAnchor.h index f2b4dfc8..3f81b4c2 100644 --- a/Source/Engine/Gramambular/NodeAnchor.h +++ b/Source/Engine/Gramambular/NodeAnchor.h @@ -25,8 +25,10 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef NodeAnchor_h -#define NodeAnchor_h +#ifndef NODEANCHOR_H_ +#define NODEANCHOR_H_ + +#include #include "Node.h" diff --git a/Source/Engine/Gramambular/Span.h b/Source/Engine/Gramambular/Span.h index 795c2a48..aa1cf38e 100644 --- a/Source/Engine/Gramambular/Span.h +++ b/Source/Engine/Gramambular/Span.h @@ -25,8 +25,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Span_h -#define Span_h +#ifndef SPAN_H_ +#define SPAN_H_ #include #include diff --git a/Source/Engine/Gramambular/Unigram.h b/Source/Engine/Gramambular/Unigram.h index df09cd0c..6cd546b3 100644 --- a/Source/Engine/Gramambular/Unigram.h +++ b/Source/Engine/Gramambular/Unigram.h @@ -25,8 +25,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Unigram_h -#define Unigram_h +#ifndef UNIGRAM_H_ +#define UNIGRAM_H_ #include diff --git a/Source/Engine/Gramambular/Walker.h b/Source/Engine/Gramambular/Walker.h index b35d2322..972214e3 100644 --- a/Source/Engine/Gramambular/Walker.h +++ b/Source/Engine/Gramambular/Walker.h @@ -25,10 +25,11 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#ifndef Walker_h -#define Walker_h +#ifndef WALKER_H_ +#define WALKER_H_ #include +#include #include "Grid.h" @@ -37,7 +38,7 @@ namespace Gramambular { class Walker { public: - Walker(Grid* inGrid); + explicit Walker(Grid* inGrid); const std::vector reverseWalk(size_t location, double accumulatedScore = 0.0);