A kanji dictionary is different from a word dictionary in that the kanji dictionary is ordered by ideographs and provides information about different words and meanings represented by a ideograph, while a word dictionary has words as atomic entries and contains information about their spelling and meaning. Thus the data models of the dictionary types cannot be unified (I think).
Each dictionary consists of a list of dictionary entries. Each dictionary entry has several fields, depending on the dictionary format; e. g. word, reading, translations, notes, ...
Only word/reading and translations are hardcoded as methods in interface DictionaryEntry. All other entry data which a dictionary might supply is stored as attributes. Different dictionary formats may support different attributes.
One or more distinct spellings (okurigana/katakana/romaji/irr. spellings). Although the field is named WORD, it may contain whole phrases or sentences.
attributes (per word):
One or more readings of the word, spelled in hiragana + punctuation marks (support katakana/romaji readings?). More than one reading is only allowed if (a) the meaning (translation and all attributes) of all readings are identical and (b) the spelling of the reading does not conflict with any word part okurigana.
translations and information.
translation: One or more distinct ranges of meaning (rom). Each rom consists of one or more groups of closely related meanings (crm). Each crm is one or more synonymous definitions.
Different search types will need different index structures, index container needed.
UI and API needs to be extended to allow additional parameters (for example distance).
Search Mode Search Fields [r] Exact Match [x] Japanese [r] Prefix Match [x] Reading [r] Suffix Match [x] Translation [r] Any Match Match Mode [r] Pattern Match [r] whole field [r] Match Near [r] word [r] Match Radius Filter [x] Main entries only [x] Examples only Dictionary Choice Dictionary [....] All Dictionaries Expression: [.....................................] Distance [..]
A Dictionary implementation is responsible for creating and maintaining the indexes needed for the searches possible on that Dictionary class. Dictionary classes should implement the Indexable interface to support access to the dictionary from an Index object.
A dictionary file in format X is accessed using an instance of class XDictionary, which implements Dictionary and Indexable. XDictionary uses several different index formats, which have yet to be created. XDictionary instanciates FileIndexContainer (which implements IndexContainer) in edit mode to create a new index file. For each used index format, it then instanciates the class implementing IndexBuilder which creates an index of that format. XDictionary iterates over all words in the dictionary file, calling addEntry of the IndexBuilder. The IndexBuilder uses the methods provided by the Indexable interface to build the index. When this is done, the IndexBuilder writes the index data to the IndexContainer via the CreateIndex method. When all index types have been created, XDictionary calls the endEditing method of the IndexContainer.
A dictionary file in format X is accessed using an instance of class XDictionary, which implements Dictionary and Indexable. XDictionary accesses the already existing index file by creating a FileIndexContainer. The FileIndexContainer is opened in edit mode, and it is tested if all needed indexes are avaliable in the container. If not -> [Index update], otherwise switch index container to access mode. The dictionary then creates instances of Index subclasses which implement the indexing algorithms used. The Index subclasses access their data through the IndexContainer.
If a dictionary file is changed after the index is created, the whole IndexContainer is recreated as in [Index creation]. If an index of a particular type is not available in the IndexContainer, it can be added by opening the IndexContainer in edit mode. This might happen if a new index format is added in a later JGloss version, or if an indexing algorithm is changed in an incompatible way.