diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-05-13 13:35:03 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-05-13 13:35:03 +0800 |
commit | 20587ac550cfcb2d7b3d6ec16e46ba1a8d0af869 (patch) | |
tree | 8da41db1cef2bcedadeb5769832d95c45ffb7f13 /split.cpp | |
parent | 62b6b42e27a4972397e94fdbb03e74ac3f5f1244 (diff) | |
download | ranksvm-20587ac550cfcb2d7b3d6ec16e46ba1a8d0af869.tar.gz ranksvm-20587ac550cfcb2d7b3d6ec16e46ba1a8d0af869.tar.bz2 ranksvm-20587ac550cfcb2d7b3d6ec16e46ba1a8d0af869.zip |
added split
Diffstat (limited to 'split.cpp')
-rw-r--r-- | split.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/split.cpp b/split.cpp new file mode 100644 index 0000000..be80545 --- /dev/null +++ b/split.cpp @@ -0,0 +1,76 @@ +// +// Created by joe on 5/13/15. +// + +#include <iostream> +#include <boost/program_options.hpp> +#include "tools/dataProvider.h" +#include "tools/fileDataProvider.h" +#include <vector> +#include <fstream> + +INITIALIZE_EASYLOGGINGPP + +using namespace std; +namespace po = boost::program_options; + +po::variables_map vm; + +int outputRid(vector<DataEntry*> a,int fsize,string fname) +{ + ofstream fout(fname.c_str()); + fout<<fsize<<endl; + for (int i=0;i<a.size();++i) + { + fout<< a[i]->qid; + for (int j=0;j<fsize;++j) + fout<<" "<< a[i]->feature(j); + fout<<endl; + } + fout<<0; + fout.close(); +} + +int main(int argc, char **argv) +{ + el::Configurations defaultConf; + defaultConf.setToDefault(); + // Values are always std::string + defaultConf.set(el::Level::Global,el::ConfigurationType::Enabled, "false"); + // default logger uses default configurations + el::Loggers::reconfigureLogger("default", defaultConf); + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("query,Q", "Query person count") + ("count,c", po::value<int>(), "take number") + ("take,a", po::value<string>(), "set output rid file 1(taken)") + ("left,b", po::value<string>(), "set output rid file 2(left)") + ("input,i", po::value<string>(), "set input Rid file"); + + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + // Print help if necessary + if (vm.count("help")) { + cout << desc; + return 0; + } + + if (vm.count("query")){ + RidFileDP dp(vm["input"].as<string>().c_str()); + dp.open(); + cout<<dp.getpSize()<<endl; + dp.close(); + return 0; + } + + RidFileDP dp(vm["input"].as<string>().c_str()); + vector<DataEntry*> a; + vector<DataEntry*> b; + dp.open(); + dp.take(vm["count"].as<int>(),a,b); + outputRid(a,dp.getfSize(),vm["take"].as<string>()); + outputRid(b,dp.getfSize(),vm["left"].as<string>()); + dp.close(); + return 0; +}
\ No newline at end of file |