Sunday, February 16, 2014

Before and after



A simple search of all words occurring immediately before and after a target expression - usually a single word.

The result is something like a concordance, but all (up to 220 of each) of the neighbors are show sorted by frequency. More common neighbors closer to the target.

Each of the neighbors is a hyperlink to a new Before and after search with the neighbor moved to the center.

Here's an example from the barb sanders dream set.

The target is "station".



Note the many senses of station that are displayed.

More generic words have more neighbors.


Tuesday, February 4, 2014

Keyboard

I saw a post about Patrick Wied's Keyboard Heatmap (http://www.patrick-wied.at/projects/heatmap-keyboard/) and decided to make my own.

Basically split a text field into individual character and count how many of each are present.

But for a keyboard 'a' and 'A' map to the same key. So do '#' and '3'.

What other keys could I map?

Shift = a capitalized letter followed by a non-capital letter. The Shift also gets bump if any of ~!@#$... are present.

No effort is made to distinguish between Left and Right Shift.

Caps Lock? I assume Caps Lock is on if I find a sequence beginning with 2 or more capitalized letters. But, because the end of a Cap Locks sequence matches the Shift key condition, I need to subtract the Caps Lock count from Shift's. No effort is made to distinguish between Left and Right Shift.

Enter = the sum of \r and \n in the split text. (Split the text using /^[\r\n]$/gm and take the length of the array.)

Tab = the sum of all \t. These don't show up in the split so I search for them with a regex in the original test.

I also thought about mapping the Back key to the number of times a list of commonly misspelled words are matched.

I use some css to display the keys in a QWERTY (only) layout.

To show the frequency of usage I first find the most pressed key and scale the background color of all keys to it. The most pressed key (space) will be the brightest red.

You can see the count for each key by placing your mouse over a key. The count shows as a tool-tip.

Since most keys a much lower in frequency that the top keys I used a log scale for the final result.

I tested this with several dream texts and, not surprisingly, they show the same ranking pattern Space, E, A, T, O, etc.

Things to test DE, FR, ES, PR texts. These contain characters which my code does not handle.

Here's the Keyboard for a dream log.











Here's one for a javascript file.
The big difference is in the use of parenthesis, braces, semicolons, equals and pipes '|'.