plugins for wvkbd using swipeGuess
predictor: more consistent compound behavior
| -rwxr-xr-x | predictor.sh | 18 |
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 |