Adapt memestats to bitreich.org. Remove IRC log stuff. - bitreich-memestats - Bitreich meme statistics and graphs. HTML git clone git://bitreich.org/bitreich-memestats git://hg6vgqziawt5s4dj.onion/bitreich-memestats DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit e082f9a06845793bcfa455df769420c1c926a85e DIR parent 277b24006ce8268150ece65be9a02607df09f55e HTML Author: Christoph Lohmann <20h@r-36.net> Date: Sun, 29 Aug 2021 20:21:50 +0200 Adapt memestats to bitreich.org. Remove IRC log stuff. * There is no IRC channel logging by privacy policy of bitreich. Diffstat: M Makefile | 30 ++++-------------------------- M extract-memecount.sh | 1 + D memeuse.awk | 70 ------------------------------- D top10.sh | 17 ----------------- 4 files changed, 5 insertions(+), 113 deletions(-) --- DIR diff --git a/Makefile b/Makefile @@ -1,18 +1,14 @@ .POSIX: MEMECACHE = "/br/gopher/memecache" -ANNNA = "$(HOME)/annna" -IRCLOG = "$(HOME)/.irssi/log/Freenode/\#bitreich-en.log" +ANNNA = "/home/annna/bin" -memecount: plot-memecount.sh top10 media-stats memecount_lin memecount_semilog - cat memecount_lin top10 media-stats memecount_semilog > $@ +memecount: plot-memecount.sh media-stats memecount_lin memecount_semilog + cat memecount_lin media-stats memecount_semilog > $@ media-stats: media-stats.sh ./media-stats.sh $(MEMECACHE) > $@ -top10: top10.sh all_time_weekly_popularity.tsv - ./top10.sh > $@ - memecount_lin: plot-memecount.sh memecount.log ./plot-memecount.sh memecount.log > $@ @@ -23,26 +19,8 @@ memecount_semilog: plot-memecount.sh memecount.log memecount.log: extract-memecount.sh ./extract-memecount.sh $(ANNNA) > $@ -# output format: avg_uses_per_week<tab>tag -all_time_weekly_popularity.tsv: memeuse.tsv all_time_use.tsv - awk -v N_weeks="$$(awk 'END{print $$1/7}' memeuse.tsv)" \ - '{print $$1/N_weeks"\t"$$2}' all_time_use.tsv > $@ - -# output format: total_uses<tab>tag -all_time_use.tsv: memeuse.tsv - cut -f5 memeuse.tsv | sort | uniq -c | sort -r | \ - awk '{print $$1"\t"$$2}' > $@ - -# format: day<tab>date<tab>time<tab>user<tab>tag -memeuse.tsv: memeuse.awk - awk -f memeuse.awk $(IRCLOG) > $@ - clean: - rm -f memeuse.tsv - rm -f all_time_use.tsv - rm -f all_time_weekly_popularity.tsv - rm -f top10 rm -f media-stats rm -f memecount{,.log,_lin,_semilog} -.PHONY: brtv clean +.PHONY: clean DIR diff --git a/extract-memecount.sh b/extract-memecount.sh @@ -4,6 +4,7 @@ annnadir="${1:-$HOME/code/annna}" memefile="modules/hashtags/hashtags.txt" update_annna=yes +fromrevision="${2}" if [ ! -e "${annnadir}/${memefile}" ]; then printf 'error: could not open %s\n' "${annnadir}/${memefile}" DIR diff --git a/memeuse.awk b/memeuse.awk @@ -1,70 +0,0 @@ -#!/usr/bin/awk -f -# get timestamp, user, and tag from irssi log in default format - -function extract_date(s) { - gsub(/--- Day changed ... /, "", s); - - match(s, /[0-9][0-9]/); - day = substr(s, RSTART, RLENGTH); - - match(s, /[0-9][0-9][0-9][0-9]/); - year = substr(s, RSTART, RLENGTH); - - month = s; - gsub(/.*Jan .*/, "01", month); - gsub(/.*Feb .*/, "02", month); - gsub(/.*Mar .*/, "03", month); - gsub(/.*Apr .*/, "04", month); - gsub(/.*May .*/, "05", month); - gsub(/.*Jun .*/, "06", month); - gsub(/.*Jul .*/, "07", month); - gsub(/.*Aug .*/, "08", month); - gsub(/.*Sep .*/, "09", month); - gsub(/.*Oct .*/, "10", month); - gsub(/.*Nov .*/, "11", month); - gsub(/.*Dec .*/, "12", month); -} - -function extract_user(s) { - if (/<.*>/) { # regular message - gsub(/.*<./, "", s); - gsub(/>.*/, "", s); - } else { # action - gsub(/.*\* /, "", s); - gsub(/ .*/, "", s); - } - return s; -} - -function extract_tag(s) { - match(s, /#.*/); - s = substr(s, RSTART, RLENGTH); - gsub(/ .*/, "", s); - gsub(/[!?:,\.]$/, "", s); - return s; -} - -function extract_time(s) { - match(s, /[0-2][0-9]:[0-5][0-9]/); - return substr(s, RSTART, RLENGTH); -} - -{ } - -# update date for subsequent entries -/--- Day changed / { - extract_date($0); - n_days++; -} - -# find tag in current line -/ #[A-Za-z0-9]+/ { - if (! /< annna>/ && ! /#bitreich-en/) { - tag = extract_tag($0); - if (!match(tag, "#nospoil")) { - printf("%s\t%s\-%s\-%s\t%s\t%s\t%s\n", - n_days, year, month, day, - extract_time($0), extract_user($0), tag); - } - } -} DIR diff --git a/top10.sh b/top10.sh @@ -1,17 +0,0 @@ -#!/bin/sh -# print table to stdout containing top 10 memes with averaged usage per week - -printf '\n ' -printf '+------ top 10 (uses per week) ------+\n' -i=1 -head "all_time_weekly_popularity.tsv" | while read u t; do - printf ' ' - printf '| %2d. %-23s %6.3f |\n' \ - "$i" \ - "$t" \ - "$u" - i=$((i+1)) -done - -printf ' ' -printf '+------------------------------------+\n'