Hello everyone,
as you've probably gathered fromt he subject line, I'm having issues
subclassing the Dictionary class. In a nutshell, I want to be able to
provide a mapping between names and synonyms which the current
dictionary doesn't seem to support. So my approach is the following:
1. create a class (MyDictionary) that extends Dictionary and overrides
'.contains()'
2. MyDictionary calls the constructor of the superclass with no args
(per 'super();')
3. it also hard-codes 'maxTokenCount' and 'minTokenCount' (10 & 1
respectively) because there is no setter method for them and are
declared private. Unless, one reads entries in from a xml file and
'puts' them in the Dictionary via 'EntryInserter' there is no way to
provide them even if we know the correct values. without doing this
the name-finder 'breaks out' the for-loop because this condition
doesn't hold:
if (lengthSearching > d.getMaxTokenCount()) { //maxTokenCount stays 0 if
the .put() is never called
break; //breaks immediately
} else ...
....
anyway, I know it is not pretty to hard-code it like that but I couldn't
think of anything else...I have verified that MyDictionary works as
expected on its own. that is, I'm passing a string to .contains() and it
correctly says true / false. I have also verified that when MyDictionary
is passed to the DictionaryNameFinder it spends some time searching
which implies that the for-loop continues as usual. Before hardcoding
'maxTokenCount' and 'minTokenCount' the call to .find() would finish
instantly cos it was never reaching the call to .contains()...
My problem is that despite everything seemingly working as expected I
get 0 in all statistics!!! I can verify that when i use a proper xml
file with the regular Dictionary i get descent statistics so adding
synonyms in the search space can only improve statistics and decrease
performance. I do see a decrease in performance but certainly not in
performance! very weird stuff...
would you say that I need to follow any extra steps for subclassing the
Dictionary? It has many methods but only the .contains() and the
getMaxTokenCount() are used in the actual .find() method of the NameFinder.
any clues/pointers? the odd thing is that MyDictionary on its own does
the right thing (regardless of what happens inside the .contains() method).
Help please...
thanks in advance
Jim