Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
| -rwxr-xr-x | mapScore.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mapScore.py b/mapScore.py index 1a8dfa9..4f69847 100755 --- a/mapScore.py +++ b/mapScore.py @@ -17,9 +17,20 @@ def makeMap(filename): break return l +def scoreWord(word,mmap): + pc=word[0] + s=0 + for c in word: + #manhattan dist + s+=abs(mmap[ord(pc)][0]-mmap[ord(c)][0]) + s+=abs(mmap[ord(pc)][1]-mmap[ord(c)][1]) + pc=c + return s + + def main(argv): - import json - json.dump(makeMap(argv[1]),sys.stdout) + mmap=makeMap(argv[1]) + print(scoreWord('ads',mmap)) if __name__ == '__main__': main(sys.argv) |