b-r-g, b-l-g-s, etc., when converted from Tibetan to Wylie, give

correct, unambiguous Wylie.
This commit is contained in:
dchandler 2003-03-30 21:49:55 +00:00
parent 8565855dd1
commit 1987f7d80a
2 changed files with 26 additions and 10 deletions

View file

@ -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();
}

View file

@ -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.