Main Page | Namespace List | Class List | File List | Class Members | File Members

main.cpp

Go to the documentation of this file.
00001 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 #include <iostream>
00033 #include <fstream>
00034 #include "Apriori.hpp"
00035 using namespace std;
00036 
00037 
00039 
00040 void usage()
00041 {
00042    cerr << "\nUsage: fim_all basketfile min_supp outcomefile \n";
00043    cerr << "\n basketfile\t    file, that contains the baskets of itemcodes";
00044    cerr << "\n min_supp\t    support threshold";
00045    cerr << "\n outcomefile\t    file to write the outcome";
00046 
00047    cerr << "\n\nFile formats:";
00048    cerr << "\n\nThe basket file is a plan text file. Each row represents a basket. ";
00049    cerr << "A basket is a set of items seperated by a nonnumeric character (for example white space, comma, colon, etc.). ";
00050    cerr << "An item is represented by its code which is an integer number greater than or equal to 0.";
00051    cerr << "\n\nHave a succesful mining ;-)";
00052    cerr << "\n\n\n\t\t\t\t\tFerenc Bodon\n\n";
00053 }
00054 
00056 int process_arguments( int argc, char *argv[], ifstream& basket_file, 
00057                        unsigned long& min_supp )
00058 {
00059    if ( argc < 4 )
00060    {
00061      usage();
00062      cerr<<"\nError! There are 3 mandatory arguments!"<<endl;
00063      return 1;
00064    }
00065    basket_file.open(argv[1]);
00066    if( !basket_file )
00067    {
00068       usage();
00069       cerr << "\nError! The basket file can not be read!"<< endl;
00070       return 1;
00071    }
00072    char* pEnd;
00073    min_supp = strtoul( argv[2], &pEnd, 0 );
00074    return 0;
00075 }
00076 
00077 int main( int argc, char *argv[] )
00078 {
00079    unsigned long min_supp;
00080    ifstream basket_file;
00081    
00082    if( process_arguments( argc, argv, basket_file, min_supp ) ) return 1;
00083         
00084    Apriori apriori( basket_file, argv[3] );
00085    apriori.APRIORI_alg( min_supp );
00086    basket_file.close();
00087    return 0;
00088 }
00089 

Generated on Fri Sep 3 17:23:51 2004 for APRIORI algorithm by doxygen 1.3.5