new struct `finger_cost`
[evolve-layout.git] / compare-layouts.sh
bloba5ae33f16bb09aea3bcfcc48fc00d71f11fbaded
1 #!/bin/sh
3 # Dieses kleine Scriptlein prüft für alle Dateien unter ./layouts/ die
4 # Gesamtstrafpunktzahl des beinhalteten Layouts und listet deren Namen
5 # sortiert auf.
6 # Es ist nicht Fehlertolerant, läuft nur unter unixartigen Systemen und
7 # produziert eine nur begrenzt aussagefähige Rangfolge.
9 # Da die Bewertungsfunktion für die Optimierung von Neo 3 geschrieben
10 # wurde, kann sie nur in Grenzen zum Vergleich anderer Layouts
11 # verwendet werden. Eine entsprechende Erweiterung nützt der
12 # Entwicklung von Neo 3 nicht und wird deshalb wahrscheinlich nie
13 # erfolgen.
15 arg0='-p'
16 arg1="$1"
17 arg2="$2"
18 arg3="$3"
19 verbose=""
20 oldvalues=""
22 while test -n "$arg0"; do
23 if test "$arg0" = "-h"; then
24 echo "Usage:"
25 echo " -h display Help and exit"
26 echo " -m test layouts for missing characters" # don't rely on this
27 echo " -p sort by tot. penalty per letter (default)"
28 echo " -t sort by total penalty"
29 echo " -k sort by key position cost"
30 echo " -f sort by fingerrepeats in 2-gramme"
31 echo " -d sort by disbalance of fingers"
32 echo " -r sort by finger repeats between top and bottom"
33 echo " -3 sort by trigrams without handswitching"
34 echo " -j sort by row jumps (rows²/dist)²"
35 echo " -i sort by hand disbalance"
36 echo " -s sort by badly positioned shortcut keys"
37 echo " -u sort by no handswitching after unbalancing"
38 echo " -a sort by movement pattern"
39 echo " -o use old values instead of computing new ones"
40 echo " -v verbose"
41 sort=''
42 arg1=''
43 elif test "$arg0" = "-m"; then
44 sort=''
45 arg1=''
46 c="a b c d e f g h i j k l m n o p q r s t u v w x y z ä ö ü ß , \."
47 for a in layouts/* ; do
48 missing=''
49 for b in $c ; do
50 if test -z "$(head -3 "$a" | grep "$b")"; then
51 missing="$missing ${b#\\}"
53 done
54 if test -n "$missing"; then
55 echo "$a:$missing missing"
57 done
58 elif test "$arg0" = "-p"; then
59 sort='yes'
60 kriterium="tot. penalty per letter"
61 suchzeile="x100 total penalty per letter"
62 elif test "$arg0" = "-t"; then
63 sort='yes'
64 kriterium="total penalty"
65 suchzeile="x10 billion total penalty compared to notime-noeffort"
66 elif test "$arg0" = "-k"; then
67 sort='yes'
68 kriterium="keyposition"
69 suchzeile="mean key position cost in file 1gramme.txt ( [0-9]*.[0-9]* )"
70 elif test "$arg0" = "-f"; then
71 sort='yes'
72 kriterium="fingerrepeats"
73 suchzeile="% finger repeats in file 2gramme.txt ( [0-9]*.[0-9]* )"
74 elif test "$arg0" = "-d"; then
75 sort='yes'
76 kriterium="disbalance of fingers"
77 suchzeile="million keystrokes disbalance of the fingers ( [0-9]*.[0-9]* )"
78 elif test "$arg0" = "-r"; then
79 sort='yes'
80 kriterium="finger repeats between top and bottom"
81 suchzeile="% finger repeats top to bottom or vice versa ( [0-9]*.[0-9]* )"
82 elif test "$arg0" = "-3"; then
83 sort='yes'
84 kriterium="trigrams without handswitching"
85 suchzeile="% of trigrams have no handswitching (after direction change counted x 1 ) ( [0-9]*.[0-9]* )"
86 elif test "$arg0" = "-j"; then
87 sort='yes'
88 kriterium="row jumps (rows²/dist)²"
89 suchzeile="billion (rows²\/dist)² to cross ( [0-9]*.[0-9]* )"
90 elif test "$arg0" = "-i"; then
91 sort='yes'
92 kriterium="hand disbalance"
93 suchzeile="hand disbalance. Left: [0-9]*.[0-9]* %, Right: [0-9]*.[0-9]* % ( [0-9]*.[0-9]* )"
94 elif test "$arg0" = "-s"; then
95 sort='yes'
96 kriterium="badly positioned shortcut keys"
97 suchzeile="badly positioned shortcut keys (weighted)."
98 elif test "$arg0" = "-u"; then
99 sort='yes'
100 kriterium="no handswitching after unbalancing"
101 suchzeile="no handswitching after unbalancing key (weighted)."
102 elif test "$arg0" = "-a"; then
103 sort='yes'
104 kriterium="movement pattern"
105 suchzeile="movement pattern cost (weighted)."
106 elif test "$arg0" = "-v"; then
107 verbose="yes"
108 elif test "$arg0" = "-o"; then
109 oldvalues="yes"
110 else
111 echo "unknown option: ‘$arg0’"
112 arg1="-h"
114 arg0="$arg1"
115 arg1="$arg2"
116 arg2="$arg3"
117 arg3=""
118 done
120 if test -n "$sort"; then
121 tmp=$(tempfile)
122 for a in layouts/* ; do
123 if test -n "$oldvalues"; then
124 ergebnis="$(cat "$a")"
125 else
126 ergebnis="$(./check_neo.py -v --check-string "`cat "$a"`")"
127 if ! test "$ergebnis" = "$(cat "$a")"; then
128 echo "$ergebnis" > "$a"
131 echo "${a##*/}:" >> "$tmp"
132 echo "$ergebnis" >> "$tmp"
133 if test -n "$verbose"; then
134 echo "${a##*/}:"
135 echo "$ergebnis"
137 done
139 echo "Ranking of $kriterium:\n"
141 suchzeile="s/:$// ; t a ; s/^# // ; t b; d ; :b s/$suchzeile// ; t c; d; :c G; s/\\n//; p; d; :a h; d"
143 sed "$suchzeile" "$tmp" | sort -g
145 echo "¹äöüß missing
146 ²ß missing
147 ³ä missing because of M4L
148 ⁴. missing because of M4L
149 missing letters are getting overall penalty" # dont blame me for my english ;-)
151 rm "$tmp"