int main(int argc, char * argv[]) { FILE * edict = fopen("./edict.locale", "r"); if(!edict) { fprintf(stderr, "Could not open the file edict.locale.\n"); fprintf(stderr, "Exiting.\n"); } FILE * kanjidic = fopen("./kanjidic.locale", "r"); if(!kanjidic) { fprintf(stderr, "Could not open the file kanjidic.locale.\n"); fprintf(stderr, "Exiting.\n"); } /* The first line is only a comment */ //skip_line(edict); skip_line(kanjidic); fprintf(stderr, "I have opened both edict.locale and kanjidic.locale.\n"); /* Read in the kanjidic file. */ kanji * klist = readkanjidic(kanjidic); fprintf(stderr, "Parsed the KANJIDIC file.\n"); /* We'll need a panini monad later (this is used by learnentry_func) */ pmonad = monad_new(); monad_rules(pmonad, "english"); /* Read the edict file in line by line */ int i = 0; for(;;) { /* Read in the headword. */ char * headword = readword(edict); if(!headword) break; if(!strlen(headword)) break; /* Every 32nd line, print out how far we've come. * (This test is an optimisation; the terminal is a slow thing to print to.) */ if(i == (i & ~(017))) fprintf(stderr, "EDICT importer: %d %s \r", i, headword); /* Parse the line and try to generate Panini source code */ readentry(edict, headword, klist); i++; } /* Print out all the used kanji. */ compilekanji(klist); free_kanji(klist); return 0; }
void learn_noun(char * fn, char * exec, char * lang, char * word) { if (test(lang, exec, word)) return; FILE * outfile = fopen(fn, "a"); monad * m = monad_new(); monad_rules(m, lang); monad * n = monad_duplicate(m); if(!panini_parse(m, exec, word, 0, 0, 5)) { // printf("Going to learn the %s %s, %s ... \n", lang, "noun", word); panini_learnvocab(n, exec, outfile, word, 20); } fclose(outfile); monad_free(m); monad_free(n); }
int test(char * lang, char * exec, char * lex) { // char e[4096]; int retval; // // strcpy(e, "(seme (head "); // strcat(e, seme); // strcat(e, ") "); // strcat(e, exec); // // fprintf(stderr, "Testing %s ...\r", e); // monad * m = monad_new(); monad_rules(m, lang); // retval = panini_parse(m, exec, lex, 0, 0, 10); monad_free(m); // fprintf(stderr, "Done testing.\n"); return retval; }
int main(int argc, char * argv[]) { /* create a new monad. */ monad * m = monad_new(); /* Set the rules ready for translation from the original */ monad_rules(m, argv[1]); /* Make the translations. */ panini_generate(m, argv[2], 0, 5); monad_rules(m, argv[3]); panini_generate(m, argv[4], 0, 5); /* And spit the output out! */ FILE * output = fopen(argv[5], "a+"); monad_map(m, print_out, output, 5); fclose(output); monad_free(m); return 0; }