"[verse]" changed to ":verse". Journal implicit, but I don't like that because it ties the input/output directories together. Added total to score.

This commit is contained in:
Neil 2023-08-04 01:11:22 -07:00
parent ea4cf06785
commit af512793b0
3 changed files with 35 additions and 31 deletions

View File

@ -271,7 +271,7 @@ static int scan_day(struct scan *const scan, union date32 date,
}
pair->a = pair->b = 0;
input.future = yycnewline, input.pair = pair;
fprintf(stderr, "%s[%zu]: new dream.\n", datestr, line);
fprintf(stderr, "%s:%zu: new dream.\n", datestr, line);
continue;
}
@ -298,7 +298,7 @@ static int scan_day(struct scan *const scan, union date32 date,
case TREE_ABSENT:
*pi = (size_t)(doc - scan->documents.array.data); break;
}
fprintf(stderr, "%s[%zu]: new document <<%.*s>> stored at %zu.\n",
fprintf(stderr, "%s:%zu: new document <<%.*s>> stored at %zu.\n",
datestr, line, (int)(s1 - s0), s0, *pi);
continue;
}
@ -318,7 +318,7 @@ static int scan_day(struct scan *const scan, union date32 date,
case TREE_ABSENT:
*pi = (size_t)(ed - scan->edits.array.data); break;
}
fprintf(stderr, "%s[%zu]: new remark from %"
fprintf(stderr, "%s:%zu: new remark from %"
PRIu32 "-%.2" PRIu32 "-%.2" PRIu32 " stored at %zu.\n",
datestr, line, ed->edit.year, ed->edit.month, ed->edit.day, *pi);
continue;
@ -335,7 +335,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new contact <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new contact <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -351,7 +351,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new book <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new book <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -367,7 +367,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new tv <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new tv <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -383,7 +383,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new movie <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new movie <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -399,7 +399,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new idea <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new idea <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -415,7 +415,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new vaccine <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new vaccine <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -431,7 +431,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new medication <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new medication <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -447,7 +447,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value = (struct money){0, CAD};
input.future = yycnewline, input.money = &pair->value;
fprintf(stderr, "%s[%zu]: new tax <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new tax <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -463,7 +463,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value = (struct money){0, CAD};
input.future = yycline, input.money = &pair->value;
fprintf(stderr, "%s[%zu]: new income <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new income <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -479,7 +479,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new mail <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new mail <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -495,7 +495,7 @@ static int scan_day(struct scan *const scan, union date32 date,
pair->key.a = s0, pair->key.b = s1;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new couch <<%.*s>>.\n",
fprintf(stderr, "%s:%zu: new couch <<%.*s>>.\n",
datestr, line, (int)(s1 - s0), s0);
continue;
}
@ -511,7 +511,7 @@ static int scan_day(struct scan *const scan, union date32 date,
if(!pair_to_date(s0, &pair->key)) goto catch;
pair->value.a = pair->value.b = 0;
input.future = yycnewline, input.pair = &pair->value;
fprintf(stderr, "%s[%zu]: new from.\n", datestr, line);
fprintf(stderr, "%s:%zu: new from.\n", datestr, line);
continue;
}
@ -528,7 +528,7 @@ static int scan_day(struct scan *const scan, union date32 date,
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
case TREE_ABSENT: *pi = i; break;
}
fprintf(stderr, "%s[%zu]: place <<%.*s>>\n",
fprintf(stderr, "%s:%zu: place <<%.*s>>\n",
datestr, line, (int)(s1 - s0), s0);
} continue; }
<place> "(" @t0 decimal "," @t1 decimal ")"
@ -547,7 +547,7 @@ static int scan_day(struct scan *const scan, union date32 date,
place->name.a = s0, place->name.b = s1;
place->x = x, place->y = y;
fprintf(stderr,
"%s[%zu]: new place: <<%.*s>> at (%f,%f) stored at %zu.\n",
"%s:%zu: new place: <<%.*s>> at (%f,%f) stored at %zu.\n",
datestr, line, (int)(s1 - s0), s0, x, y, *idx);
goto also_place;
}
@ -581,7 +581,7 @@ static int scan_day(struct scan *const scan, union date32 date,
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
case TREE_ABSENT: *pi = i; break;
}
fprintf(stderr, "%s[%zu]: source <<%.*s>>\n",
fprintf(stderr, "%s:%zu: source <<%.*s>>\n",
datestr, line, (int)(s1 - s0), s0);
} continue; }
/* New source. */
@ -599,7 +599,7 @@ static int scan_day(struct scan *const scan, union date32 date,
source->key.a = s0, source->key.b = s1;
source->value.a = 0, source->value.b = 0;
input.future = yycnewline, input.pair = &source->value;
fprintf(stderr, "%s[%zu]: new source <<%.*s>> stored at %zu.\n",
fprintf(stderr, "%s:%zu: new source <<%.*s>> stored at %zu.\n",
datestr, line, (int)(s1 - s0), s0, *idx);
goto also_source;
}
@ -622,7 +622,7 @@ static int scan_day(struct scan *const scan, union date32 date,
case TREE_ERROR: goto catch;
case TREE_ABSENT: *pidx = idx; break;
}
fprintf(stderr, "%s[%zu]: score <%.*s>\n",
fprintf(stderr, "%s:%zu: score <%.*s>\n",
datestr, line, (int)(s1 - s0), s0);
} continue; }
/* New score. */
@ -644,7 +644,7 @@ static int scan_day(struct scan *const scan, union date32 date,
new_score->name.a = 0, new_score->name.b = 0;
new_score->date.u32 = new_score->last.u32 = 0;
new_score->edges = 0, new_score->score = 0;
fprintf(stderr, "%s[%zu]: new score <%.*s> stored at %zu.\n",
fprintf(stderr, "%s:%zu: new score <%.*s> stored at %zu.\n",
datestr, line, (int)(s1 - s0), s0, *idx);
goto new_score;
}
@ -688,7 +688,7 @@ static int scan_day(struct scan *const scan, union date32 date,
<glider_launch> * { fail = "glider launch"; goto catch; }
<glider_launch> ws* @s0 airport @s1 ";" => glider_how {
new_glider->launch.a = s0, new_glider->launch.b = s1;
fprintf(stderr, "%s[%zu]: glider <<%.*s>> at <<%.*s>>\n",
fprintf(stderr, "%s:%zu: glider <<%.*s>> at <<%.*s>>\n",
datestr, line, (int)(new_glider->reg.b - new_glider->reg.a),
new_glider->reg.a, (int)(s1 - s0), s0);
continue;
@ -760,7 +760,7 @@ static int scan_day(struct scan *const scan, union date32 date,
ws* @t0 airport @t1 ws* ";" => flight_pic {
new_flight->launch.a = s0, new_flight->launch.b = s1;
new_flight->landing.a = t0, new_flight->landing.b = t1;
fprintf(stderr, "%s[%zu]: flight <<%.*s>> at <<%.*s>>\n",
fprintf(stderr, "%s:%zu: flight <<%.*s>> at <<%.*s>>\n",
datestr, line, (int)(new_flight->reg.b - new_flight->reg.a),
new_flight->reg.a, (int)(s1 - s0), s0);
continue;
@ -913,7 +913,7 @@ static int scan_day(struct scan *const scan, union date32 date,
value->verse_end = kjv.verse_end;
break;
}
fprintf(stderr, "%s[%zu]: KJV %s %" PRIu32 ":%" PRIu32, datestr,
fprintf(stderr, "%s:%zu: KJV %s %" PRIu32 ":%" PRIu32, datestr,
line, kjv_book_string[kjv.book], kjv.chapter, kjv.verse);
if(kjv.verse_end) fprintf(stderr, "-%u", kjv.verse_end);
fprintf(stderr, "\n");
@ -975,7 +975,7 @@ catch:
fprintf(stderr, "%.*s\n", (int)(s1 - lastnl), lastnl);
}
fprintf(stderr,
"%s line %zu fail: %s" /*" condition %d"*/ ".\n",
"%s:%zu fail: %s" /*" condition %d"*/ ".\n",
datestr, line, fail/*, condition*/);
return 0;
}
@ -1107,6 +1107,7 @@ void scan_score_graph(struct scan *const scan) {
= linemap_tree_iterator(&scan->scores.dates);
union line64 line;
struct score *score;
unsigned total = 0;
assert(scan);
fprintf(stderr, "*** Score graph %s.\n",
@ -1121,7 +1122,7 @@ void scan_score_graph(struct scan *const scan) {
" size 840, 480 fontscale 1\n"
"set output \"score.png\"\n");
printf("$Data <<EOD\n"
"# date, key, key score\n");
"# date, key, score, total, place\n");
while(linemap_tree_next(&it)) {
line = linemap_tree_key(&it);
assert(*linemap_tree_value(&it) < scan->scores.array.size);
@ -1140,8 +1141,11 @@ void scan_score_graph(struct scan *const scan) {
char datestr[12];
date32_to_string(line.date, &datestr);
score->score++; /* Keep track of the score per key. */
printf("%s, %.*s, %u, %.*s\n", datestr,
(int)(score->key.b - score->key.a), score->key.a, score->score,
total++; /* Keep track of the total. */
printf("%s, %.*s, %u, %u, %.*s\n",
datestr,
(int)(score->key.b - score->key.a), score->key.a,
score->score, total,
(int)(place_name.b - place_name.a), place_name.a);
}
printf("EOD\n"
@ -1162,7 +1166,7 @@ void scan_score_graph(struct scan *const scan) {
"myTimeFmt = \"%%Y-%%m-%%d\"\n"
"set format x myTimeFmt timedate\n"
"set xtics format myTimeFmt rotate by -30\n"
"set ylabel \"happiness CDF (person·day)\"\n"
"set ylabel \"meaning CDF (person·day)\"\n"
"set grid\n"
"set key out reverse Left noautotitle\n"
"set style fill solid 0.5\n"

View File

@ -7,7 +7,7 @@
int main(void) {
errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */
struct journal j = journal("../journal");
struct journal j = journal(/*"../journal"*/);
int success = EXIT_SUCCESS;
if(errno) goto catch;
printf("Journal: %s.\n", journal_to_string(&j));

View File

@ -7,7 +7,7 @@
int main(void) {
int success = EXIT_SUCCESS;
errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */
struct journal jrnl = journal("../journal");
struct journal jrnl = journal(/*"../journal"*/);
struct scan scn = scan(&jrnl);
if(errno) goto catch;