simon.proctor has asked for the wisdom of the Perl Monks concerning the following question:

I've decided to learn Japanese and I'm now on my 5th week of the course. The amount of material coming my way is quite large (especially the vocabulary) so I was thinking about how I could get Perl to help me learn characters and pick up vocabulary.

What I want is to have this tool easily extendable as I learn more. For example, to begin with we are learning words using Romaji spelling. So simple word matching should be easy. However, we are also learning hiragana (and no doubt will soon learn katakana) so I want to be able to extend/switch to unicode matching at a future point.

I have an idea of an application written in Perl/Tk with a virtual keyboard and some kind of gui screen that presents a question and echos my answer.

Trouble is, I know virtually nothing about Tk. Additionally, I am not sure how I would enter the hiragana (etc) except via a *fake* keyboard window that has the characters that I can click on.

Does this sound correct? Could I just use Unicode on a Win2K system and have the Perl/Tk do the right thing? Ideally I'd like this to be portable to other platforms so relying on an ime from Microsoft isn't ideal. I also don't fancy having to learn raw unicode ;).

I had considered a web application but I think the opportunnity to learn perl/tk to be quite a good one.

Any thoughts, resources, book links that you think may be of use would be gratefully accepted!

TTFN,

SP

Replies are listed 'Best First'.
Re: RFC: Japanese Language Quiz Program
by barrd (Canon) on Oct 17, 2003 at 10:40 UTC
    Hello simon.proctor,
    Any thoughts, resources, book links that you think may be of use would be gratefully accepted!
    Whilst I realise that this reply at first might not seem all that helpful seeing as you are obviously using Windows (Win2k) please persevere.

    There is a Freeware programme called 'Nuku' which unfortunately only seems to be available for Apple Macs. However it does pretty much everything you have asked in your post and maybe you have access to a Mac through work or a friend?

    If so it would give you some pointers if you still want to create a Perl app with Tk (if only so that you can screengrab all the characters ;). It would also be a good visualisation tool for creating the "*fake keyboard*" layout.

    Its pretty feature rich (this is from the Readme "US spelling"):

    How? Start it. Start clicking. Nuku will start in Quiz Mode the first time you start it, the mode in which you click upon the translation of the character shown in the upper left corner. It will measure your score, tell you when you are wrong, and in that case, what you did wrong. Thi +s is the primary objective of Nuku. The other mode is Learning Mode, whe +re you simply click on the translated syllable you are interested in, and Nuku will show the corresponding Japanese character. ... Romanization systems? There are several methods of romanizing Japanese kana, the collective word for both hiragana and katakana. The three main ones are Hepburn, Kunrei and Nihon-shiki. The official system is Kunrei, which does not correspond to the actual pronounciation of the characters. However, th +is is the main advantage of Hepburn, it is less regular than Kunrei, but you can also tell how to pronounce words from the romanization. The third system, Nihon-shiki, is basically Kunrei, slightly altered to no +t map two kana with the same sound onto one romanization.

    If you don't have access to a Mac sorry for wasting your time, but I hope this might be of some benefit if you do.

    And no, I have nothing to do with the programme what-so-ever :)

