3 # Copyright 2023 Paul Hänsch
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 DOC="${PATH_INFO%/}/" DOC="${DOC%/\[*\]/}" DOC="${DOC%/}/"
18 P="$_DATA/pages${DOC}" I="$_DATA/index/"
20 if [ -f "$P/#index.flag" -a ! "$P/#page.md" -nt "$P/#index.flag" ]; then
25 . "$_EXEC/cgilite/storage.sh"
29 touch "$P/#index.flag"
32 { cat; printf \\n; } \
33 | while IFS='' read -r line; do
34 printf '%s\n' "$line" >&3
38 BEGIN { FS = "[] \t\n\r!\"#'\''()*+,./:;<=>?\\^_`{|}~[-]+" }
39 { for (n = 1; n <= NF; n++) if ( $n != "" ) { words[tolower($n)]++; total++; } }
40 END { for (w in words) printf "%i %i %f %s\n", words[w], total, words[w] / total, w; }
42 | while read num total freq word; do
43 [ "$word" ] || continue
49 { while read d l f n t; do
51 || printf "%i %s %f %i %i\n" \
52 "$d" "$l" "$f" "$n" "$t"
54 printf "%i %s %f %i %i\n" \
55 "$_DATE" "$L" "$freq" "$num" "$total"