Added UI for EWTS->Tibetan conversions. GUI is disabled except in

debug mode for now.

I tested against a really simple-but-real document, found a bug with '*', tried
to implement TMW vowel code but I don't trust it yet.  Differentiated EWTS
code from ACIP where needed.

Several bugs in ewts->tibetan have been exposed; see the TODO
comments.
This commit is contained in:
dchandler 2005-06-20 09:30:35 +00:00
parent 7198f23361
commit 2678fc134a
9 changed files with 150 additions and 34 deletions

View file

@ -223,10 +223,13 @@ class ConvertDialog extends JDialog
JButton src = (JButton)ae.getSource();
if (src == browseOld) {
jfc.setFileFilter((ACIP_TO_UNI_TEXT.equals((String)choices.getSelectedItem())
|| ACIP_TO_TMW.equals((String)choices.getSelectedItem()))
|| WYLIE_TO_UNI_TEXT.equals((String)choices.getSelectedItem())
|| ACIP_TO_TMW.equals((String)choices.getSelectedItem())
|| WYLIE_TO_TMW.equals((String)choices.getSelectedItem()))
? acipff : rtfff);
} else {
jfc.setFileFilter((ACIP_TO_UNI_TEXT.equals((String)choices.getSelectedItem())
|| WYLIE_TO_UNI_TEXT.equals((String)choices.getSelectedItem())
|| TMW_TO_ACIP_TEXT.equals((String)choices.getSelectedItem())
|| TMW_TO_WYLIE_TEXT.equals((String)choices.getSelectedItem()))
? acipff : rtfff);
@ -457,7 +460,7 @@ class ConvertDialog extends JDialog
} else if (FIND_ALL_NON_TM == ct) {
newFileNamePrefix = "AllNonTM__";
newFileNameExtension = ".TXT";
} else if (TMW_TO_SAME_TWM == ct) {
} else if (TMW_TO_SAME_TMW == ct) {
newFileNamePrefix = "TMW_to_same_TMW__";
newFileNameExtension = ".RTF";
} else { // conversion mode
@ -471,13 +474,15 @@ class ConvertDialog extends JDialog
} else if (TMW_TO_ACIP_TEXT == ct) {
newFileNamePrefix = suggested_ACIP_prefix;
newFileNameExtension = ".TXT";
} else if (TMW_TO_UNI == ct || ACIP_TO_UNI_TEXT == ct) {
} else if (TMW_TO_UNI == ct || ACIP_TO_UNI_TEXT == ct
|| WYLIE_TO_UNI_TEXT == ct) {
newFileNamePrefix = suggested_TO_UNI_prefix;
if (ACIP_TO_UNI_TEXT == ct)
if (ACIP_TO_UNI_TEXT == ct || WYLIE_TO_UNI_TEXT == ct)
newFileNameExtension = ".TXT";
} else if (TM_TO_TMW == ct || ACIP_TO_TMW == ct) {
} else if (TM_TO_TMW == ct || ACIP_TO_TMW == ct
|| WYLIE_TO_TMW == ct) {
newFileNamePrefix = suggested_TO_TMW_prefix;
if (ACIP_TO_TMW == ct)
if (ACIP_TO_TMW == ct || WYLIE_TO_TMW == ct)
newFileNameExtension = ".RTF";
} else {
ThdlDebug.verify(TMW_TO_TM == ct);
@ -509,6 +514,7 @@ class ConvertDialog extends JDialog
}
}
// TODO(DLC)[EWTS->Tibetan]: we use for wylie (ewts) too...
public class ACIPFileFilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File f)

View file