Re: RFC: Japanese Language Quiz Program
by Courage (Parson) on Oct 17, 2003 at 16:12 UTC
    Be aware that perlTk with Unicode support is currently in beta stage.

    I can share a program written for WinCE devices (hence strange geometry) that uses Tcl::Tk and provides English/Korenan/Japanese/Chinese dictionary searching (Japanese, Chinese taken from Monash university, thanks them!)
    Also it allows searching in Unihan database.

    use strict; $::unipath='\storage card\unicode'; #my %uniexcl = (); my $o='5669'; my $last=0; use Tcl::Tk qw/:perlTk/; my $mw=tkinit; my $int=$mw->interp; my $lfont = "-*-Arial Unicode MS--R---*-300-*-*-*-*-*-*"; my $cfont = "-*-Arial Unicode MS--R---*-200-*-*-*-*-*-*"; my $mfont = "-*-Arial Unicode MS--R---*-100-*-*-*-*-*-*"; my $tw=$mw->Text(-wrap=>'char',-font=>$cfont,-height=>4,-width=>20)->p +ack; $tw->tagConfigure('large',-font=>$lfont); $tw->tagConfigure('descr',-font=>$mfont,-foreground=>'blue4'); $tw->tagConfigure('def',-font=>$mfont,-foreground=>'red4'); my $fbot=$mw->Frame()->pack; my $ew=$fbot->Entry(-font=>$mfont,-textvariable=>\$o,-width=>10)->pack +(-side=>'left'); my ($gdef,$ghier)=('',''); #my $e1w=$fbot->Entry(-font=>$lfont,-textvariable=>\$ghier,-width=>3)- +>pack(-side=>'left'); my $e2w=$fbot->Entry(-font=>$mfont,-textvariable=>\$gdef)->pack(-side= +>'left'); my $fr=$mw->Frame()->pack; my $bw=$fr->Button(-text=>'test', -command=>sub{ $tw->insert('insert',eval qq/"\\x{$o}"/); })->pack(-side=>'left'); my $bschw=$fr->Button(-text=>'search', -command=>sub{ my ($r,$what)=($tw->get('insert','insert + 1 chars'),''); if ($r eq '+') { $what=$tw->get('insert + 1 chars','insert + 5 chars'); } else { #use Devel::Peek; #Dump($r); use Encode; Encode::_utf8_on($r);# will go away once Tcl bug will be fixed #Dump($r); $what=unpack("H*",encode('ucs2',$r)); } #print STDERR qq/=$what=\n/; $ghier = eval qq/"\\x{$what}"/; $tw->insert('end',"$ghier\n",'large'); $tw->insert('end',$_,/kDefinition/i?'def':'descr') for lookup_unihan($what); })->pack(-side=>'left'); my $bscodew=$fr->Button(-text=>'(#)', -command=>sub{ my $what=$o; $tw->insert('end',eval qq/"\\x{$what}\n"/); $tw->insert('end',$_,/kDefinition/i?'def':'descr') for lookup_unihan($what); })->pack(-side=>'left'); my $blookupj=$fr->Button(-text=>'l-J', -command=>sub{ my $what=quotemeta $o; unless (defined $::jmdict) { open my $fhjm, "<$::unipath\\tkjmdict-0.94\\jmdict_en.bin"; binmode $fhjm; local $/; $::jmdict=<$fhjm>; } while ($::jmdict=~/^.*?$what.*?$/img) { my ($t0,$t1)=($-[0],$+[0]); $tw->insert('end',substr($::jmdict,$t0,$t1-$t0).qq/\n/,'descr'); $int->update; } })->pack(-side=>'left'); my $blookupch=$fr->Button(-text=>'l-CH', -command=>sub{ my $what=quotemeta $o; unless (defined $::chdict) { open my $fhch, "<$::unipath\\CHIN\\cedict.utf8"; binmode $fhch; local $/; $::chdict=<$fhch>; } while ($::chdict=~/^.*?$what.*?$/img) { my ($t0,$t1)=($-[0],$+[0]); $tw->insert('end',substr($::chdict,$t0,$t1-$t0).qq/\n/,'descr'); $int->update; } })->pack(-side=>'left'); my $blookupch=$fr->Button(-text=>'l-KR', -command=>sub{ my $what=quotemeta $o; unless (defined $::krdict) { open my $fhkr, "<$::unipath\\korean\\kor2eng.ut8"; binmode $fhkr; local $/; $::krdict=<$fhkr>; } while ($::krdict=~/^.*?$what.*?$/img) { my ($t0,$t1)=($-[0],$+[0]); $tw->insert('end',substr($::krdict,$t0,$t1-$t0).qq/\n/,'descr'); $int->update; } })->pack(-side=>'left'); my $bclr=$fr->Button(-text=>'clear',-command=>sub{ $tw->delete('1.0','end'); })->pack(-side=>'left'); my $bgen=$fr->Button(-text=>'gen_idx', -command=>sub{ 0 && do_idx(); })->pack(-side=>'left'); my $cnt=0; sub do_idx { if(!$last){ $o='Testing... done!'; return; } open my $fh, "<$::unipath\\unihan.txt"; binmode $fh; open my $fhoidx, ">$::unipath\\unihan-idx.idx"; binmode $fhoidx; my $lo=''; my ($fpos,$fpos0)=(0,0); while(<$fh>) { $fpos=$fpos0; $fpos0=tell $fh; if (/^u\+(\w+)/i) { next if $1 eq $lo; $lo=$1;$o=$1; $int->update; printf $fhoidx "%4s%08d\n",$lo,$fpos; # $tw->insert('end',eval qq/"\\x{$lo}"/); while(<$fh>=~/^u\+$o/io){ # print "$_"; } } last if $last; #last if ++$cnt>100000; # $int->update; } } $int->MainLoop; # # look up in unihan database. # reads index file if necessary sub lookup_unihan { my $what=shift; unless (defined $::idx) { open my $fhiidx, "<$::unipath\\unihan-idx.idx"; binmode $fhiidx; local $/; $::idx=<$fhiidx>; } $::idx=~/^$what(.*?)$/im; open my $fh, "<$::unipath\\unihan.txt"; binmode $fh; seek $fh, $1, 0; my @res; while (local $_ = <$fh>) { last unless /^u\+$what/i; s/\t/ /g; push @res, $_; } return @res; }

    Courage, the Cowardly Dog

Re: RFC: Japanese Language Quiz Program
by deliria (Chaplain) on Oct 17, 2003 at 21:02 UTC
    Aside from the application Barrd pointed out, there also is an RPG game for linux/windows which helps you in learning Japanese.

    It tackled the problem of westerners not having japanese keyboards by letting the player enter the Katakana/Hiragana or Kanji characters / words in phonetic Romaji style.

    Project LRNJ

    Hth, Deliria.
Re: RFC: Japanese Language Quiz Program
by justinNEE (Monk) on Oct 18, 2003 at 21:28 UTC

    It seems like it would be easier (for you) to store/process all the information using romaji. You could take your input this way also. You type in romaji but the japanese characters come up.

    But I think I would look for an exsisting app since soon you will need to learn your vocab with kanji mixed in.

    I know what you mean about wanting a customized tutorial though. On one hand, the object is to learn japanese. But unfortunately, you still have to pass the class so you have to learn THEIR vocabulary lists. ugh.

    Here is a good place to learn the characters because you can learn one line at a time:
    http://www.bigtrouble.com/kana