2 # *******************************************************************************
3 # * Copyright (C) 2002-2004, International Business Machines Corporation and *
4 # * others. All Rights Reserved. *
5 # *******************************************************************************
9 if "%OS%" == "Windows_NT" goto WinNT
10 perl -W -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
14 if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
15 if %errorlevel% == 9009 echo You do not have Perl in your PATH.
21 # This perl script updates the filters in the transliterator index file.
22 # It does so in a dumb way:
27 # For transliterators using NFKD, or not using Lower in this way, you
28 # will have to hand-edit the index file.
30 # This script writes a new index file. The new file has to then be
31 # hand-edited and checked before use; it contains comments indicating
32 # old lines that were replaced.
38 my $DIR = "../../text/resources";
39 my $CLASSES = "../../../../../classes";
41 #GetOptions('dir=s' => \$DIR,
43 # '<>' => \&usage) || die;
49 print STDERR "$DIR is not a directory\n";
56 # print "Usage: $me [-dir <dir>] [-id <id>]\n";
57 # print " --dir <dir> Specify the directory containing the\n";
58 # print " Transliterator_*.txt files\n";
59 # print " --id <id> Specify a single ID to transform, e.g.\n";
60 # print " Fullwidth-Halfwidth\n";
66 ######################################################################
67 # Convert the index file from Java to C format
68 # Assume lines are of the form:
69 # <ID>:alias:<FILTER>;<REMAINDER>
75 $IN = "Transliterator_index.txt";
77 open(IN, "$DIR/$IN") or die;
78 open(OUT, ">$DIR/$OUT") or die;
81 # Look for lines that are aliases with NF*
82 if (/^([^:]+):alias:(\[.+?);\s*((NF[^\s]*?)\s*;.+)$/i) {
89 # If it comes before NF* then adjust accordingly
90 if (/^([^:]+):alias:(\[.+?);\s*(Lower\s*;.+)$/i) {
92 if (length($2) < length($oldset)) {
97 print STDERR "$id $NFXD $lower\n";
98 my $set = getSourceSet($id, $NFXD, $lower);
99 $_ = "$id:alias:$set;$remainder\n";
106 print STDERR "Wrote $DIR/$OUT\n";
109 ######################################################################
110 # Get the source set (call out to Java), optionally with a closure.
115 my $set = `java -classpath $CLASSES com.ibm.tools.translit.genIndexFilters $ID $NFXD $lower`;