@ -26,7 +26,9 @@ import java.awt.*;
@author Nathaniel Garson, Tibetan and Himalayan Digital Library */
interface FontConverterConstants
{
final String TMW_TO_SAME_TWM = "TMW to the same TMW (for testing only) (RTF->RTF)";
final String WYLIE_TO_UNI_TEXT = "Wylie to Unicode (Text->Text)";
final String WYLIE_TO_TMW = "Wylie to TMW (Text->RTF)";
final String TMW_TO_SAME_TMW = "TMW to the same TMW (for testing only) (RTF->RTF)";
final String ACIP_TO_UNI_TEXT = "ACIP to Unicode (Text->Text)";
final String ACIP_TO_TMW = "ACIP to TMW (Text->RTF)";
final String TMW_TO_ACIP = "TMW to ACIP (RTF->RTF)";
@ -42,6 +44,10 @@ interface FontConverterConstants
final String FIND_ALL_NON_TM = "Find all non-TM (in RTF)";
final String[] CHOICES = new String[] {
/* TODO(DLC)[EWTS->Tibetan]: once we're done debugging:
WYLIE_TO_UNI_TEXT,
WYLIE_TO_TMW,
*/
ACIP_TO_UNI_TEXT,
ACIP_TO_TMW,
TMW_TO_ACIP,
@ -58,7 +64,9 @@ interface FontConverterConstants
};
final String[] DEBUG_CHOICES = new String[] {
TMW_TO_SAME_TWM,
TMW_TO_SAME_TMW,
WYLIE_TO_UNI_TEXT,
WYLIE_TO_TMW,
ACIP_TO_UNI_TEXT,
ACIP_TO_TMW,
TMW_TO_ACIP,

View file

@ -28,6 +28,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.text.ttt.TConverter;
import org.thdl.tib.text.ttt.ACIPTraits;
import org.thdl.tib.text.ttt.EWTSTraits;
import org.thdl.tib.text.ttt.TTraits;
import java.util.ArrayList;
/** TibetanConverter is a command-line utility for converting to and
@ -71,6 +73,8 @@ public class TibetanConverter implements FontConverterConstants {
boolean convertToTMMode = false;
boolean convertACIPToUniMode = false;
boolean convertACIPToTMWMode = false;
boolean convertWylieToUniMode = false;
boolean convertWylieToTMWMode = false;
boolean convertToTMWMode = false;
boolean convertToWylieRTFMode = false;
boolean convertToWylieTextMode = false;
@ -116,6 +120,10 @@ public class TibetanConverter implements FontConverterConstants {
= args[numArgs - 2].equals("--acip-to-unicode"))
|| (convertACIPToTMWMode
= args[numArgs - 2].equals("--acip-to-tmw"))
|| (convertWylieToUniMode
= args[numArgs - 2].equals("--wylie-to-unicode"))
|| (convertWylieToTMWMode
= args[numArgs - 2].equals("--wylie-to-tmw"))
|| (convertToUnicodeMode
= args[numArgs - 2].equals("--to-unicode"))
|| (convertToWylieRTFMode
@ -147,6 +155,7 @@ public class TibetanConverter implements FontConverterConstants {
out.println(" | --to-tibetan-machine | --to-tibetan-machine-web");
out.println(" | --to-unicode | --to-wylie | --to-acip");
out.println(" | --to-wylie-text | --to-acip-text");
out.println(" | --wylie-to-unicode | --wylie-to-tmw");
out.println(" | --acip-to-unicode | --acip-to-tmw RTF_file|TXT_file");
out.println(" | TibetanConverter [--version | -v | --help | -h]");
out.println("");
@ -251,13 +260,17 @@ public class TibetanConverter implements FontConverterConstants {
} else if (convertToUnicodeMode) {
conversionTag = TMW_TO_UNI;
} else if (convertTmwToTmwMode) {
conversionTag = TMW_TO_SAME_TWM;
conversionTag = TMW_TO_SAME_TMW;
} else if (convertToTMWMode) {
conversionTag = TM_TO_TMW;
} else if (convertACIPToUniMode) {
conversionTag = ACIP_TO_UNI_TEXT;
} else if (convertACIPToTMWMode) {
conversionTag = ACIP_TO_TMW;
} else if (convertWylieToUniMode) {
conversionTag = WYLIE_TO_UNI_TEXT;
} else if (convertWylieToTMWMode) {
conversionTag = WYLIE_TO_TMW;
} else {
ThdlDebug.verify(convertToTMMode);
conversionTag = TMW_TO_TM;
@ -294,20 +307,28 @@ public class TibetanConverter implements FontConverterConstants {
static int reallyConvert(InputStream in, PrintStream out, String ct,
String warningLevel, boolean shortMessages,
boolean colors) {
if (ACIP_TO_UNI_TEXT == ct || ACIP_TO_TMW == ct) {
if (ACIP_TO_UNI_TEXT == ct || ACIP_TO_TMW == ct
|| WYLIE_TO_UNI_TEXT == ct || WYLIE_TO_TMW == ct) {
try {
ArrayList al
= ACIPTraits.instance().scanner().scanStream(in, null,
ThdlOptions.getIntegerOption("thdl.most.errors.a.tibetan.acip.document.can.have",
1000 - 1),
shortMessages,
warningLevel);
= ((ACIP_TO_UNI_TEXT == ct || ACIP_TO_TMW == ct)
? (TTraits)ACIPTraits.instance()
: (TTraits)EWTSTraits.instance()).scanner().scanStream(in, null,
ThdlOptions.getIntegerOption((ACIP_TO_UNI_TEXT == ct || ACIP_TO_TMW == ct)
? "thdl.most.errors.a.tibetan.acip.document.can.have"
: "thdl.most.errors.a.tibetan.ewts.document.can.have",
1000 - 1),
shortMessages,
warningLevel);
if (null == al)
return 47;
boolean embeddedWarnings = (warningLevel != "None");
boolean hasWarnings[] = new boolean[] { false };
if (ACIP_TO_UNI_TEXT == ct) {
if (!TConverter.convertToUnicodeText(ACIPTraits.instance(),
if (ACIP_TO_UNI_TEXT == ct
|| WYLIE_TO_UNI_TEXT == ct) {
if (!TConverter.convertToUnicodeText((WYLIE_TO_UNI_TEXT == ct)
? (TTraits)EWTSTraits.instance()
: (TTraits)ACIPTraits.instance(),
al, out, null,
null, hasWarnings,
embeddedWarnings,
@ -315,8 +336,9 @@ public class TibetanConverter implements FontConverterConstants {
shortMessages))
return 46;
} else {
if (ct != ACIP_TO_TMW) throw new Error("badness");
if (!TConverter.convertToTMW(ACIPTraits.instance(),
if (!TConverter.convertToTMW((WYLIE_TO_TMW == ct)
? (TTraits)EWTSTraits.instance()
: (TTraits)ACIPTraits.instance(),
al, out, null, null,
hasWarnings,
embeddedWarnings,
@ -402,7 +424,7 @@ public class TibetanConverter implements FontConverterConstants {
int exitCode = 0;
ThdlDebug.verify(((TMW_TO_TM == ct) ? 1 : 0)
+ ((TMW_TO_SAME_TWM == ct) ? 1 : 0)
+ ((TMW_TO_SAME_TMW == ct) ? 1 : 0)
+ ((TMW_TO_UNI == ct) ? 1 : 0)
+ ((TM_TO_TMW == ct) ? 1 : 0)
+ ((TMW_TO_ACIP == ct) ? 1 : 0)
@ -411,7 +433,7 @@ public class TibetanConverter implements FontConverterConstants {
+ ((TMW_TO_WYLIE_TEXT == ct) ? 1 : 0)
== 1);
long numAttemptedReplacements[] = new long[] { 0 };
if (TMW_TO_SAME_TWM == ct) {
if (TMW_TO_SAME_TMW == ct) {
// Identity conversion for testing
if (tdoc.identityTmwToTmwConversion(0,
tdoc.getLength(),