Added debug info to the servlet version.
This commit is contained in:
parent
9507ff3694
commit
107fcce565
8 changed files with 210 additions and 200 deletions
|
@ -61,12 +61,12 @@ public class DictionaryTableModel extends AbstractTableModel
|
||||||
{
|
{
|
||||||
switch(column)
|
switch(column)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (tibetanActivated) return arrayTibetan[row];
|
if (tibetanActivated) return arrayTibetan[row];
|
||||||
else return array[row].getWylie();
|
else return array[row].getWylie();
|
||||||
case 1: return array[row].getDefPreview();
|
case 1: return array[row].getDefPreview();
|
||||||
default: return array[row].toString();
|
default: return array[row].toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -208,50 +208,50 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener
|
||||||
|
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
txtInput.setText("");
|
txtInput.setText("");
|
||||||
duffInput.setText("");
|
duffInput.setText("");
|
||||||
fullDef.setText("");
|
fullDef.setText("");
|
||||||
model.newSearch(null);
|
model.newSearch(null);
|
||||||
table.tableChanged(new TableModelEvent(model));
|
table.tableChanged(new TableModelEvent(model));
|
||||||
table.repaint();
|
table.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translate()
|
public void translate()
|
||||||
{
|
{
|
||||||
String in;
|
String in;
|
||||||
setDicts(scanner.getDictionarySource());
|
setDicts(scanner.getDictionarySource());
|
||||||
|
|
||||||
in = "";
|
in = "";
|
||||||
if (showingTibetan)
|
if (showingTibetan)
|
||||||
in = duffInput.getWylie(new boolean[] { false });
|
in = duffInput.getWylie(new boolean[] { false });
|
||||||
else
|
else
|
||||||
in = txtInput.getText();
|
in = txtInput.getText();
|
||||||
|
|
||||||
if (!in.equals(""))
|
if (!in.equals(""))
|
||||||
{
|
{
|
||||||
doingStatus("Translating...");
|
doingStatus("Translating...");
|
||||||
scanner.scanBody(in);
|
scanner.scanBody(in);
|
||||||
scanner.finishUp();
|
scanner.finishUp();
|
||||||
model.newSearch(scanner.getWordArray());
|
model.newSearch(scanner.getWordArray());
|
||||||
// printAllDefs();
|
//printAllDefs();
|
||||||
scanner.clearTokens();
|
scanner.clearTokens();
|
||||||
returnStatusToNorm();
|
returnStatusToNorm();
|
||||||
fullDef.setText("");
|
fullDef.setText("");
|
||||||
/* ListSelectionModel lsm = (ListSelectionModel)table.getSelectionModel();
|
/*ListSelectionModel lsm = (ListSelectionModel)table.getSelectionModel();
|
||||||
if (!lsm.isSelectionEmpty())
|
if (!lsm.isSelectionEmpty())
|
||||||
{
|
{
|
||||||
int selectedRow = lsm.getMinSelectionIndex();
|
int selectedRow = lsm.getMinSelectionIndex();
|
||||||
//TableModel tm = table.getModel();
|
//TableModel tm = table.getModel();
|
||||||
if (selectedRow<model.getRowCount())
|
if (selectedRow<model.getRowCount())
|
||||||
fullDef.setText(model.getValueAt(selectedRow, 1).toString());
|
fullDef.setText(model.getValueAt(selectedRow, 1).toString());
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.newSearch(null);
|
model.newSearch(null);
|
||||||
fullDef.setText("");
|
fullDef.setText("");
|
||||||
}
|
}
|
||||||
table.tableChanged(new TableModelEvent(model));
|
table.tableChanged(new TableModelEvent(model));
|
||||||
table.repaint();
|
table.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,55 +207,57 @@ public class FileSyllableListTree implements SyllableListTree
|
||||||
|
|
||||||
public Definitions getDefs()
|
public Definitions getDefs()
|
||||||
{
|
{
|
||||||
if (def==null) return null;
|
if (def==null) return null;
|
||||||
DictionarySource defSourceAvail = defSource.intersection(defSourcesWanted);
|
DictionarySource defSourceAvail = defSource.intersection(defSourcesWanted);
|
||||||
String defs[];
|
String defs[];
|
||||||
int i, n=0;
|
int i, n=0;
|
||||||
|
|
||||||
if (versionNumber==2)
|
|
||||||
{
|
|
||||||
int defsAvail[] = ((BitDictionarySource) defSourceAvail).untangleDefs(), defsFound[] = ((BitDictionarySource) defSource).untangleDefs(def.length);
|
|
||||||
|
|
||||||
defs = new String[defsAvail.length];
|
if (versionNumber==2)
|
||||||
try
|
{
|
||||||
{
|
int defsAvail[] = ((BitDictionarySource) defSourceAvail).untangleDefs(), defsFound[] = ((BitDictionarySource) defSource).untangleDefs(def.length);
|
||||||
for (i=0; i<defsAvail.length; i++)
|
|
||||||
{
|
defs = new String[defsAvail.length];
|
||||||
while(defsAvail[i]!=defsFound[n]) n++;
|
try
|
||||||
defRaf.seek(def[n]);
|
{
|
||||||
defs[i] = defRaf.readUTF();
|
for (i=0; i<defsAvail.length; i++)
|
||||||
}
|
{
|
||||||
}
|
while(defsAvail[i]!=defsFound[n]) n++;
|
||||||
catch (Exception e)
|
defRaf.seek(def[n]);
|
||||||
{
|
defs[i] = defRaf.readUTF();
|
||||||
System.out.println(e);
|
}
|
||||||
return null;
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
}
|
{
|
||||||
else
|
System.out.println(e);
|
||||||
{
|
e.printStackTrace();
|
||||||
ByteDictionarySource defSourceAvailBy = (ByteDictionarySource) defSourceAvail;
|
return null;
|
||||||
defs = new String [defSourceAvailBy.countDefs()];
|
}
|
||||||
|
}
|
||||||
try
|
else
|
||||||
{
|
{
|
||||||
for (i=0; i < def.length; i++)
|
ByteDictionarySource defSourceAvailBy = (ByteDictionarySource) defSourceAvail;
|
||||||
{
|
defs = new String [defSourceAvailBy.countDefs()];
|
||||||
if (!defSourceAvailBy.isEmpty(i))
|
|
||||||
{
|
try
|
||||||
defRaf.seek(def[i]);
|
{
|
||||||
defs[n] = defRaf.readUTF();
|
for (i=0; i < def.length; i++)
|
||||||
n++;
|
{
|
||||||
}
|
if (!defSourceAvailBy.isEmpty(i))
|
||||||
}
|
{
|
||||||
}
|
defRaf.seek(def[i]);
|
||||||
catch (Exception e)
|
defs[n] = defRaf.readUTF();
|
||||||
{
|
n++;
|
||||||
System.out.println(e);
|
}
|
||||||
return null;
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
return new Definitions(defs, defSourceAvail);
|
{
|
||||||
|
System.out.println(e);
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Definitions(defs, defSourceAvail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDef()
|
public boolean hasDef()
|
||||||
|
|
|
@ -274,19 +274,19 @@ public class LocalTibetanScanner extends TibetanScanner
|
||||||
fin = in.indexOf("\n",init);
|
fin = in.indexOf("\n",init);
|
||||||
if (fin<0)
|
if (fin<0)
|
||||||
{
|
{
|
||||||
linea = in.substring(init).trim();
|
linea = in.substring(init).trim();
|
||||||
hayMasLineas=false;
|
hayMasLineas=false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
linea = in.substring(init, fin).trim();
|
linea = in.substring(init, fin).trim();
|
||||||
|
|
||||||
if (linea.equals(""))
|
if (linea.equals(""))
|
||||||
{
|
{
|
||||||
finishUp();
|
finishUp();
|
||||||
wordList.addLast(new PunctuationMark('\n'));
|
wordList.addLast(new PunctuationMark('\n'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
scanLine(linea);
|
scanLine(linea);
|
||||||
|
|
||||||
init = fin+1;
|
init = fin+1;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ public class LocalTibetanScanner extends TibetanScanner
|
||||||
{
|
{
|
||||||
finishUp();
|
finishUp();
|
||||||
wordList.addLast(new PunctuationMark('\n'));
|
wordList.addLast(new PunctuationMark('\n'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
outAHere:
|
outAHere:
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class OnLineScannerFilter extends HttpServlet
|
||||||
public OnLineScannerFilter() //throws Exception
|
public OnLineScannerFilter() //throws Exception
|
||||||
{
|
{
|
||||||
rb = ResourceBundle.getBundle(propertyFile);
|
rb = ResourceBundle.getBundle(propertyFile);
|
||||||
sl = new ScannerLogger();
|
sl = new ScannerLogger();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -377,9 +377,8 @@ public class OnLineScannerFilter extends HttpServlet
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pw.print(pm + " ");
|
pw.print(pm + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pw.println("</p>");
|
pw.println("</p>");
|
||||||
|
@ -389,7 +388,7 @@ public class OnLineScannerFilter extends HttpServlet
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
Word words[];
|
Word words[];
|
||||||
SwingWord word;
|
SwingWord word=null;
|
||||||
Definitions defs;
|
Definitions defs;
|
||||||
String tag;
|
String tag;
|
||||||
DictionarySource ds;
|
DictionarySource ds;
|
||||||
|
@ -402,38 +401,48 @@ public class OnLineScannerFilter extends HttpServlet
|
||||||
|
|
||||||
for (j=0; j<words.length; j++)
|
for (j=0; j<words.length; j++)
|
||||||
{
|
{
|
||||||
word = new SwingWord(words[j]);
|
try
|
||||||
defs = word.getDefs();
|
{
|
||||||
ds = defs.getDictionarySource();
|
|
||||||
if (ds==null) continue;
|
word = new SwingWord(words[j]);
|
||||||
pw.println(" <tr>");
|
defs = word.getDefs();
|
||||||
tag = ds.getTag(0);
|
ds = defs.getDictionarySource();
|
||||||
// else tag = null;
|
if (ds==null || ds.isEmpty()) continue;
|
||||||
/*if (tag!=null)
|
pw.println(" <tr>");
|
||||||
{*/
|
tag = ds.getTag(0);
|
||||||
pw.println(" <td width=\"20%\" rowspan=\""+ defs.def.length +"\" valign=\"top\">"+ word.getBookmark(tibetan) +"</td>");
|
// else tag = null;
|
||||||
pw.println(" <td width=\"12%\">"+ tag +"</td>");
|
/*if (tag!=null)
|
||||||
pw.println(" <td width=\"68%\">" + defs.def[0] + "</td>");
|
{*/
|
||||||
/*}
|
pw.println(" <td width=\"20%\" rowspan=\""+ defs.def.length +"\" valign=\"top\">"+ word.getBookmark(tibetan) +"</td>");
|
||||||
else
|
pw.println(" <td width=\"12%\">"+ tag +"</td>");
|
||||||
{
|
pw.println(" <td width=\"68%\">" + defs.def[0] + "</td>");
|
||||||
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>");
|
else
|
||||||
}*/
|
{
|
||||||
pw.println(" </tr>");
|
pw.println(" <td width=\"20%\" rowspan=\""+ defs.def.length +"\" valign=\"top\">"+ words[j].getBookmark(tibetan) +"</td>");
|
||||||
for (i=1; i<defs.def.length; i++)
|
pw.println(" <td width=\"80%\" colspan=\"2\">" + defs.def[0] + "</td>");
|
||||||
{
|
}*/
|
||||||
pw.println(" <tr>");
|
pw.println(" </tr>");
|
||||||
if (ds!=null) tag = ds.getTag(i);
|
for (i=1; i<defs.def.length; i++)
|
||||||
else tag = null;
|
{
|
||||||
if (tag!=null)
|
pw.println(" <tr>");
|
||||||
{
|
if (ds!=null) tag = ds.getTag(i);
|
||||||
pw.println(" <td width=\"12%\">"+ tag +"</td>");
|
else tag = null;
|
||||||
pw.println(" <td width=\"68%\">" + defs.def[i] + "</td>");
|
if (tag!=null)
|
||||||
}
|
{
|
||||||
else pw.println(" <td width=\"80%\" colspan=\"2\">" + defs.def[i] + "</td>");
|
pw.println(" <td width=\"12%\">"+ tag +"</td>");
|
||||||
pw.println(" </tr>");
|
pw.println(" <td width=\"68%\">" + defs.def[i] + "</td>");
|
||||||
}
|
}
|
||||||
|
else pw.println(" <td width=\"80%\" colspan=\"2\">" + defs.def[i] + "</td>");
|
||||||
|
pw.println(" </tr>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
sl.writeLog("Crash\tOnLineScannerFilter\t" + word.getWylie());
|
||||||
|
sl.writeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pw.println("</table>");
|
pw.println("</table>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,7 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
res.setContentType ("text/plain");
|
res.setContentType ("text/plain");
|
||||||
sl.setUserIP(req.getRemoteAddr());
|
sl.setUserIP(req.getRemoteAddr());
|
||||||
|
|
||||||
Token token[] = null;
|
Word word = null, words[] = null;
|
||||||
Word word = null;
|
|
||||||
PrintWriter out;
|
PrintWriter out;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -117,28 +116,29 @@ public class RemoteScannerFilter extends GenericServlet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: sometimes getDef returns raises a NullPointerException.
|
/* FIXME: sometimes getDef raises a NullPointerException.
|
||||||
In the meantime, I'll just keep it from crashing
|
In the meantime, I'll just keep it from crashing
|
||||||
*/
|
*/
|
||||||
sl.writeLog("Translation\tRemoteScannerFilter");
|
sl.writeLog("Translation\tRemoteScannerFilter");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
scanner.clearTokens();
|
||||||
while((linea = br.readLine())!= null)
|
while((linea = br.readLine())!= null)
|
||||||
scanner.scanLine(linea);
|
scanner.scanLine(linea);
|
||||||
|
|
||||||
br.close();
|
br.close();
|
||||||
|
|
||||||
scanner.finishUp();
|
scanner.finishUp();
|
||||||
token = scanner.getTokenArray();
|
words = scanner.getWordArray();
|
||||||
|
|
||||||
for (i=0; i<token.length; i++)
|
for (i=0; i<words.length; i++)
|
||||||
{
|
{
|
||||||
if (!(token[i] instanceof Word)) continue;
|
linea = words[i].getDef();
|
||||||
word = (Word) token[i];
|
if (linea == null) continue;
|
||||||
out.println(word.getWylie());
|
out.println(words[i].getWylie());
|
||||||
out.println(word.getDef());
|
out.println(linea);
|
||||||
out.println();
|
out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class ScannerLogger
|
||||||
|
|
||||||
public ScannerLogger()
|
public ScannerLogger()
|
||||||
{
|
{
|
||||||
ResourceBundle rb = ResourceBundle.getBundle("dictionary");
|
ResourceBundle rb = ResourceBundle.getBundle("dictionary");
|
||||||
fileName = rb.getString("remotescannerfilter.log-file-name");
|
fileName = rb.getString("remotescannerfilter.log-file-name");
|
||||||
lastIP = null;
|
lastIP = null;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,10 @@ public class ScannerLogger
|
||||||
{
|
{
|
||||||
PrintStream pw = getPrintStream();
|
PrintStream pw = getPrintStream();
|
||||||
if (lastIP!=null) pw.print(lastIP);
|
if (lastIP!=null) pw.print(lastIP);
|
||||||
pw.println("\t" + getCurrentTime() + "\t" + s);
|
else pw.print("-");
|
||||||
pw.flush();
|
pw.println("\t" + getCurrentTime() + "\t" + s);
|
||||||
pw.close();
|
pw.flush();
|
||||||
|
pw.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PrintStream getPrintStream()
|
private PrintStream getPrintStream()
|
||||||
|
|
|
@ -316,58 +316,56 @@ public abstract class TibetanScanner
|
||||||
Token token;
|
Token token;
|
||||||
Word array[], word;
|
Word array[], word;
|
||||||
int n=0;
|
int n=0;
|
||||||
SimplifiedListIterator li = wordList.listIterator();
|
SimplifiedListIterator li = wordList.listIterator();
|
||||||
SimplifiedLinkedList ll2, ll = new SimplifiedLinkedList();
|
SimplifiedLinkedList ll2, ll = new SimplifiedLinkedList();
|
||||||
|
|
||||||
while(li.hasNext())
|
while(li.hasNext())
|
||||||
{
|
{
|
||||||
token = (Token) li.next();
|
token = (Token) li.next();
|
||||||
|
|
||||||
if (token instanceof Word)
|
if (token instanceof Word)
|
||||||
{
|
{
|
||||||
ll.addLast(token);
|
ll.addLast(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeRepeated)
|
if (includeRepeated)
|
||||||
{
|
{
|
||||||
n = ll.size();
|
n = ll.size();
|
||||||
|
if (n==0) return null;
|
||||||
if (n==0) return null;
|
|
||||||
|
array = new Word[n];
|
||||||
array = new Word[n];
|
li = ll.listIterator();
|
||||||
li = ll.listIterator();
|
|
||||||
|
n=0;
|
||||||
n=0;
|
while (li.hasNext())
|
||||||
while (li.hasNext())
|
{
|
||||||
{
|
array[n++] = (Word) li.next();
|
||||||
array[n++] = (Word) li.next();
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
ll2 = new SimplifiedLinkedList();
|
||||||
ll2 = new SimplifiedLinkedList();
|
li = ll.listIterator();
|
||||||
li = ll.listIterator();
|
|
||||||
|
while(li.hasNext())
|
||||||
while(li.hasNext())
|
{
|
||||||
{
|
word = (Word) li.next();
|
||||||
word = (Word) li.next();
|
if (!ll2.contains(word)) ll2.addLast(word);
|
||||||
|
}
|
||||||
if (!ll2.contains(word)) ll2.addLast(word);
|
|
||||||
}
|
n = ll2.size();
|
||||||
|
|
||||||
n = ll2.size();
|
if (n==0) return null;
|
||||||
|
|
||||||
if (n==0) return null;
|
array = new Word[n];
|
||||||
|
li = ll2.listIterator();
|
||||||
array = new Word[n];
|
|
||||||
li = ll2.listIterator();
|
while (li.hasNext())
|
||||||
|
{
|
||||||
while (li.hasNext())
|
array[--n] = (Word) li.next();
|
||||||
{
|
}
|
||||||
array[--n] = (Word) li.next();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue