Graph improved.
This commit is contained in:
parent
947d448962
commit
3da15791d6
@ -107,7 +107,7 @@ struct verse_table {
|
||||
struct kjv {
|
||||
struct kjvset_table set;
|
||||
struct verse_table verses;
|
||||
struct { size_t total, set, verse; } words;
|
||||
struct { size_t total, cumulative, set, verse; } words;
|
||||
};
|
||||
struct kjv kjv(void);
|
||||
void kjv_(struct kjv *);
|
||||
|
@ -227,13 +227,13 @@ int kjv_is_valid(const struct kjv *const kjv)
|
||||
|
||||
/** Adds `cite` to `kjv` if not present. @return Is the kjv still valid. */
|
||||
int kjv_add(struct kjv *const kjv, const union kjvcite cite) {
|
||||
unsigned w;
|
||||
if(!kjv) return 0;
|
||||
w = verse_table_get(&kjv->verses, cite);
|
||||
kjv->words.verse = verse_table_get(&kjv->verses, cite);
|
||||
kjv->words.cumulative += kjv->words.verse;
|
||||
switch(kjvset_table_try(&kjv->set, cite)) {
|
||||
case TABLE_ERROR: return 0;
|
||||
case TABLE_ABSENT: kjv->words.set += w; /* Sic. */
|
||||
case TABLE_PRESENT: kjv->words.verse = w; break;
|
||||
case TABLE_ABSENT: kjv->words.set += kjv->words.verse; /* Sic. */
|
||||
case TABLE_PRESENT: break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -158,12 +158,12 @@ static int scan(union date32 date, const char *const buffer,
|
||||
if(!kjv_add(kj, cite)) { why = "add to set"; goto catch; }
|
||||
if(!verse_end || verse_end <= verse) break;
|
||||
}
|
||||
printf("%s\t%zu\t%zu\t%zu\t# ",
|
||||
datestr, kj->words.verse, kj->words.set, kj->words.cumulative);
|
||||
if(verse_end) {
|
||||
printf("%s\t%zu\t%zu\t# %s-%" PRIu32 "\n",
|
||||
datestr, old_set_words, kj->words.set, citestr, verse_end);
|
||||
printf("%s-%" PRIu32 "\n", citestr, verse_end);
|
||||
} else {
|
||||
printf("%s\t%zu\t%zu\t# %s\n",
|
||||
datestr, old_set_words, kj->words.set, citestr);
|
||||
printf("%s\n", citestr);
|
||||
}
|
||||
book = Revelation, chapter = 0, verse = 0, verse_end = 0;
|
||||
continue;
|
||||
@ -197,7 +197,7 @@ int main(void) {
|
||||
printf("set term postscript eps enhanced\n"
|
||||
"set output \"kjv.eps\"\n"
|
||||
"$Data <<EOD\n"
|
||||
"# date\told\tnew / %zu\n", kj.words.total);
|
||||
"# date\tverse\tset\tcumulative / %zu\n", kj.words.total);
|
||||
it = journal_begin(&j), i = 0; while(journal_next(&it, &k, &v)) {
|
||||
if(!scan(k, v->text, &kj)) goto catch;
|
||||
/*if(++i > 32) break;*/
|
||||
@ -209,11 +209,12 @@ int main(void) {
|
||||
"set xtics format \"%%Y-%%m-%%d\" rotate by -30\n"
|
||||
"set ylabel \"words\"\n"
|
||||
"set format y \"%%g%%%%\"\n"
|
||||
"unset key #set key bottom right\n"
|
||||
"set key top left\n"
|
||||
"set grid\n"
|
||||
"unset border\n"
|
||||
"plot $Data using 1:($3-$2)*100/%zu smooth cumulative "
|
||||
"with steps lw 2\n", kj.words.total);
|
||||
"plot $Data using 1:($3)*100/%zu with steps lw 2 title \"set\", \\\n"
|
||||
"$Data using 1:($4)*100/%zu with steps lw 1 title \"cumulative\"\n",
|
||||
kj.words.total, kj.words.total);
|
||||
goto finally;
|
||||
catch:
|
||||
success = EXIT_FAILURE;
|
||||
|
Loading…
Reference in New Issue
Block a user