From 1987f7d80a1ee10f3a9ac8cadb00df9cc21ef9bc Mon Sep 17 00:00:00 2001 From: dchandler Date: Sun, 30 Mar 2003 21:49:55 +0000 Subject: [PATCH] b-r-g, b-l-g-s, etc., when converted from Tibetan to Wylie, give correct, unambiguous Wylie. --- source/org/thdl/tib/text/TibTextUtils.java | 19 +++++++++---------- .../org/thdl/tib/text/TibetanMachineWeb.java | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/source/org/thdl/tib/text/TibTextUtils.java b/source/org/thdl/tib/text/TibTextUtils.java index f590f6c..e52b4c1 100644 --- a/source/org/thdl/tib/text/TibTextUtils.java +++ b/source/org/thdl/tib/text/TibTextUtils.java @@ -830,10 +830,7 @@ public class TibTextUtils { sb.append(aVowelToUseAfter(lastWylie)); } - // FIXME: "g" and "y" should not be hard-coded here. - // Instead, TibetanMachineWeb should introduce relevant sets - - if (lastWylie.equals("g") && wylie.equals("y")) + if (TibetanMachineWeb.isAmbiguousWylie(lastWylie, wylie)) sb.append(TibetanMachineWeb.WYLIE_DISAMBIGUATING_KEY); if (!wylie.equals(TibetanMachineWeb.ACHEN)) { @@ -895,7 +892,7 @@ public class TibTextUtils { || !TibetanMachineWeb.isWylieFarRight(TibetanMachineWeb.getWylieForGlyph((DuffCode)glyphList.get(size - 1))))))) { for (int i = 0; i < size; i++) { wylie = TibetanMachineWeb.getWylieForGlyph((DuffCode)glyphList.get(i)); - if ((lastWylie.equals("g") && wylie.equals("y")) + if (TibetanMachineWeb.isAmbiguousWylie(lastWylie, wylie) || (i != 0 && wylie.equals(TibetanMachineWeb.ACHEN))) sb.append(TibetanMachineWeb.WYLIE_DISAMBIGUATING_KEY); @@ -909,7 +906,7 @@ public class TibTextUtils { int i = 0; while (i+2 < size) { wylie = TibetanMachineWeb.getWylieForGlyph((DuffCode)glyphList.get(i)); - if ((lastWylie.equals("g") && wylie.equals("y")) + if (TibetanMachineWeb.isAmbiguousWylie(lastWylie, wylie) || (i != 0 && wylie.equals(TibetanMachineWeb.ACHEN))) sb.append(TibetanMachineWeb.WYLIE_DISAMBIGUATING_KEY); @@ -1010,6 +1007,8 @@ public class TibTextUtils { } else { /* no ambiguity. the "a" vowel comes after * wylie1. */ + if (TibetanMachineWeb.isAmbiguousWylie(wylie0, wylie1)) + sb.append(TibetanMachineWeb.WYLIE_DISAMBIGUATING_KEY); sb.append(wylie1 + aVowelToUseAfter(wylie1) + wylie2); @@ -1068,10 +1067,7 @@ public class TibTextUtils { dc = (DuffCode)iter.next(); currWylie = TibetanMachineWeb.getWylieForGlyph(dc); -//note: "g" and "y" should not be hard-coded -// instead, TibetanMachineWeb should introduce relevant sets - - if ((lastWylie.equals("g") && currWylie.equals("y")) + if (TibetanMachineWeb.isAmbiguousWylie(lastWylie, currWylie) || (!lastWylie.equals("") && currWylie.equals(TibetanMachineWeb.ACHEN))) sb.append(TibetanMachineWeb.WYLIE_DISAMBIGUATING_KEY); @@ -1081,6 +1077,9 @@ public class TibTextUtils { lastWylie = currWylie; } + // DLC FIXME: type jeskada, convert Tibetan->Wylie. You get + // the wrong thing in makeIllegalTibetanGoEndToEnd mode. Fix + // it here. return sb.toString(); } diff --git a/source/org/thdl/tib/text/TibetanMachineWeb.java b/source/org/thdl/tib/text/TibetanMachineWeb.java index e7bfa49..d68f9ed 100644 --- a/source/org/thdl/tib/text/TibetanMachineWeb.java +++ b/source/org/thdl/tib/text/TibetanMachineWeb.java @@ -43,6 +43,7 @@ import org.thdl.util.ThdlOptions; * @author Edward Garrett, Tibetan and Himalayan Digital Library * @version 1.0 */ +// FIXME: for speed, make either this class, its methods, or both, final? public class TibetanMachineWeb { /** This addresses bug 624133, "Input freezes after impossible * character". The input sequences that are valid in Extended @@ -696,6 +697,22 @@ public static boolean isVowel(String s) { return keyboard.isVowel(s); } +/** +* Checks to see if the concatenation of x and y is ambiguous in +* Extended Wylie. gya and g.ya, bla and b.la, and bra and b.ra are +* the only syntactically legal ambigous fellows, as stacks like blha, +* blda, brla, brkya, brgya, brka, etc. are unambiguous. +* @param x the prefix +* @param y the root stack +* @return true if x + y is ambiguous in the Extended Wylie +* transliteration, false if not +*/ +public static boolean isAmbiguousWylie(String x, String y) { + return (("g".equals(x) && "y".equals(y)) + || ("b".equals(x) && "l".equals(y)) + || ("b".equals(x) && "r".equals(y))); +} + /** * Checks to see if the passed string * is a vowel in Extended Wylie.