From 8048f6351fb4611134c2f6e2d9129ec025376914 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 3 Oct 2019 15:09:33 +0200 Subject: doc: Add hand/finger stats to all layouts Adds a preprocessing step to the doc HTML document. --- .gitignore | 6 ++---- doc/index.html | 34 ++++++++++++++++++---------------- doc/style.css | 35 +++++++++++++++++++++++++++++++++++ gen.sh | 34 ++++++++++++++++++++++++++++------ lulua/stats.py | 40 +++++++++++++++++++++++++++++++--------- 5 files changed, 114 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 62a43bc..41a91da 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,8 @@ __pycache__ .eggs/ .coverage .mypy_cache/ -doc/*.svg -doc/*.yaml -doc/*.xmodmap -doc/letterfreq.json +doc/_build +doc/_temp .ninja_* build.ninja stats/ diff --git a/doc/index.html b/doc/index.html index e5f7973..f9daf88 100644 --- a/doc/index.html +++ b/doc/index.html @@ -178,18 +178,9 @@
+ #include "ar-lulua-fingerhand.html"
-
-
-
-
-
-

Button heatmap

-
-
-
-
@@ -205,6 +196,7 @@
+ #include "ar-asmo663-fingerhand.html"
@@ -229,6 +221,7 @@
+ #include "ar-linux-fingerhand.html"
@@ -253,6 +246,7 @@
+ #include "ar-malas-fingerhand.html"
@@ -268,10 +262,12 @@ optimized for typing speed only, claiming 35% faster typing compared to the currently used layouts. - However the choice to put ي in the top - row seems odd and suggests the authors did not take the time to review - the layout manually, given this letter is the third most frequent one - even in their own research. + However the decision to put ي in the top + row seems odd. + + Assigning the same left index finger to ا + ي و, which are three of the most frequent letters, heavily + strains this particular finger.

@@ -281,6 +277,7 @@
+ #include "ar-osman-fingerhand.html"
@@ -313,6 +310,7 @@
+ #include "ar-khorshid-fingerhand.html"
@@ -328,8 +326,11 @@ They claim a 36% improvement over the standard keyboard based on their criteria for ergonomic layouts. - However in their layout from figure 8 both letters ب ر are in suboptimal positions. + However in their layout from figure 8 the letters ل ب ر are in suboptimal positions. + + Also it seems their algorithm favors the bottom row instead of the + easier to use top row.

@@ -339,6 +340,7 @@
+ #include "ar-phonetic-fingerhand.html"
diff --git a/doc/style.css b/doc/style.css index 5aa9a55..0f137c4 100644 --- a/doc/style.css +++ b/doc/style.css @@ -106,3 +106,38 @@ div.indepth-card { .lbox { margin: 0 5vw; } +/* for hand/finger stats */ +div.fingerhandstats { + text-align: center; + display: flex; +} +div.fingerhandstats div.fingers { + display: flex; +} +div.fingerhandstats div.fingers div { + margin: 0.1em; + overflow: hidden; +} +div.fingerhandstats .left { + margin-right: 0.5em; +} +div.fingerhandstats .right { + margin-left: 0.5em; +} +/* keep in sync with render-svg.css */ +div.fingerhandstats .fingers .little { + border: 0.1em solid #dc322f; /* red */ +} +div.fingerhandstats .fingers .ring { + border: 0.1em solid #268bd2; /* blue */ +} +div.fingerhandstats .fingers .middle { + border: 0.1em solid #d33682; /* magenta */ +} +div.fingerhandstats .fingers .index { + border: 0.1em solid #6c71c4; /* violet */ +} +div.fingerhandstats .fingers .thumb { + border: 0.1em solid #2aa198; /* cyan */ +} + diff --git a/gen.sh b/gen.sh index b9b9028..77fbf81 100755 --- a/gen.sh +++ b/gen.sh @@ -64,9 +64,28 @@ rule mkdir rule letterfreq command = lulua-analyze -l ar-lulua letterfreq < \$in > \$out -### build targets ### -build \$docdir/letterfreq.json: letterfreq \$statsdir/ar-lulua/all.pickle +rule analyze-fingerhand + command = lulua-analyze -l \$layout fingerhand < \$in > \$out + +rule cpp + command = gcc -E -x c -nostdinc -MMD -MF \$out.d -C -P -I \$docdir/_temp \$in -o \$out + depfile = \$out.d + deps = gcc + +rule cp + command = cp \$in \$out +### build targets ### +build \$docdir/_build: mkdir +build \$docdir/_build/fonts: mkdir +build \$docdir/_temp: mkdir + +build \$docdir/_build/index.html: cpp \$docdir/index.html || \$docdir/_build +build \$docdir/_build/letterfreq.json: letterfreq \$statsdir/ar-lulua/all.pickle || \$docdir/_build +build \$docdir/_build/style.css: cp \$docdir/style.css || \$docdir/_build +build \$docdir/_build/lulua-logo.svg: cp \$docdir/lulua-logo.svg || \$docdir/_build +build \$docdir/_build/fonts/IBMPlexArabic-Regular.woff2: cp \$docdir/fonts/IBMPlexArabic-Regular.woff2 || \$docdir/_build/fonts +build \$docdir/_build/fonts/IBMPlexArabic-Thin.woff2: cp \$docdir/fonts/IBMPlexArabic-Thin.woff2 || \$docdir/_build/fonts EOF for l in $layouts; do @@ -87,13 +106,16 @@ build \$statsdir/${l}/arwiki.pickle: write-arwiki \$corpusdir/arwiki/arwiki-2019 build \$statsdir/${l}/all.pickle: combine \$statsdir/${l}/bbcarabic.pickle \$statsdir/${l}/aljazeera.pickle \$statsdir/${l}/tanzil.pickle \$statsdir/${l}/arwiki.pickle || \$statsdir/${l} -build \$docdir/${l}.svg: render-svg +build \$docdir/_build/${l}.svg: render-svg || \$docdir/_build + layout = ${l} + +build \$docdir/_temp/${l}-heat.yaml: analyze-heat \$statsdir/${l}/all.pickle || \$docdir/_temp layout = ${l} -build \$docdir/${l}-heat.yaml: analyze-heat \$statsdir/${l}/all.pickle +build \$docdir/_build/${l}-heat.svg: render-svg-heat \$docdir/_temp/${l}-heat.yaml || \$docdir/_build layout = ${l} -build \$docdir/${l}-heat.svg: render-svg-heat \$docdir/${l}-heat.yaml +build \$docdir/_temp/${l}-fingerhand.html: analyze-fingerhand \$statsdir/${l}/all.pickle || \$docdir/_temp layout = ${l} EOF @@ -101,7 +123,7 @@ done for l in $layoutsXmodmap; do cat <') + fingerOrder = {LEFT: list (FingerType), RIGHT: reversed (FingerType)} + for hand in Direction: + handpct = hands[hand]/buttonPresses*100 + print (f'
\n\t
{handpct:.2f}%
') + print ('\t
') + for finger in fingerOrder[hand]: + fingerpct = fingers[(hand, finger)]/buttonPresses*100 + # finger width is relative to parent (i.e. hand) + fingerwidth = fingers[(hand, finger)]/hands[hand]*100 + print (f'\t\t
{fingerpct:.2f}
') + print ('\t
\n\t
') + print ('
') + def main (): parser = argparse.ArgumentParser(description='Process statistics files.') parser.add_argument('-l', '--layout', metavar='LAYOUT', help='Keyboard layout name') @@ -256,6 +276,8 @@ def main (): sp.set_defaults (func=triadfreq) sp = subparsers.add_parser('keyheatmap') sp.set_defaults (func=keyHeatmap) + sp = subparsers.add_parser('fingerhand') + sp.set_defaults (func=fingerHand) logging.basicConfig (level=logging.INFO) args = parser.parse_args() -- cgit v1.2.3