22
22
use Gtk2 ' -init' ;
23
23
use Getopt::Long;
24
24
use Pod::Usage;
25
+ use lib ' lib/' ;
26
+ use Hyphen;
25
27
26
28
# defines
27
29
my $font = " courier new 24" ;
44
46
my $back_ptr = -1;
45
47
my $prev_back_ptr = -1;
46
48
my $fast_forward = 0;
49
+ my $hyphen = Text::Hyphen-> new(' min_word' => 17,
50
+ ' min_prefix' => 8, ' min_suffix' => 8, ' min_part' => 7);
47
51
48
52
49
53
# ###################
@@ -66,6 +70,22 @@ sub get_line
66
70
}
67
71
68
72
my @words_buffer ;
73
+ sub limit_word_length
74
+ {
75
+ my $i = 0;
76
+ for ($i = 0; $i <= $#words_buffer ; ++$i ) {
77
+ my @tmp_buffer = ();
78
+ printf (" word: $i = " .$words_buffer [$i ]." \n " );
79
+ @tmp_buffer = $hyphen -> hyphenate($words_buffer [$i ]);
80
+ # if hyphenate happened, replace original word by hyphen array
81
+ if ($#tmp_buffer > 0) {
82
+ $tmp_buffer [$_ ] .= " -" foreach (0 .. $#tmp_buffer - 1);
83
+ splice (@words_buffer , $i , 1, @tmp_buffer );
84
+ }
85
+ }
86
+ # printf ($foo->hyphenate('Schiffahrt')."\n");;
87
+ }
88
+
69
89
my @back_buffer ;
70
90
my $sentence_cnt = 0;
71
91
sub get_next_word
@@ -100,6 +120,8 @@ sub get_next_word
100
120
@words_buffer = split (' ' , $line );
101
121
}
102
122
$sentence_cnt ++;
123
+ limit_word_length();
124
+ printf ($line ." \n " );
103
125
unshift (@back_buffer , $line );
104
126
pop (@back_buffer ) if ($#back_buffer > 10);
105
127
}
@@ -108,6 +130,7 @@ sub get_next_word
108
130
# line into @words_buffer
109
131
if ($#words_buffer < 0) {
110
132
@words_buffer = split (' ' , $back_buffer [$back_ptr ]);
133
+ limit_word_length();
111
134
}
112
135
# if @words_buffer empty, proceed with next line
113
136
$back_ptr -- if ($#words_buffer <= 0);
@@ -187,8 +210,8 @@ sub set_text
187
210
$next_shot += $timeout / 2 if ($word_length > 10);
188
211
$next_shot += $timeout / 2 if ($word_length > 14);
189
212
$next_shot += $timeout / 2 if ($word_length > 18);
190
- $next_shot += $timeout * 1.5 if ($word =~ / .*[\. !?;]$ / );
191
213
$next_shot += $timeout / 2 if ($word =~ / .*,$ / );
214
+ $next_shot += $timeout * 1.5 if ($word =~ / .*[\. !\? ;]«?$ / );
192
215
193
216
# search for vowel from start to the mid of the word,
194
217
# this will be the focuspoint of the word
@@ -354,7 +377,6 @@ sub main
354
377
return TRUE;
355
378
}
356
379
357
-
358
380
main();
359
381
360
382
0 commit comments