Introduction
Introduction Statistics Contact Development Disclaimer Help
Scale agrep errors by hashtag string length. - annna - Annna the nice friendly …
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 2626d2adbaed035067dbbf759afb1edeaa388618
parent 197a022b0448e15a18957ccb5d3d91a94513ca64
Author: Annna Robert-Houdin <[email protected]>
Date: Sun, 7 Aug 2022 21:18:35 +0200
Scale agrep errors by hashtag string length.
Diffstat:
M annna-meme-recommend | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/annna-meme-recommend b/annna-meme-recommend
@@ -12,8 +12,30 @@ hashtagfile="$HOME/bin/modules/hashtags/hashtags.txt"
hashtag="$1"
+# Scale allowed errors by input hashtag length.
+hashtaglen=$(($(utf8expr length "$hashtag") - 1))
+case $hashtaglen in
+0|1)
+ nerrors=1;;
+2|3)
+ nerrors=2;;
+4|5)
+ nerrors=3;;
+6|7)
+ nerrors=4;;
+8|9)
+ nerrors=5;;
+10|11)
+ nerrors=6;;
+12|13)
+ nerrors=7;;
+*)
+ nerrors=8;;
+esac
+
+
# n differences == -4; up to 8
-agrep -i -4 "^#${hashtag} " "${hashtagfile}" \
+agrep -i -$nerrors "^#${hashtag} " "${hashtagfile}" \
| head -n 5 \
| cut -d' ' -f 1 \
| tr "\n" " "
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.