#include #include #include "syllable.h" const size_t BUFFER_SIZE = 4096; char buffer[BUFFER_SIZE]; const char* const source_filename = "dicc_es.txt"; const char* const target_filename = "dicc_es.txt"; int main() { FILE* source = fopen(source_filename, "r"); if ( ! source ) return fprintf(stderr, "Could not open %s\n", source_filename); FILE* target = fopen("dicc_es_div.txt", "w"); if ( ! target ) return fprintf(stderr, "Could not create %s\n", target_filename); SeparatorOfSyllables separator; while ( fgets(buffer, BUFFER_SIZE, source) ) { int len = strlen(buffer); buffer[--len] = '\0'; fprintf(target, "%s\t", buffer); const int count = separator.NumberOfSyllables(buffer); const int* const syllables = separator.SyllablePositions(buffer); for ( int i = 0; i < count - 1; ++i ) { for ( int j = syllables[i]; j < syllables[i + 1]; ++j ) fputc(buffer[j], target); fputc('-', target); } for ( int j = syllables[count - 1]; j < len; ++j ) fputc(buffer[j], target); fputc('\n', target); } fclose(source); fclose(target); return 0; }