예제 #1
0
int main(int argc, char *argv[])
{
  char *target_filename;
  char *output_filename;
  FILE *input, *output;
  DICT *dict;

  // analize options
    if (argc != 3) {
      printf("usage: %s target_text_file output_cfg_file\n", argv[0]);
      exit(1);
  }

  target_filename = argv[1];
  output_filename = argv[2];
  
  // Run the algorithm procedure
  input  = fopen(target_filename, "r");
  output = fopen(output_filename, "wb");
  if (input == NULL || output == NULL) {
    puts("File open error at the beginning.");
    exit(1);
  }

  dict = GrammarTrans_LCA(input);
  OutputGeneratedCFG(dict, output);
  DestructDict(dict);

  fclose(input);
  fclose(output);
  
  exit(0);
}
예제 #2
0
파일: main.c 프로젝트: syoshid/Re-Pair-VF
int main(int argc, char *argv[])
{
    char *target_filename;
    char *output_filename;
    FILE *input, *output;
    DICT *dict;

    if (argc != 3) {
        printf("usage: %s target_text_file output_file\n", argv[0]);
        exit(1);
    }
    target_filename = argv[1];
    output_filename = argv[2];

    input  = fopen(target_filename, "r");
    output = fopen(output_filename, "wb");
    if (input == NULL || output == NULL) {
        puts("File open error at the beginning.");
        exit(1);
    }

    dict = RunRepair(input);
    OutputGeneratedCFG(dict, output);
    DestructDict(dict);

    fclose(input);
    fclose(output);
    exit(0);
}
예제 #3
0
파일: main.c 프로젝트: s-maruyama/exrepair
int main(int argc, char *argv[])
{
  char *target_filename;
  char output_filename[256];
  FILE *input, *output;
  uint code_len, cont_len, cont_size;
  DICT *dict;

  if (argc != 4 && argc != 5) {
    printf("usage: %s target_text_file [code_length (bits)]\n", argv[0]);
    printf("default code_length: 8 bits\n");
    exit(1);
  }

  target_filename = argv[1];
  strcpy(output_filename, target_filename);

  if (argc == 2) {
    code_len = 8;
    cont_len = 1;
    cont_size = 256;
    strcat(output_filename, ".cr8");
  }
  else {
    code_len = atoi(argv[2]);
    if (code_len < 8 || code_len > 24) {
      printf("range of code length: 8-24 (bits)\n"); 
      exit(1);
    }
    cont_len = atoi(argv[3]);
    if (cont_len < 1 || cont_len > 3) {
      printf("range of context length: 1-3\n");
      exit(1);
    }
    cont_size = atoi(argv[4]);
    if (cont_size < 1 || cont_size > 256) {
      printf("range of context size: 1-256");
      exit(1);
    }
    strcat(output_filename, ".cr");
    strcat(output_filename, argv[2]);
  }
  printf("output_filename = %s\n", output_filename);

  input  = fopen(target_filename, "r");
  output = fopen(output_filename, "wb");
  if (input == NULL || output == NULL) {
    puts("File open error at the beginning.");
    exit(1);
  }

  dict = RunCodeRepair(input, code_len, cont_len, cont_size);
  OutputCompTxt(dict, output);
  DestructDict(dict);

  fclose(input);
  fclose(output);
  exit(0);
}