Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
Diffstat (limited to 'mapScore.py')
| -rwxr-xr-x | mapScore.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mapScore.py b/mapScore.py index 2385106..61a5259 100755 --- a/mapScore.py +++ b/mapScore.py @@ -17,23 +17,24 @@ def makeMap(filename): break return l -def scoreWord(word,mmap): - pc=word[0] +def scoreWord(word,mm): + pc=word[0] or ' ' 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]) + s+=abs(mm[ord(pc)][0]-mm[ord(c)][0]) + s+=abs(mm[ord(pc)][1]-mm[ord(c)][1]) pc=c return s def main(argv): mm=makeMap(argv[1]) while 1: - line = sys.stdin.readline() - if not line: - break - w=line.strip() + line = sys.stdin.readline() + if not line: + break + w=line.strip() + if w: print(scoreWord(w,mm),w,sep='\t') if __name__ == '__main__': |