Updated all words.*.
This commit is contained in:
parent
ccdee8a779
commit
947d448962
@ -107,7 +107,7 @@ struct verse_table {
|
|||||||
struct kjv {
|
struct kjv {
|
||||||
struct kjvset_table set;
|
struct kjvset_table set;
|
||||||
struct verse_table verses;
|
struct verse_table verses;
|
||||||
size_t total_words, set_words;
|
struct { size_t total, set, verse; } words;
|
||||||
};
|
};
|
||||||
struct kjv kjv(void);
|
struct kjv kjv(void);
|
||||||
void kjv_(struct kjv *);
|
void kjv_(struct kjv *);
|
||||||
|
@ -203,7 +203,7 @@ struct kjv kjv(void) {
|
|||||||
case TABLE_ERROR: goto catch;
|
case TABLE_ERROR: goto catch;
|
||||||
case TABLE_ABSENT: break;
|
case TABLE_ABSENT: break;
|
||||||
}
|
}
|
||||||
*words = x.words, kjv.total_words += x.words;
|
*words = x.words, kjv.words.total += x.words;
|
||||||
}
|
}
|
||||||
if(x.error) { fprintf(stderr, "[%u]%s on line %zu\n",
|
if(x.error) { fprintf(stderr, "[%u]%s on line %zu\n",
|
||||||
b + 1, kjv_book_string[b], x.line); goto catch; }
|
b + 1, kjv_book_string[b], x.line); goto catch; }
|
||||||
@ -227,11 +227,13 @@ int kjv_is_valid(const struct kjv *const kjv)
|
|||||||
|
|
||||||
/** Adds `cite` to `kjv` if not present. @return Is the kjv still valid. */
|
/** Adds `cite` to `kjv` if not present. @return Is the kjv still valid. */
|
||||||
int kjv_add(struct kjv *const kjv, const union kjvcite cite) {
|
int kjv_add(struct kjv *const kjv, const union kjvcite cite) {
|
||||||
|
unsigned w;
|
||||||
if(!kjv) return 0;
|
if(!kjv) return 0;
|
||||||
|
w = verse_table_get(&kjv->verses, cite);
|
||||||
switch(kjvset_table_try(&kjv->set, cite)) {
|
switch(kjvset_table_try(&kjv->set, cite)) {
|
||||||
case TABLE_ERROR: return 0;
|
case TABLE_ERROR: return 0;
|
||||||
case TABLE_ABSENT: kjv->set_words += verse_table_get(&kjv->verses, cite);
|
case TABLE_ABSENT: kjv->words.set += w; /* Sic. */
|
||||||
case TABLE_PRESENT: break;
|
case TABLE_PRESENT: kjv->words.verse = w; break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ static int scan(union date32 date, const char *const buffer,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
<book> engage => skip {
|
<book> engage => skip {
|
||||||
const size_t old_set_words = kj->set_words;
|
const size_t old_set_words = kj->words.set;
|
||||||
char citestr[12];
|
char citestr[12];
|
||||||
if(!chapter || !verse) { why = "missing information"; goto catch; }
|
if(!chapter || !verse) { why = "missing information"; goto catch; }
|
||||||
if(verse_end && verse_end <= verse)
|
if(verse_end && verse_end <= verse)
|
||||||
@ -160,10 +160,10 @@ static int scan(union date32 date, const char *const buffer,
|
|||||||
}
|
}
|
||||||
if(verse_end) {
|
if(verse_end) {
|
||||||
printf("%s\t%zu\t%zu\t# %s-%" PRIu32 "\n",
|
printf("%s\t%zu\t%zu\t# %s-%" PRIu32 "\n",
|
||||||
datestr, old_set_words, kj->set_words, citestr, verse_end);
|
datestr, old_set_words, kj->words.set, citestr, verse_end);
|
||||||
} else {
|
} else {
|
||||||
printf("%s\t%zu\t%zu\t# %s\n",
|
printf("%s\t%zu\t%zu\t# %s\n",
|
||||||
datestr, old_set_words, kj->set_words, citestr);
|
datestr, old_set_words, kj->words.set, citestr);
|
||||||
}
|
}
|
||||||
book = Revelation, chapter = 0, verse = 0, verse_end = 0;
|
book = Revelation, chapter = 0, verse = 0, verse_end = 0;
|
||||||
continue;
|
continue;
|
||||||
@ -197,7 +197,7 @@ int main(void) {
|
|||||||
printf("set term postscript eps enhanced\n"
|
printf("set term postscript eps enhanced\n"
|
||||||
"set output \"kjv.eps\"\n"
|
"set output \"kjv.eps\"\n"
|
||||||
"$Data <<EOD\n"
|
"$Data <<EOD\n"
|
||||||
"# date\told\tnew / %zu\n", kj.total_words);
|
"# date\told\tnew / %zu\n", kj.words.total);
|
||||||
it = journal_begin(&j), i = 0; while(journal_next(&it, &k, &v)) {
|
it = journal_begin(&j), i = 0; while(journal_next(&it, &k, &v)) {
|
||||||
if(!scan(k, v->text, &kj)) goto catch;
|
if(!scan(k, v->text, &kj)) goto catch;
|
||||||
/*if(++i > 32) break;*/
|
/*if(++i > 32) break;*/
|
||||||
@ -213,7 +213,7 @@ int main(void) {
|
|||||||
"set grid\n"
|
"set grid\n"
|
||||||
"unset border\n"
|
"unset border\n"
|
||||||
"plot $Data using 1:($3-$2)*100/%zu smooth cumulative "
|
"plot $Data using 1:($3-$2)*100/%zu smooth cumulative "
|
||||||
"with steps lw 2\n", kj.total_words);
|
"with steps lw 2\n", kj.words.total);
|
||||||
goto finally;
|
goto finally;
|
||||||
catch:
|
catch:
|
||||||
success = EXIT_FAILURE;
|
success = EXIT_FAILURE;
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
int success = EXIT_SUCCESS;
|
int success = EXIT_SUCCESS;
|
||||||
struct kjv k = kjv();
|
struct kjv k = kjv();
|
||||||
fprintf(stderr, "%zu total words, %s.\n", k.total_words, kjv_to_string(&k));
|
fprintf(stderr, "%zu total words, %s.\n", k.words.total, kjv_to_string(&k));
|
||||||
if(!kjv_is_valid(&k)) goto catch;
|
if(!kjv_is_valid(&k)) goto catch;
|
||||||
kjv_add(&k, (union kjvcite){ .book = Genesis, .chapter = 1, .verse = 1 });
|
kjv_add(&k, (union kjvcite){ .book = Genesis, .chapter = 1, .verse = 1 });
|
||||||
kjv_add(&k, (union kjvcite){ .book = Genesis, .chapter = 1, .verse = 2 });
|
kjv_add(&k, (union kjvcite){ .book = Genesis, .chapter = 1, .verse = 2 });
|
||||||
kjv_add(&k, (union kjvcite){ .book = Genesis, .chapter = 1, .verse = 1 });
|
kjv_add(&k, (union kjvcite){ .book = Genesis, .chapter = 1, .verse = 1 });
|
||||||
fprintf(stderr, "%zu of which: %s.\n", k.set_words, kjv_set_to_string(&k));
|
fprintf(stderr, "%zu of which: %s.\n", k.words.set, kjv_set_to_string(&k));
|
||||||
assert(k.total_words == 789633);
|
assert(k.words.total == 789633);
|
||||||
assert(k.set_words == 39);
|
assert(k.words.set == 39);
|
||||||
goto finally;
|
goto finally;
|
||||||
catch:
|
catch:
|
||||||
success = EXIT_FAILURE, perror("kjv");
|
success = EXIT_FAILURE, perror("kjv");
|
||||||
|
Loading…
Reference in New Issue
Block a user