mirror of
https://github.com/google/sentencepiece.git
synced 2024-09-11 10:55:42 +03:00
Renamed VERSION to VERSION.txt. Remove the dependency to absl::Flags from so library.
This commit is contained in:
parent
8336bbd0c1
commit
308d9bf37f
@ -13,7 +13,7 @@
|
||||
# limitations under the License.!
|
||||
|
||||
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
||||
file(STRINGS "VERSION" SPM_VERSION)
|
||||
file(STRINGS "VERSION.txt" SPM_VERSION)
|
||||
message(STATUS "VERSION: ${SPM_VERSION}")
|
||||
project(sentencepiece VERSION ${SPM_VERSION} LANGUAGES C CXX)
|
||||
|
||||
|
@ -33,7 +33,7 @@ def long_description():
|
||||
|
||||
|
||||
def version():
|
||||
with codecs.open('VERSION', 'r', 'utf-8') as f:
|
||||
with codecs.open('VERSION.txt', 'r', 'utf-8') as f:
|
||||
version = f.read().rstrip()
|
||||
return version
|
||||
|
||||
|
@ -132,6 +132,9 @@ enum LogSeverity {
|
||||
LOG_SEVERITY_SIZE = 4,
|
||||
};
|
||||
|
||||
int GetMinLogLevel();
|
||||
void SetMinLogLevel(int v);
|
||||
|
||||
inline const char *BaseName(const char *path) {
|
||||
#ifdef OS_WIN
|
||||
const char *p = strrchr(path, '\\');
|
||||
@ -144,10 +147,8 @@ inline const char *BaseName(const char *path) {
|
||||
} // namespace logging
|
||||
} // namespace sentencepiece
|
||||
|
||||
ABSL_DECLARE_FLAG(int32, minloglevel);
|
||||
|
||||
#define LOG(severity) \
|
||||
(absl::GetFlag(FLAGS_minloglevel) > \
|
||||
(::sentencepiece::logging::GetMinLogLevel() > \
|
||||
::sentencepiece::logging::LOG_##severity) \
|
||||
? 0 \
|
||||
: ::sentencepiece::error::Die( \
|
||||
|
@ -14,8 +14,11 @@
|
||||
|
||||
#include "init.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "third_party/absl/flags/flag.h"
|
||||
|
||||
ABSL_DECLARE_FLAG(int32, minloglevel);
|
||||
|
||||
namespace sentencepiece {
|
||||
|
||||
void ParseCommandLineFlags(const char *usage, int *argc, char ***argv,
|
||||
@ -28,5 +31,7 @@ void ParseCommandLineFlags(const char *usage, int *argc, char ***argv,
|
||||
std::copy(unused_args.begin(), unused_args.end(), argv_val);
|
||||
*argc = static_cast<int>(unused_args.size());
|
||||
}
|
||||
|
||||
logging::SetMinLogLevel(absl::GetFlag(FLAGS_minloglevel));
|
||||
}
|
||||
} // namespace sentencepiece
|
||||
|
@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.!
|
||||
|
||||
#include "sentencepiece_trainer.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -20,9 +22,7 @@
|
||||
#include "normalizer.h"
|
||||
#include "sentencepiece.pb.h"
|
||||
#include "sentencepiece_model.pb.h"
|
||||
#include "sentencepiece_trainer.h"
|
||||
#include "spec_parser.h"
|
||||
#include "third_party/absl/flags/flag.h"
|
||||
#include "third_party/absl/strings/numbers.h"
|
||||
#include "third_party/absl/strings/str_cat.h"
|
||||
#include "third_party/absl/strings/str_split.h"
|
||||
@ -31,8 +31,6 @@
|
||||
#include "trainer_factory.h"
|
||||
#include "util.h"
|
||||
|
||||
ABSL_DECLARE_FLAG(int, minloglevel);
|
||||
|
||||
namespace sentencepiece {
|
||||
namespace {
|
||||
static constexpr char kDefaultNormalizerName[] = "nmt_nfkc";
|
||||
@ -151,7 +149,7 @@ util::Status SentencePieceTrainer::MergeSpecsFromArgs(
|
||||
} else if (key == "minloglevel") {
|
||||
int v = 0;
|
||||
CHECK_OR_RETURN(absl::SimpleAtoi(value, &v));
|
||||
absl::SetFlag(&FLAGS_minloglevel, v);
|
||||
logging::SetMinLogLevel(v);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace sentencepiece {
|
||||
namespace {
|
||||
constexpr unsigned int kDefaultSeed = static_cast<unsigned int>(-1);
|
||||
static unsigned int g_seed = kDefaultSeed;
|
||||
static int g_minloglevel = 0;
|
||||
} // namespace
|
||||
|
||||
void SetRandomGeneratorSeed(unsigned int seed) {
|
||||
@ -30,6 +31,11 @@ uint32 GetRandomGeneratorSeed() {
|
||||
return g_seed == kDefaultSeed ? std::random_device{}() : g_seed;
|
||||
}
|
||||
|
||||
namespace logging {
|
||||
int GetMinLogLevel() { return g_minloglevel; }
|
||||
void SetMinLogLevel(int v) { g_minloglevel = v; }
|
||||
} // namespace logging
|
||||
|
||||
namespace string_util {
|
||||
|
||||
// mblen sotres the number of bytes consumed after decoding.
|
||||
|
Loading…
Reference in New Issue
Block a user