Implement meme did-you-mean recommendation service. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit 6c59e0c19fb8e49e319a5f0db504b29376b4740e DIR parent 47fac1ebd9249ede9d33851a3ce5b1b33db06d2d HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Sat, 6 Aug 2022 21:51:32 +0200 Implement meme did-you-mean recommendation service. Diffstat: M annna-message-common | 10 ++++++++++ 1 file changed, 10 insertions(+), 0 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -1048,6 +1048,16 @@ do if tagline="$(grep "${tag} " "${hashtagfile}")"; then annna-say -s "${server}" -c "${channel}" "${tagline% *}: ${tagline#* }" + else + # Use the special agrep -1 to find similar memes. + didyoumean="$(agrep -i -1 "^#${tag} " "${hashtagfile}" \ + | head -n 5 \ + | cut -d' ' -f 1 \ + | tr "\n" " ")" + if [ -n "${didyoumean}" ]; + then + annna-say -c "${server}" -c "${channel}" "Did you mean: ${didyoumean} ?" + fi fi done