Namazu-win32-users-ja(旧)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
 Re: 一太郎 11  用 filter を作ってみたのですが
- From: ken_kojima@xxxxxxxxxxxxxxxxxx
 
- Date: Mon, 15 Oct 2001 17:51:26 +0900
 
- X-ml-name: namazu-win32-users-ja
 
- X-mail-count: 01088
 
一太郎11を使ったfilterに執着している小嶋です。
olemsword.plを参考に、jt.plの若干の手直しをしてみましたので、ここに
載せます。変更はjt.plだけで、rubyの部分は変更ありません。
なお、2.0.7の環境でテストしております。
jt.pl
------------------------------------------------------------
#
# -*- Perl -*-
# $Id: jt.pl,v 1.1 2001/10/15 17:34:25 D.K.C $
# Euc convert with module_nkf
# module_nkf to $cont directly (not using temp_file)
#
package jt;
use strict;
use File::Copy;
use NKF;
require 'util.pl';
require 'gfilter.pl';
my $taroconvpath  = undef;
sub mediatype() {
    return qw(
     application/x-js-taro
    );
}
sub status() {
    $taroconvpath = util::checkcmd('jt_v1_1');
    return 'yes' if defined $taroconvpath;
    return 'no';
}
sub recursive() {
    return 0;
}
sub pre_codeconv() {
    return 0;
}
sub post_codeconv () {
    return 0;
}
sub add_magic ($) {
    my ($magic) = @_;
    # Ichitaro 8, 9, 10, 11
    $magic->addFileExts('\\.jt[dt]$', 'application/x-js-taro');
    return;
}
sub filter ($$$$$) {
    my ($orig_cfile, $cont, $weighted_str, $headings, $fields)
      = @_;
    my $cfile = defined $orig_cfile ? $$orig_cfile : '';
    $$cont = "";
    my $tmpfile = util::tmpnam('NMZ.sjis');
    system("$taroconvpath -f $cfile > $tmpfile");
    open (INPATH,"< $tmpfile") || die "Can't open file :$!\n";
    my $tline = <INPATH>;
    my $aline = <INPATH>;
    my $dline = <INPATH>;
    $fields->{'title'} = codeconv::shiftjis_to_eucjp($tline)
    if (defined $tline);
    $fields->{'author'} = codeconv::shiftjis_to_eucjp($aline)
    if (defined $aline);
    while (my $sentence = <INPATH> ){
          $$cont .=  nkf('-eSZ',$sentence);
        }
    close(INPATH);
    unlink($tmpfile);
    gfilter::line_adjust_filter($cont);
    gfilter::line_adjust_filter($weighted_str);
    gfilter::white_space_adjust_filter($cont);
    $fields->{'title'} = gfilter::filename_to_title($cfile, $weighted_str)
      unless $fields->{'title'};
    gfilter::show_filter_debug_info($cont, $weighted_str,
               $fields, $headings);
    return undef;
}
1;