00001
00005 #include "commandline.hpp"
00006 #include "log.h"
00007
00008 #include <iostream>
00009 #include <string>
00010
00011 std::string file_format;
00012
00013
00014 void init()
00015 {
00016 file_format = "File format:";
00017 file_format += "\n\nThe transactionfile is a plan text file. Each row ";
00018 file_format += "represents a transaction. \n";
00019 file_format += "A transaction is a set of items seperated by a nonnumeric ";
00020 file_format += "character.\nIt can be for example a white space, comma, ";
00021 file_format += "colon, etc.\n";
00022 file_format += "Items are nonnegative integers.\n";
00023 }
00025 void usage()
00026 {
00027 std::cerr << "\nUsage: fim algorithm transactionfile outcomefile ";
00028 std::cerr << "min_supp [options]\n";
00029 std::cerr << "\n algorithm\t the name of the algorithm, i.e: input_test, ";
00030 std::cerr << "simple_output_test apriori, eclat or fp-growth";
00031 std::cerr << "\n transactionfile\t file, that contains the tranasctions of items";
00032 std::cerr << "\n outcomefile\t file to write the outcome";
00033 std::cerr << "\n min_supp\t absolute support threshold";
00034
00035 std::cerr << "\n\nFile formats:";
00036 std::cerr << "\n\nThe transactionfile is a plan text file. Each row represents";
00037 std::cerr << " a transaction. "<<std::endl;
00038 std::cerr << "A transaction is a set of items seperated by a nonnumeric character.";
00039 std::cerr << "\nIt can be for example a white space, comma, colon, etc. \n";
00040 std::cerr << "Items are nonnegative integers.\n";
00041 std::cerr << "\n\nHave a succesful mining ;-)";
00042 }
00043
00044 int process_arguments( int argc, char *argv[], counter_t& min_supp,
00045 bool &isrel, double &relminsupp )
00046 {
00047 if ( argc < 5 )
00048 {
00049 usage();
00050 std::cerr<<"\nError! There are 4 mandatory arguments!\n"<<std::flush;
00051 return 1;
00052 }
00053 std::string mins=argv[4];
00054 if (mins[mins.size()-1]=='%') {
00055 mins.erase(mins.size()-1);
00056 isrel=true;
00057 relminsupp=atof(mins.c_str());
00058 relminsupp/=100;
00059 log_info(0,"Using relative minimum support of %lg",relminsupp);
00060 return 0;
00061 }
00062 min_supp = atoi(argv[4]);
00063 if ( min_supp <= 0 )
00064 {
00065 usage();
00066 std::cerr<<"\nError!\n min_supp should be positive."<<std::endl;
00067 return 1;
00068 }
00069
00070 return 0;
00071 }
00072
00073
00074 int process_arguments( int argc, char *argv[], counter_t& min_supp )
00075 {
00076 if ( argc < 5 )
00077 {
00078 usage();
00079 std::cerr<<"\nError! There are 4 mandatory arguments!\n"<<std::flush;
00080 return 1;
00081 }
00082 min_supp = atoi(argv[4]);
00083 if ( min_supp <= 0 )
00084 {
00085 usage();
00086 std::cerr<<"\nError!\n min_supp should be positive."<<std::endl;
00087 return 1;
00088 }
00089
00090 return 0;
00091 }
00092
00093