Added Transliteration options, added BLOCK size in a file.
--- a/src/jdict/AskWord.java Wed Jul 25 00:39:59 2007 +0200
+++ b/src/jdict/AskWord.java Wed Jul 25 20:47:50 2007 +0200
@@ -9,7 +9,13 @@
private Form myform;
private Command cmd_eliri;
private Command cmd_sercxi;
+ private Command cmd_montri;
private TextField word;
+ private ChoiceGroup translit;
+ final String translit_neniu = "Neniu";
+ final String translit_iksa = "Iksa sistemo";
+ final String translit_rusa = "ASCII-rusa";
+ private StringItem showSearch;
public AskWord()
{
@@ -31,13 +37,26 @@
word = new TextField("Vorto:", "", 20, TextField.ANY);
myform.append(word);
+ translit = new ChoiceGroup("Transliterigo", ChoiceGroup.EXCLUSIVE);
+ translit.append(translit_neniu, null);
+ translit.append(translit_iksa, null);
+ translit.append(translit_rusa, null);
+ translit.setSelectedIndex(0, true);
+ myform.append(translit);
+
+ /* DEBUG */
+ showSearch = new StringItem("Serĉonte:", "");
+ myform.append(showSearch);
+
+ cmd_sercxi = new Command("Serĉi", Command.OK, 0);
+ myform.addCommand(cmd_sercxi);
+ /* Commands */
+ cmd_montri = new Command("Montri", Command.HELP, 0);
+ myform.addCommand(cmd_montri);
/* Commands */
cmd_eliri = new Command("Eliri", Command.BACK, 0);
myform.addCommand(cmd_eliri);
- cmd_sercxi = new Command("Serĉi", Command.BACK, 0);
- myform.addCommand(cmd_sercxi);
-
myform.setCommandListener(this);
Main.display.setCurrent(myform);
}
@@ -52,12 +71,15 @@
DictIndex index = new DictIndex("alos-eo-ca");
Vector results;
- String toSearch = Replace.IksojAlCxapeloj(word.getString());
+ String toSearch = word.getString();
+ if (translit.getString(translit.getSelectedIndex())
+ .equals(translit_iksa))
+ toSearch = Replace.IksojAlCxapeloj(word.getString());
+ else if (translit.getString(translit.getSelectedIndex())
+ .equals(translit_rusa))
+ toSearch = Replace.AsciiAlRusa(word.getString());
- /* DEBUG */
- StringItem tosearch = new StringItem("Serĉante:", toSearch);
- myform.append(tosearch);
-
+ showSearch.setText(toSearch);
System.out.println("Serĉante: " + toSearch);
results = index.SearchDefinition(toSearch);
@@ -67,5 +89,17 @@
{
Main.main.quit();
}
+ else if (c == cmd_montri)
+ {
+ String toSearch = word.getString();
+ if (translit.getString(translit.getSelectedIndex())
+ .equals(translit_iksa))
+ toSearch = Replace.IksojAlCxapeloj(word.getString());
+ else if (translit.getString(translit.getSelectedIndex())
+ .equals(translit_rusa))
+ toSearch = Replace.AsciiAlRusa(word.getString());
+
+ showSearch.setText(toSearch);
+ }
}
}
--- a/src/jdict/BlockFile.java Wed Jul 25 00:39:59 2007 +0200
+++ b/src/jdict/BlockFile.java Wed Jul 25 20:47:50 2007 +0200
@@ -6,12 +6,34 @@
{
InputStream in;
int block_id;
- final int blocksize = 50000;
+ int blocksize;
int block_offset;
String basename;
+ public void read_block_size()
+ {
+ InputStream bfile = getClass().getResourceAsStream("/dicts/BLOCKS");
+ /* 10 bytes is enough for a simple int */
+ byte array[] = new byte[10];
+ int total;
+ try {
+ total = bfile.read(array, 0, 10);
+ } catch (IOException e)
+ {
+ System.out.println("Cannot open BLOCKS file. Going to 32000 B.");
+ blocksize = 32000;
+ return;
+ }
+ /* This will have '\n' */
+ String str = new String(array, 0, total - 1 /* - \n */);
+ blocksize = Integer.parseInt(str);
+ System.out.println("Block size: " +
+ new Integer(blocksize).toString());
+ }
+
public BlockFile(String _basename)
{
+ read_block_size();
basename = _basename;
openIndex(0);
}
--- a/src/jdict/Replace.java Wed Jul 25 00:39:59 2007 +0200
+++ b/src/jdict/Replace.java Wed Jul 25 20:47:50 2007 +0200
@@ -76,7 +76,7 @@
result = replace_sub(result, "\"", "ъ");
result = replace_sub(result, "y", "ы");
result = replace_sub(result, "'", "ь");
- result = replace_sub(result, "e", "э");
+ result = replace_sub(result, "/e", "э");
return result;
}