SIS
Symmetric Index Structures
/Users/dbr/ma/src/bas/lml/main.c
Go to the documentation of this file.
00001 #include "base.h"
00002 
00003 #define mSetCommandArguments( nArguments )\
00004 {\
00005     cmd->numberOfArguments = (nArguments);\
00006     cmd->arguments = arguments;\
00007 }
00008 S32 main( S32 argc, S8* argv[] ){
00009     Command * cmd;
00010     S64 start, end;
00011     U32 tmp;
00012     double t;
00013 
00014     mSetEndianness()
00015     cmd = CommandInit();
00016     if( argc <= 1 ){
00017         printf( "Please, choose a command:\n" );
00018         printf( "1: reverse_and_sort\n" );
00019         printf( "2: build_suffix_tree\n" );
00020         printf( "3: generate_suffixes\n" );
00021         printf( "4: compressed_automaton_lang\n" );
00022         printf( "5: build_cdawg\n" );
00023         printf( "6: compressed_automaton_stat\n" );
00024         printf( "7: build_scdawg\n" );
00025         printf( "8: scdawg_left_lang\n" );
00026         printf( "9: compressed_automaton_gv\n" );
00027         printf( "10: scdawg_stat\n" );
00028         printf( "11: scdawg_gv\n" );
00029 
00030         scanf( "%u", &tmp ); cmd->cmd = tmp; {char tmp[128]; fgets( tmp, 128, stdin );}
00031 
00032         switch( cmd->cmd ){
00033             case CMD_REVERSE_AND_SORT:
00034             case CMD_GENERATE_SUFFIXES:
00035                 {
00036                     S8 fileNameInput[MAX_INPUT_STRING_SIZE];
00037                     S8 fileNameOutput[MAX_INPUT_STRING_SIZE];
00038                     S8 bitsPerSymbol[MAX_INPUT_STRING_SIZE];
00039                     S8 encoding[MAX_INPUT_STRING_SIZE];
00040                     S8 * arguments[4] = {fileNameInput, fileNameOutput, bitsPerSymbol, encoding};
00041 
00042                     printf( "Please, enter the input file name:\n" );
00043                     mGETS( fileNameInput );
00044 
00045                     printf( "Please, enter the output file name:\n" );
00046                     mGETS( fileNameOutput );
00047 
00048                     printf( "Please, enter the number of bits per symbol:\n" );
00049                     mGETS( bitsPerSymbol );
00050 
00051                     printf( "Please, enter the encoding (UTF-8 / PLAIN):\n" );
00052                     mGETS( encoding );
00053 
00054                     mSetCommandArguments( 4 )
00055                 }
00056                 break;            
00057             case CMD_BUILD_SUFFIX_TREE:
00058             case CMD_BUILD_CDAWG:
00059             case CMD_BUILD_SCDAWG:
00060                 {
00061                     S8 fileNameInput[MAX_INPUT_STRING_SIZE];
00062                     S8 fileNameOutput[MAX_INPUT_STRING_SIZE];
00063                     S8 bitsPerSymbol[MAX_INPUT_STRING_SIZE];
00064                     S8 encoding[MAX_INPUT_STRING_SIZE];
00065                     S8 tarjanTable[MAX_INPUT_STRING_SIZE];
00066                     S8 * arguments[5] = {fileNameInput, fileNameOutput, bitsPerSymbol, encoding, tarjanTable};
00067 
00068                     printf( "Please, enter the input file name:\n" );
00069                     mGETS( fileNameInput );
00070 
00071                     printf( "Please, enter the output file name:\n" );
00072                     mGETS( fileNameOutput );
00073 
00074                     printf( "Please, enter the number of bits per symbol:\n" );
00075                     mGETS( bitsPerSymbol );
00076 
00077                     printf( "Please, enter the encoding (UTF-8 / PLAIN):\n" );
00078                     mGETS( encoding );
00079 
00080                     printf( "Please, enter Tarjan table (y / n):\n" );
00081                     mGETS( tarjanTable );
00082 
00083                     mSetCommandArguments( 5 )
00084                 }
00085                 break;
00086             case CMD_COMPRESSED_AUTOMATON_LANG:
00087             case CMD_SCDAWG_LEFT_LANG:
00088             case CMD_COMPRESSED_AUTOMATON_GV:
00089             case CMD_SCDAWG_GV:
00090                 {
00091                     S8 fileNameInput[MAX_INPUT_STRING_SIZE];
00092                     S8 fileNameOutput[MAX_INPUT_STRING_SIZE];
00093                     S8 encoding[MAX_INPUT_STRING_SIZE];
00094                     S8 * arguments[3] = {fileNameInput, fileNameOutput, encoding};
00095 
00096                     printf( "Please, enter the input file name:\n" );
00097                     mGETS( fileNameInput );
00098 
00099                     printf( "Please, enter the output file name:\n" );
00100                     mGETS( fileNameOutput );
00101 
00102                     printf( "Please, enter the encoding (UTF-8 / PLAIN):\n" );
00103                     mGETS( encoding );
00104 
00105                     mSetCommandArguments( 3 )
00106                 }
00107                 break;
00108             case CMD_COMPRESSED_AUTOMATON_STAT:
00109             case CMD_SCDAWG_STAT:
00110                 {
00111                     S8 fileNameInput[MAX_INPUT_STRING_SIZE];
00112                     S8 fileNameOutput[MAX_INPUT_STRING_SIZE];
00113                     S8 * arguments[2] = {fileNameInput, fileNameOutput};
00114 
00115                     printf( "Please, enter the input file name:\n" );
00116                     mGETS( fileNameInput );
00117 
00118                     printf( "Please, enter the output file name:\n" );
00119                     mGETS( fileNameOutput );
00120 
00121                     mSetCommandArguments( 2 )
00122                 }
00123                 break;
00124             default:
00125                 {
00126                     S8 msg[MAX_INPUT_STRING_SIZE];
00127                     sprintf( msg, "Unknown command: %llu", (U64)(cmd->cmd) );
00128                     Throw( msg );
00129                 }
00130                 break;
00131         }
00132     }
00133     else{
00134         CommandParse( cmd, argc, argv );
00135     }
00136     start = clock();
00137     CommandExecute( cmd );
00138     end = clock();
00139     t = ((double)(end - start)) / CLOCKS_PER_SEC;
00140     printf( "time = %.2f seconds\n", t );
00141     CommandFree( cmd );
00142     Verify();
00143     return 0;
00144 }
00145 //dot my.gv -Tps -o"my.ps" -Kdot
00146 //diff -q 1.txt 2.txt
00147