Graph improved.
This commit is contained in:
parent
947d448962
commit
3da15791d6
@ -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;
|
||||||
struct { size_t total, set, verse; } words;
|
struct { size_t total, cumulative, set, verse; } words;
|
||||||
};
|
};
|
||||||
struct kjv kjv(void);
|
struct kjv kjv(void);
|
||||||
void kjv_(struct kjv *);
|
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. */
|
/** 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);
|
kjv->words.verse = verse_table_get(&kjv->verses, cite);
|
||||||
|
kjv->words.cumulative += kjv->words.verse;
|
||||||
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->words.set += w; /* Sic. */
|
case TABLE_ABSENT: kjv->words.set += kjv->words.verse; /* Sic. */
|
||||||
case TABLE_PRESENT: kjv->words.verse = w; break;
|
case TABLE_PRESENT: break;
|
||||||
}
|
}
|
||||||
return 1;
|
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(!kjv_add(kj, cite)) { why = "add to set"; goto catch; }
|
||||||
if(!verse_end || verse_end <= verse) break;
|
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) {
|
if(verse_end) {
|
||||||
printf("%s\t%zu\t%zu\t# %s-%" PRIu32 "\n",
|
printf("%s-%" PRIu32 "\n", 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\n", 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.words.total);
|
"# date\tverse\tset\tcumulative / %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;*/
|
||||||
@ -209,11 +209,12 @@ int main(void) {
|
|||||||
"set xtics format \"%%Y-%%m-%%d\" rotate by -30\n"
|
"set xtics format \"%%Y-%%m-%%d\" rotate by -30\n"
|
||||||
"set ylabel \"words\"\n"
|
"set ylabel \"words\"\n"
|
||||||
"set format y \"%%g%%%%\"\n"
|
"set format y \"%%g%%%%\"\n"
|
||||||
"unset key #set key bottom right\n"
|
"set key top left\n"
|
||||||
"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)*100/%zu with steps lw 2 title \"set\", \\\n"
|
||||||
"with steps lw 2\n", kj.words.total);
|
"$Data using 1:($4)*100/%zu with steps lw 1 title \"cumulative\"\n",
|
||||||
|
kj.words.total, kj.words.total);
|
||||||
goto finally;
|
goto finally;
|
||||||
catch:
|
catch:
|
||||||
success = EXIT_FAILURE;
|
success = EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user