The source for this notebook is available from my GitHub Gist here .
Spend some time working with natural language processing and it seems to come up just about everywhere. How does it work?
This notebook demonstrates how to use cosine similarity to compare words letter-by-letter based on their physical location on a QWERTY keyboard.
The keyPos map is a hand-built set of X, Y vectors that roughly specify the physical location of each key relative to the other.
keyPos = { "`": {"x": 0, "y": 0}, "1": {"x": 1, "y": 0}, "2": {"x": 2, "y": 0}, "3": {"x": 3, "y": 0}, "4": {"x": 4, "y": 0}, "5": {"x": 5, "y": 0}, "6": {"x": 6, "y": 0}, "7": {"x": 7, "y": 0}, "8": {"x": 8, "y": 0}, "9": {"x": 9, "y": 0}, "0": {"x": 10, "y": 0}, "-": {"x": 11, "y": 0}, "=": {"x": 12, "y": 0},
char(9): {"x": 0, "y": 1}, "q": {"x": 1, "y": 1}, "w": {"x": 2, "y": 1}, "e": {"x": 3, "y": 1}, "r": {"x": 4, "y": 1}, "t": {"x": 5, "y": 1}, "y": {"x": 6, "y": 1}, "u": {"x": 7, "y": 1}, "i": {"x": 8, "y": 1}, "o": {"x": 9, "y": 1}, "p":…