plugins for wvkbd using swipeGuess
predictor: more consistent compound behavior
Zach DeCook 2022-05-17
parent 88dbe5d · commit 7a2afa7
-rwxr-xr-xpredictor.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/predictor.sh b/predictor.sh
index ccbb21f..0a5a932 100755
--- a/predictor.sh
+++ b/predictor.sh
@@ -1,6 +1,7 @@
#!/bin/sh
sock="$XDG_RUNTIME_DIR/predictor.sock"
lw="$XDG_RUNTIME_DIR/pred.lastword"
+tw="$XDG_RUNTIME_DIR/pred.tfw"
complete="$XDG_RUNTIME_DIR/pred.complete.bool"
words=~/.local/share/sxmo/words.txt
twow=~/.local/share/sxmo/count_2w.txt
@@ -11,9 +12,16 @@ saveWord(){
IFS=''
while read -r word; do
echo "$word"
- word="$(printf "$word" |sed 's/^ //g' |tee "$lw")"
+ if test "${word:0:1}" = " "; then
+ printf " " >> "$lw"
+ mv "$lw" "$tw"
+ word="$(printf %s "${word:1}"| tee "$lw")"
+ else
+ printf %s "$word" >> "$lw"
+ word="$(cat "$lw")"
+ fi
rm -f "$complete"
- cat "$words" "$twow" | quick5 "$word" | sed 's/\t/ \t/g'|sed 's/$/ /g' >> "$sock"
+ cat "$words" "$twow" | quick5 "$word" >> "$sock"
done
}
typeSomehow(){
@@ -39,15 +47,15 @@ while read -r swipe; do
printf " " >> "$lw"
rm -f "$complete"
cat "$twow" | quick5 "$(cat "$lw")" >> "$sock"
- rm -f "$lw"
+ mv "$lw" "$tw"
fi
elif test "$swipe" = "$(echo -e "\x08")"; then
lastword="$(cat "$lw")"
printf %s "$lastword" | sed 's/.$//g' > "$lw"
elif test "$swipe" = "$(echo -e "\n")"; then
- rm -f "$lw"
+ rm -f "$lw" "$tw"
else
- printf "$swipe" >> "$lw"
+ printf %s "$swipe" >> "$lw"
fi
fi
done