[jsword-devel] Dictionary search problem for Chinese Character Key
DM Smith
dmsmith at crosswire.org
Thu Apr 2 04:29:25 MST 2009
On Apr 1, 2009, at 10:55 PM, Yiguang Hu wrote:
>
> I created a Chinese dictionary using imp2ld.exe. It works fine if
> the key is in English. But If use Chinese as Key the search would
> fail with the following exception. Any idea?
>
> Thanks
> Yiguang
>
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out
> of range: -1
> at
> org.crosswire.jsword.book.sword.RawLDBackend.get(RawLDBackend.java:
> 162)
> at
> org
> .crosswire
> .jsword.book.sword.SwordDictionary.getKey(SwordDictionary.java:176)
> at GbookController.getBookKey(GbookController.groovy:987)
> at GbookController.this$2$getBookKey(GbookController.groovy)
> at GbookController.getBookData(GbookController.groovy:955)
> at GbookController.this$2$getBookData(GbookController.groovy)
> at GbookController.getOSISProvider(GbookController.groovy:933)
> at GbookController.this
> $2$getOSISProvider(GbookController.groovy)
> at GbookController.getOSISString(GbookController.groovy:762)
> at GbookController$_closure12.doCall(GbookController.groovy:
> 481)
> at GbookController$_closure12.doCall(GbookController.groovy)
The routine that is calling RawLDBackend.get(int) is passing a -1.
Here is the SwordDictionary.getKey(text) method):
public Key getKey(String text) throws NoSuchKeyException
{
checkActive();
int pos = backend.indexOf(new DefaultLeafKeyList(text));
if (pos < 0)
{
if (backend.getCardinality() > -pos - 1)
{
return backend.get(-pos - 1);
}
return backend.get(backend.getCardinality() - 1);
}
return backend.get(pos);
}
From this it appears that pos is getting a negative value and is
hitting the line:
return backend.get(backend.getCardinality() - 1);
The purpose of this is on a full miss to return the last element in
the dictionary.
Since the exception is reporting an array out of bounds exception of
-1, it appears that
backend.getCardinality()
is returning 0.
The computation of getCardinality() first opens the module with a call
to checkActive(). There's a bit of magic going on here with activator,
but that calls activate(). If activate() encounters a problem with
opening any of the files, it returns that the module has 0 entries. If
it encounters any problem, it reports the problem via the Reporter
(Have you set up a listener to the Reporter?) or the log (have you
checked the log?).
Otherwise, it gets the size of the index file and divides that by size
of a single entry in the index, as every entry in the index is the
same size.
My suggestion is to check the size of the idx and dat files to see if
they make sense. If so, check the read permissions on them and the
folders above them. If that checks out, debug line 195 in RawLDBackend
to see if the path makes sense. If it does not, check the conf to see
if it specifies DataPath properly.
Hope this helps.
In Christ,
DM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20090402/c716541e/attachment.html>
More information about the jsword-devel
mailing list