summaryrefslogtreecommitdiff
path: root/split.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'split.cpp')
-rw-r--r--split.cpp76
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