implement a converter from aprob to bmap

This commit is contained in:
falsycat 2022-10-10 22:39:58 +09:00
parent 83ee7f5f1e
commit 4ddd15f34e
2 changed files with 61 additions and 0 deletions

View File

@ -1,3 +1,4 @@
# ---- main procedural
add_executable(dcode_feat common.hh dcode_feat.cc)
target_link_libraries(dcode_feat PRIVATE args)
@ -18,3 +19,8 @@ target_link_libraries(fprob_feat PRIVATE args)
add_executable(feat_dcode common.hh feat_dcode.cc)
target_link_libraries(feat_dcode PRIVATE args)
# ---- procedural of preprocessing
add_executable(aprob_bmap common.hh aprob_bmap.cc)
target_link_libraries(aprob_bmap PRIVATE args)

55
conv/aprob_bmap.cc Normal file
View File

@ -0,0 +1,55 @@
#include <fstream>
#include <iostream>
#include <string>
#include <args.hxx>
#include "common.hh"
namespace param {
using namespace ::args;
ArgumentParser parser {
"converter: aprob -> bmap"
};
HelpFlag help {
parser, "help", "display this menu", {'h', "help"},
};
ValueFlag<double> min {
parser, "0.2", "minimum alter-probability to select", {"min"}, 0.4,
};
ValueFlag<double> max {
parser, "0.6", "maximum alter-probability to select", {"max"}, 0.6,
};
} // namespace param
static void Exec() {
const auto aprob = ReadMatrix<double>(std::cin);
for (auto& probs : aprob) {
for (size_t i = 0; i < probs.size(); ++i) {
if (args::get(param::min) <= probs[i] && probs[i] <= args::get(param::max)) {
std::cout << i << ' ';
}
}
std::cout << '\n';
}
}
int main(int argc, char** argv)
try {
param::parser.ParseCLI(argc, argv);
Exec();
return EXIT_SUCCESS;
} catch (const args::Help&) {
std::cout << param::parser << std::endl;
return EXIT_SUCCESS;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}