summaryrefslogtreecommitdiffstats
path: root/ktouch/extras/training-gen/perl
diff options
context:
space:
mode:
Diffstat (limited to 'ktouch/extras/training-gen/perl')
-rw-r--r--ktouch/extras/training-gen/perl/README80
-rw-r--r--ktouch/extras/training-gen/perl/dk.config19
-rw-r--r--ktouch/extras/training-gen/perl/en.config15
-rw-r--r--ktouch/extras/training-gen/perl/es.config17
-rwxr-xr-xktouch/extras/training-gen/perl/ktouch-gen.pl180
-rw-r--r--ktouch/extras/training-gen/perl/no.config20
6 files changed, 331 insertions, 0 deletions
diff --git a/ktouch/extras/training-gen/perl/README b/ktouch/extras/training-gen/perl/README
new file mode 100644
index 00000000..557a7468
--- /dev/null
+++ b/ktouch/extras/training-gen/perl/README
@@ -0,0 +1,80 @@
+###################################################################
+#
+# ktouch-gen.pl
+#
+# written by: Steinar Theigmann <steinart@incatel.no>
+# Håvard Frøiland <havard.froiland@chello.no>
+#
+# This file describes how to generate your own training files
+# in 3. steps.
+#
+
+
+Step 1: Collect data
+
+The script needs a data file with words, one word on each line. You
+can create it in your editor, or you can get it generated (see
+below). You will also find some data files in cvs.
+
+Suggestion for creating your own data file using an excisting dictionary. See http://aspell.sourceforge.net for more info.
+
+$ aspell dump master
+
+This will print out a looong list with words in the default
+language. If you have installed other languages that you want to use
+you can write:
+
+$ aspell dump master norwegian
+
+This will print out all the norwegian words found in the norwegian
+ditionary.
+
+Since we don't want this word on the screen, but in a file we do this:
+
+$ aspell dump master > ~/your-word-file
+
+You will now have a file called your-word-file stored in your home directory.
+
+
+Step 2: Creat a configuration file
+
+The config file is shown below.
+
+<---- the file starts here ---->
+length-of-line 20
+number-of-line 10
+
+jf
+kd
+ls
+ca
+nt
+iv
+me
+hr
+go
+bp
+qu
+wn
+cx
+yz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+<---- the file ends here ---->
+
+The length of a line is set to be 20 characters, and each level should
+be 10 lines loong. The first level will only contain combinations of
+"jf" and the next one will contain "jfkd" and so on.
+
+Save it to a file called your-config-file, and we are ready to try the script.
+
+
+Step 3: Generate your training file
+
+To test the script you should do this:
+
+$ perl ktouch-gen.pl your-config-file < your-word-file
+
+This will print out the newly generated training file to your screen,
+if you are happy with it, you could save it to file by doing this.
+
+$ perl ktouch-gen.pl your-config-file < your-word-file > your-training-file.ktouch
diff --git a/ktouch/extras/training-gen/perl/dk.config b/ktouch/extras/training-gen/perl/dk.config
new file mode 100644
index 00000000..409a07ca
--- /dev/null
+++ b/ktouch/extras/training-gen/perl/dk.config
@@ -0,0 +1,19 @@
+length-of-line 12
+number-of-line 6
+
+jf
+kd
+ls
+øa
+nt
+iv
+me
+hr
+go
+bp
+qå
+wn
+cæ
+x
+,.
+ABCDEFGHIJKLMNOPQRSTUVWYZÆØÅ \ No newline at end of file
diff --git a/ktouch/extras/training-gen/perl/en.config b/ktouch/extras/training-gen/perl/en.config
new file mode 100644
index 00000000..bb5df1ae
--- /dev/null
+++ b/ktouch/extras/training-gen/perl/en.config
@@ -0,0 +1,15 @@
+jf
+kd
+ls
+ca
+nt
+iv
+me
+hr
+go
+bp
+qu
+wn
+cx
+yz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
diff --git a/ktouch/extras/training-gen/perl/es.config b/ktouch/extras/training-gen/perl/es.config
new file mode 100644
index 00000000..49b8b32d
--- /dev/null
+++ b/ktouch/extras/training-gen/perl/es.config
@@ -0,0 +1,17 @@
+length-of-line 30
+number-of-line 20
+jf
+kd
+ls
+caá
+ntñ
+iví
+meé
+hr
+goó
+bp
+quü
+wnñ
+cx
+yz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
diff --git a/ktouch/extras/training-gen/perl/ktouch-gen.pl b/ktouch/extras/training-gen/perl/ktouch-gen.pl
new file mode 100755
index 00000000..901df6e0
--- /dev/null
+++ b/ktouch/extras/training-gen/perl/ktouch-gen.pl
@@ -0,0 +1,180 @@
+#!/usr/bin/perl -w --strict
+
+# default values
+$length_of_line = 60;
+$number_of_line = 30;
+
+
+# genword( accumulated, core )
+# This function will generate a random sequens of character
+# containing only characters from accum or core and all words
+# generated will contain at lest on character from core
+sub genword
+{
+ (my $accum, my $core) = @_;
+
+ my $all=$accum.$core;
+ my $res="";
+
+ for(my $i=0;$i<=rand(5);$i++)
+ {
+ my $ran_pos=int(rand(length($all)));
+ $res=$res.substr($all,$ran_pos,1);
+ }
+
+ # check if we have generated a walid word, containig some characters from $core
+ if ($res =~ m/[$core]/)
+ {
+ return $res;
+ }
+ else
+ {
+ return genword($accum,$core);
+ }
+}
+
+# This function will return a list of words containing only characters from
+# accum or core. And all words will contain at lest on echaracter from core.
+# If we can't find enough words, we will use genword to generate enough words
+# to fill the list.
+sub genlist
+{
+ ($accum, $core) = @_;
+ my @res;
+
+ my $all=$accum.$core;
+
+
+ #print "$core\n";
+
+ foreach(@word_list)
+ {
+ chomp($_);
+ if (m/[$core]/ && m/^[($all)][$all]*$/)
+ {
+ push @res,$_;
+ }
+ }
+
+ for(my $i=@res;$i<30;$i++)
+ {
+ push @res,genword($accum,$core);
+ }
+
+ return @res;
+}
+
+
+# Genlevel will generate a level
+sub genlevel
+{
+ ($accum, $core) = @_;
+ my $res = "";
+ my @list = genlist($accum,$core);
+ my $max_lines = $number_of_line;
+ my $max_length = $length_of_line;
+ while($max_lines >0)
+ {
+ my $tmp=$list[rand(@list)-1];
+ $res = $res.$tmp; # first word on line should not have space
+ while($max_length >0)
+ {
+ my $tmp=$list[rand(@list)-1];
+ $res = $res." ".$tmp;
+ $max_length = $max_length - (length($tmp) + 1); # +1 is for counting one extra space for each word
+ }
+ $res = $res."\n";
+ $max_length = $length_of_line;
+ $max_lines = $max_lines - 1;
+ }
+ return $res;
+}
+
+sub rrr
+{
+ print ".";
+ s/\\/\\\\/g; #remove escape character...
+ s/-/\\-/g; #remove any - since this will mean range
+ s/ //g;
+ return $_;
+}
+
+sub heading
+{
+ return
+ "######################################################################\n".
+ "##\n".
+ "# KTouch training file generated ".localtime(time())."\n".
+ "#\n".
+ "# Perl Script written by Steinar Theigmann & Håvard Frøiland.\n".
+ "#\n";
+}
+
+sub usage
+{
+ return
+ "\n".
+ "usage: ktouch-gen config_file\n".
+ " Example: ./ktouch-gen english-conf < english-word-file\n".
+ "\n";
+}
+
+# --------------------- START ----------------------------
+
+if(@ARGV == 0) # exit if there is no config_file specified
+{
+ die usage;
+}
+
+open(CONFIG,$ARGV[0]) # First argument should be config file
+ or die "\ nCan't find config_file: $ARGV[0]\n\n";
+
+# Read in all elements in config file
+while (<CONFIG>)
+{
+ chomp($_);
+
+ if(s/length\-of\-line//)
+ {
+ $length_of_line = $_;
+ }
+ elsif(s/number\-of\-line//)
+ {
+ $number_of_line = $_;
+ }
+ elsif($_) # Add to config if not empty
+ {
+ push @config,$_;
+ }
+}
+
+#foreach(@config)
+#{
+# print "$_\n";
+#}
+#exit 0;
+
+# Read in all words
+while (<STDIN>)
+{
+ chomp($_);
+ if(length($_)>0)
+ {
+ push @word_list, $_;
+ }
+}
+
+print heading;
+
+$accum="";
+$count=0;
+foreach(@config)
+{
+ $count++;
+ print "# Level $count\n";
+ print "$_\n";
+ print genlevel($accum,$_);
+ $accum=$accum.$_;
+ print "\n\n";
+}
+
diff --git a/ktouch/extras/training-gen/perl/no.config b/ktouch/extras/training-gen/perl/no.config
new file mode 100644
index 00000000..2135fce3
--- /dev/null
+++ b/ktouch/extras/training-gen/perl/no.config
@@ -0,0 +1,20 @@
+length-of-line 20
+number-of-line 10
+
+jf
+kd
+ls
+øa
+nt
+iv
+me
+hr
+go
+bp
+qå
+wn
+cæ
+x
+,.
+-
+<>