Compiler warnings, rename to ${binary}_main.cc

This commit is contained in:
Kenneth Heafield 2013-01-20 13:43:19 +00:00
parent a52d97f99f
commit cfe7d00ea2
11 changed files with 25 additions and 21 deletions

View File

@ -13,17 +13,17 @@ update-if-changed $(ORDER-LOG) $(max-order) ;
max-order += <dependency>$(ORDER-LOG) ;
fakelib kenlm : bhiksha.cc binary_format.cc config.cc lm_exception.cc model.cc quantize.cc read_arpa.cc search_hashed.cc search_trie.cc sizes.cc trie.cc trie_sort.cc value_build.cc virtual_interface.cc vocab.cc ../util//kenutil : <include>.. $(max-order) : : <include>.. $(max-order) ;
fakelib kenlm : [ glob *.cc : *main.cc *test.cc ] ../util//kenutil : <include>.. $(max-order) : : <include>.. $(max-order) ;
import testing ;
run left_test.cc ../util//kenutil kenlm /top//boost_unit_test_framework : : test.arpa ;
run model_test.cc ../util//kenutil kenlm /top//boost_unit_test_framework : : test.arpa test_nounk.arpa ;
run partial_test.cc ../util//kenutil kenlm /top//boost_unit_test_framework : : test.arpa ;
run left_test.cc kenlm /top//boost_unit_test_framework : : test.arpa ;
run model_test.cc kenlm /top//boost_unit_test_framework : : test.arpa test_nounk.arpa ;
run partial_test.cc kenlm /top//boost_unit_test_framework : : test.arpa ;
exe query : ngram_query.cc kenlm ../util//kenutil ;
exe build_binary : build_binary.cc kenlm ../util//kenutil ;
exe kenlm_max_order : max_order.cc : <include>.. $(max-order) ;
exe fragment : fragment.cc kenlm ;
exe query : query_main.cc kenlm ../util//kenutil ;
exe build_binary : build_binary_main.cc kenlm ../util//kenutil ;
exe kenlm_max_order : kenlm_max_order_main.cc : <include>.. $(max-order) ;
exe fragment : fragment_main.cc kenlm ;
alias programs : query build_binary kenlm_max_order fragment filter//filter : <threading>multi:<source>builder//lmplz ;

View File

@ -1,8 +1,8 @@
fakelib builder : corpus_count.cc adjust_counts.cc initial_probabilities.cc interpolate.cc pipeline.cc print.cc
fakelib builder : [ glob *.cc : *test.cc *main.cc ]
../../util//kenutil ../../util/stream//stream ../../util/double-conversion//double-conversion ..//kenlm
: : : <library>/top//boost_thread $(timer-link) ;
exe lmplz : main.cc builder /top//boost_program_options ;
exe lmplz : lmplz_main.cc builder /top//boost_program_options ;
import testing ;
unit-test corpus_count_test : corpus_count_test.cc builder /top//boost_unit_test_framework ;

View File

@ -1,5 +1,5 @@
fakelib lm_filter : phrase.cc vocab.cc arpa_io.cc ../../util//kenutil : <threading>multi:<library>/top//boost_thread ;
obj main : main.cc : <threading>single:<define>NTHREAD <include>../.. ;
obj main : filter_main.cc : <threading>single:<define>NTHREAD <include>../.. ;
exe filter : main lm_filter ../../util//kenutil ..//kenlm : <threading>multi:<library>/top//boost_thread ;

View File

@ -53,7 +53,7 @@ void DisplayHelp(const char *name) {
" stream i.e. /dev/stdout\n";
}
typedef enum {MODE_COPY, MODE_SINGLE, MODE_MULTIPLE, MODE_UNION} FilterMode;
typedef enum {MODE_COPY, MODE_SINGLE, MODE_MULTIPLE, MODE_UNION, MODE_UNSET} FilterMode;
typedef enum {FORMAT_ARPA, FORMAT_COUNT} Format;
struct Config {
@ -162,19 +162,19 @@ int main(int argc, char *argv[]) {
return 1;
}
// I used to have boost::program_options, but some users didn't want to compile boost.
// I used to have boost::program_options, but some users didn't want to compile boost.
lm::Config config;
boost::optional<lm::FilterMode> mode;
config.mode = lm::MODE_UNSET;
for (int i = 1; i < argc - 2; ++i) {
const char *str = argv[i];
if (!std::strcmp(str, "copy")) {
mode = lm::MODE_COPY;
config.mode = lm::MODE_COPY;
} else if (!std::strcmp(str, "single")) {
mode = lm::MODE_SINGLE;
config.mode = lm::MODE_SINGLE;
} else if (!std::strcmp(str, "multiple")) {
mode = lm::MODE_MULTIPLE;
config.mode = lm::MODE_MULTIPLE;
} else if (!std::strcmp(str, "union")) {
mode = lm::MODE_UNION;
config.mode = lm::MODE_UNION;
} else if (!std::strcmp(str, "phrase")) {
config.phrase = true;
} else if (!std::strcmp(str, "context")) {
@ -203,13 +203,12 @@ int main(int argc, char *argv[]) {
}
}
if (!mode) {
if (config.mode == lm::MODE_UNSET) {
lm::DisplayHelp(argv[0]);
return 1;
}
config.mode = *mode;
if (config.phrase && config.mode != lm::MODE_UNION && mode != lm::MODE_MULTIPLE) {
if (config.phrase && config.mode != lm::MODE_UNION && config.mode != lm::MODE_MULTIPLE) {
std::cerr << "Phrase constraint currently only works in multiple or union mode. If you really need it for single, put everything on one line and use union." << std::endl;
return 1;
}

View File

@ -57,6 +57,7 @@ class Substrings {
LM_FILTER_PHRASE_METHOD(Right, right)
LM_FILTER_PHRASE_METHOD(Phrase, phrase)
#pragma GCC diagnostic ignored "-Wuninitialized" // end != finish so there's always an initialization
// sentence_id must be non-decreasing. Iterators are over words in the phrase.
template <class Iterator> void AddPhrase(unsigned int sentence_id, const Iterator &begin, const Iterator &end) {
// Iterate over all substrings.

View File

@ -506,7 +506,9 @@ float Strtof(Vector<const char> buffer, int exponent) {
double double_previous = Double(double_guess).PreviousDouble();
float f1 = static_cast<float>(double_previous);
#ifndef NDEBUG
float f2 = float_guess;
#endif
float f3 = static_cast<float>(double_next);
float f4;
if (is_correct) {
@ -515,7 +517,9 @@ float Strtof(Vector<const char> buffer, int exponent) {
double double_next2 = Double(double_next).NextDouble();
f4 = static_cast<float>(double_next2);
}
#ifndef NDEBUG
ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4);
#endif
// If the guess doesn't lie near a single-precision boundary we can simply
// return its float-value.