git://git.jankratochvil.net
/
nethome.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
+make
[nethome.git]
/
src
/
jaxam
diff --git
a/src/jaxam
b/src/jaxam
index
713e826
..
1c0b62c
100755
(executable)
--- a/
src/jaxam
+++ b/
src/jaxam
@@
-1,8
+1,6
@@
#! /usr/bin/perl
#
# $Id$
#! /usr/bin/perl
#
# $Id$
-# for .vimrc:
-# noremap <C-w> V:!~/src/jaxam --wrong --tee --errors-wait-key<cr>
use strict;
use strict;
@@
-24,6
+22,7
@@
my $opt_wrong;
my $opt_errors_wait_key;
my $opt_tee;
my $opt_fast;
my $opt_errors_wait_key;
my $opt_tee;
my $opt_fast;
+my $opt_cycle=10;
$Getopt::Long::ignorecase=0;
$Getopt::Long::bundling=1;
$Getopt::Long::ignorecase=0;
$Getopt::Long::bundling=1;
@@
-35,6
+34,7
@@
die if !GetOptions(
"errors-wait-key"=>\$opt_errors_wait_key, # Only for -w|--wrong.
"tee!" =>\$opt_tee, # Output all the read lines. Only for -w|--wrong.
"fast!" =>\$opt_fast,
"errors-wait-key"=>\$opt_errors_wait_key, # Only for -w|--wrong.
"tee!" =>\$opt_tee, # Output all the read lines. Only for -w|--wrong.
"fast!" =>\$opt_fast,
+ "cycle=s" =>\$opt_cycle,
);
$opt_log||=$opt_edict.".log";
);
$opt_log||=$opt_edict.".log";
@@
-51,11
+51,22
@@
my $T;
my @R;
my %identify;
my %kana_to_r;
my @R;
my %identify;
my %kana_to_r;
+my $result_count=0;
+
+sub siglog($)
+{
+ my($a)=@_;
+
+ return 0 if !$a;
+ my $sig=($a>0)-($a<0);
+ return $sig*log(abs $a);
+}
sub schedule($$%)
{
my($r,$exam_from,%args)=@_;
sub schedule($$%)
{
my($r,$exam_from,%args)=@_;
+ return if $r->{"orig"}=~/\Q(laceno)\E/;
my $time=$args{"time"}||time();
my $sum=0;
for my $result (@{$r->{"result"}}) {
my $time=$args{"time"}||time();
my $sum=0;
for my $result (@{$r->{"result"}}) {
@@
-71,7
+82,19
@@
sub schedule($$%)
# 1/log(2+$age): big.. big importance
# 1/log(2+$age): 0..small importance
$sum+=1/log(2+$age)*$ok{$result->{"ok"}};
# 1/log(2+$age): big.. big importance
# 1/log(2+$age): 0..small importance
$sum+=1/log(2+$age)*$ok{$result->{"ok"}};
+ if (!$result->{"ok"}) {
+ my $count_diff=$result_count-$result->{"count"};
+ $count_diff-=$opt_cycle;
+ $sum-=siglog($count_diff);
+ }
}
}
+ my $scale=1;
+ if ($r->{"pri"}) {
+ my $abspri=$r->{"pri"};
+ $abspri=1/(-$abspri) if $abspri<0;
+ $abspri=2 if $abspri<2;
+ $scale=log($abspri)*($r->{"pri"}<0 ? -1 : +1);
+ }
my $arr=[];
if ($T->exists($sum)) {
$arr=$T->select($sum)->{"arr"};
my $arr=[];
if ($T->exists($sum)) {
$arr=$T->select($sum)->{"arr"};
@@
-139,11
+162,12
@@
sub result($$$%)
." exam_from=$exam_from ok=$ok: ".identify($r)."\n";
close LOG_APPEND or die "close \"$opt_log\": $!";
}
." exam_from=$exam_from ok=$ok: ".identify($r)."\n";
close LOG_APPEND or die "close \"$opt_log\": $!";
}
-
+ $args{"time"}||=time();
push @{$r->{"result"}},{
push @{$r->{"result"}},{
- "time"=>
time()
,
+ "time"=>
$args{"time"}
,
"exam_from"=>$exam_from,
"ok"=>$ok,
"exam_from"=>$exam_from,
"ok"=>$ok,
+ "count"=>$result_count++,
};
}
};
}
@@
-176,6
+200,7
@@
sub edict_line_parse(;$)
$r->{"kana"}=$r->{"kanji"};
delete $r->{"kanji"};
}
$r->{"kana"}=$r->{"kanji"};
delete $r->{"kanji"};
}
+ $rest=~s{^(|.*/)[(]pri([+-]\d+)[)]/}{$r->{"pri"}=$2;$1;}e;
while ($rest) {
$rest=~s{^\s*([^/]+?)\s*/}{}
or do { warn "Unparsable english: $s\n"; $errors_wait_key_count++; return; };
while ($rest) {
$rest=~s{^\s*([^/]+?)\s*/}{}
or do { warn "Unparsable english: $s\n"; $errors_wait_key_count++; return; };
@@
-212,7
+237,6
@@
sub edict_read($)
);
while (<EDICT>) {
my $r=edict_line_parse() or next;
);
while (<EDICT>) {
my $r=edict_line_parse() or next;
- next if /\Q(laceno)\E/;
push @R,$r;
push @{$kana_to_r{$r->{"kana"}}},$r;
keys(%check);
push @R,$r;
push @{$kana_to_r{$r->{"kana"}}},$r;
keys(%check);
@@
-253,7
+277,7
@@
sub log_read($)
my $gmtime=$localtime-($zonepm."1")*($zonehour*60+$zoneminute);
my $r=$identify{$identify}
or do { warn "Word not found from line: $_\n"; next; };
my $gmtime=$localtime-($zonepm."1")*($zonehour*60+$zoneminute);
my $r=$identify{$identify}
or do { warn "Word not found from line: $_\n"; next; };
- result $r,$exam_from,$ok,"write"=>0;
+ result $r,$exam_from,$ok,"write"=>0
,"time"=>$gmtime
;
}
close LOG_READ or die "close \"$pathname\": $!";
}
}
close LOG_READ or die "close \"$pathname\": $!";
}