Made some changes to the OnlineTranslationTool. Now when text is redisplayed as links, is shows up with the declension marks.

This commit is contained in:
amontano 2005-02-28 03:04:01 +00:00
parent ff130e6fb1
commit d4dc004c2a
3 changed files with 70 additions and 75 deletions

View file

@ -165,7 +165,8 @@ public class LocalTibetanScanner extends TibetanScanner
if (lastCompSil!=null) if (lastCompSil!=null)
{ {
w = new Word(lastCompWord, lastCompSil.getDefs()); if (lastCompWord.equals(wordActual)) w = new Word(lastCompWord, lastCompSil.getDefs());
else w = new Word(lastCompWord, wordActual, lastCompSil.getDefs());
wordList.addLast(w); wordList.addLast(w);
this.resetAll(); this.resetAll();
@ -202,7 +203,8 @@ public class LocalTibetanScanner extends TibetanScanner
while (lastCompSil!=null) while (lastCompSil!=null)
{ {
w = new Word(lastCompWord, lastCompSil.getDefs()); if (lastCompWord.equals(wordActual)) w = new Word(lastCompWord, lastCompSil.getDefs());
else w = new Word(lastCompWord, wordActual, lastCompSil.getDefs());
wordList.addLast(w); wordList.addLast(w);
this.resetAll(); this.resetAll();

View file

@ -351,35 +351,35 @@ public class OnLineScannerFilter extends HttpServlet
for (i=0; i < words.length; i++) for (i=0; i < words.length; i++)
{ {
if (words[i] instanceof Word) if (words[i] instanceof Word)
{ {
word = new SwingWord((Word)words[i]); word = new SwingWord((Word)words[i]);
if (word.getDefs().getDictionarySource()!=null) // if (word.getDefs().getDictionarySource()!=null)
pw.print(word.getLink()); pw.print(word.getLink());
else pw.print(word.getWylie() + " "); // else pw.print(word.getWylie() + " ");
} }
else else
{ {
if (words[i] instanceof PunctuationMark) if (words[i] instanceof PunctuationMark)
{ {
pm = words[i].toString().charAt(0); pm = words[i].toString().charAt(0);
switch (pm) switch (pm)
{ {
case '\n': case '\n':
pw.println("</p>"); pw.println("</p>");
pw.print("<p>"); pw.print("<p>");
break; break;
case '<': case '<':
pw.print("&lt; "); pw.print("&lt; ");
break; break;
case '>': case '>':
pw.print("&gt; "); pw.print("&gt; ");
break; break;
default: default:
pw.print(pm + " "); pw.print(pm + " ");
}
} }
} }
}
} }
pw.println("</p>"); pw.println("</p>");
} }
@ -407,34 +407,24 @@ public class OnLineScannerFilter extends HttpServlet
word = new SwingWord(words[j]); word = new SwingWord(words[j]);
defs = word.getDefs(); defs = word.getDefs();
ds = defs.getDictionarySource(); ds = defs.getDictionarySource();
if (ds==null || ds.isEmpty()) continue;
pw.println(" <tr>"); pw.println(" <tr>");
tag = ds.getTag(0); if (ds!=null && !ds.isEmpty()) tag = ds.getTag(0);
// else tag = null; else tag = "&nbsp;";
/*if (tag!=null)
{*/ pw.println(" <td width=\"20%\" rowspan=\""+ defs.def.length +"\" valign=\"top\">"+ word.getBookmark(tibetan) +"</td>");
pw.println(" <td width=\"20%\" rowspan=\""+ defs.def.length +"\" valign=\"top\">"+ word.getBookmark(tibetan) +"</td>"); pw.println(" <td width=\"12%\">"+ tag +"</td>");
pw.println(" <td width=\"12%\">"+ tag +"</td>"); pw.println(" <td width=\"68%\">" + defs.def[0] + "</td>");
pw.println(" <td width=\"68%\">" + defs.def[0] + "</td>");
/*}
else
{
pw.println(" <td width=\"20%\" rowspan=\""+ defs.def.length +"\" valign=\"top\">"+ words[j].getBookmark(tibetan) +"</td>");
pw.println(" <td width=\"80%\" colspan=\"2\">" + defs.def[0] + "</td>");
}*/
pw.println(" </tr>"); pw.println(" </tr>");
for (i=1; i<defs.def.length; i++) for (i=1; i<defs.def.length; i++)
{ {
pw.println(" <tr>"); pw.println(" <tr>");
if (ds!=null) tag = ds.getTag(i); if (ds!=null && !ds.isEmpty()) tag = ds.getTag(i);
else tag = null; else tag = "&nbsp;";
if (tag!=null) pw.println(" <td width=\"12%\">"+ tag +"</td>");
{ pw.println(" <td width=\"68%\">" + defs.def[i] + "</td>");
pw.println(" <td width=\"12%\">"+ tag +"</td>"); //else pw.println(" <td width=\"80%\" colspan=\"2\">" + defs.def[i] + "</td>");
pw.println(" <td width=\"68%\">" + defs.def[i] + "</td>"); pw.println(" </tr>");
}
else pw.println(" <td width=\"80%\" colspan=\"2\">" + defs.def[i] + "</td>");
pw.println(" </tr>");
} }
} }
catch (Exception e) catch (Exception e)

View file

@ -76,28 +76,31 @@ public class SwingWord extends Word
return getLink(false); return getLink(false);
} }
/** Returns the word marked up as a link.
*
*/
public String getLink(boolean tibetan) public String getLink(boolean tibetan)
{ {
String localWord, result=null; String localWord, result=null;
// String result;
if (wordSinDec==null) localWord = super.token; if (wordSinDec==null) localWord = super.token;
else localWord = wordSinDec; else localWord = wordSinDec;
if (tibetan) if (tibetan)
{ {
try try
{ {
result = TibetanHTML.getHTML(localWord + " "); result = TibetanHTML.getHTML(localWord + " ");
} }
catch (Exception e) catch (Exception e)
{ {
result = localWord; result = localWord;
} }
} }
else result = localWord; else result = localWord;
/* result = "<a href=\"#" + word + "\">" + localWord; /* result = "<a href=\"#" + word + "\">" + localWord;
if (tibetan) result+= "</a>"; if (tibetan) result+= "</a>";
else result+= "</a> "; else result+= "</a> ";
return result;*/ return result;*/
return "<a href=\"#" + super.token + "\">" + result + "</a> "; return "<a href=\"#" + super.token + "\">" + result + "</a> ";
} }
} }