Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Nice kanji fonts for TeX/LaTeX



>>>>> "Josh" == Josh Glover <jmglov@example.com> writes:

    Josh> On 23/02/06, Marcus Metzler <mocm@example.com> wrote:
    >> I am using Perl and Latex to make make kanji flashcards from
    >> kanjidic using Lingua::JP::Kanjidic, the flashcards style and
    >> the cjk for LaTeX.  I use UTF8 as encoding.

    Josh> Marcus,

    Josh> I was just starting a project to produce high-quality kanji
    Josh> flashcards for my JLPT studies. My idea was to output XML
    Josh> and use a stylesheet to make the flashcards printable from
    Josh> say, Firefox.

    Josh> If you would consider licensing your flashcards under a
    Josh> Creative Commons licence[1], I would love to see what you
    Josh> are doing. Also, consider releasing the Perl code under your
    Josh> favourite Open Source license.

    Josh> I will probably use the Firefox platform to generate my
    Josh> cards, stealing some code from the rikaichan extension[2]
    Josh> (which I have just finished porting to Thunderbird--details
    Josh> to follow in a day or two).

    Josh> So I cannot really help you, except to suggest outputting to
    Josh> XML / XHTML to take advantage of the pretty, anti-aliased,
    Josh> Unicode fonts that people have these days. :)

    Josh> Oh yes, and please do consider sharing your flashcards. I
    Josh> have done some research, and I cannot find high-quality,
    Josh> Free (or even free) flashcards anywhere on the web. I will
    Josh> remedy this problem myself, but it will take some time. If
    Josh> you already have a solution that you would like to share
    Josh> with the world, all the better!

Creating the flash cards is not that hard. The major component ist the

Lingua::JP::Kanjidic module for PERL found here
http://search.cpan.org/dist/Lingua-JP-Kanjidic/

and the latex flashcard style found here
http://ftp.math.utah.edu/pub/mirrors/ctan.tug.org/tex-archive/macros/latex/contrib/flashcards/

With those and the appropriate debian packages for tetex and cjk
(maybe also xemacs ucs support) installed you can create flashcards
with a simple PERL script like this:


#!/usr/bin/perl
binmode(STDOUT, ":utf8");
use Lingua::JP::Kanjidic;
#system("wget http://ftp.monash.edu.au/pub/nihongo/kanjidic.gz";);
# Please see the license at
# http://www.csse.monash.edu.au/groups/edrdg/licence.html
#system("gunzip kanjidic.gz");

my $x = Lingua::JP::Kanjidic->new();
$co = 1;
#while ($co < 20){
#  $x->reset();
  $f =0;
  while(($y = $x->next()) && !$f){
#    if ($y->heiseg()==$co){
    if ($y->heiseg()){
#      $f=1;
    print $y->heiseg(),"\t";

      print $y->kanji()," \@";

#      $n= $y->hiragana;
#      $c = @$n;
#      for ($i=0;$i < $c; $i++){
#	print $y->hiragana->[$i]," ";
#      }

#      $n= $y->katakana;
#      $c = @$n;
#      for ($i=0;$i < $c; $i++){
#	print $y->katakana->[$i]," ";
#      }
#      print "\@";

#      $n= $y->meaning;
#      $c = @$n;
#      for ($i=0;$i < $c; $i++){
#	print $y->meaning->[$i]," ";
#      }
#      print "\@";
#      $n= $y->pinyin;
#      $c = @$n;
#      for ($i=0;$i < $c; $i++){
#	print $y->pinyin->[$i]," ";
#      }
      print "\n";
      $co++;
    }
  }
#}

This is short version which doesn't output latex, but just sorts out
the Heisig Kanji for knquiz on my Zaurus, but you can see the
principle. 
If you want a version with latex output, I can put it on my website,
but since you want to use xml, the example above should tell you all
you need. You should also look at the README of the PERL module for
other options you may need. Some are used in the # comment lines,
which were not needed for knquiz, because it uses kanjidic internally
and just needs to know the knajis you want to learn.

Marcus

-- 
/--------------------------------------------------------------------\
| Dr. Marcus O.C. Metzler        |                                   |
| mocm@example.com            | http://www.metzlerbros.de/        |
\--------------------------------------------------------------------/
 |>>>             Quis custodiet ipsos custodes                 <<<|


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links