SPT - Synonyms Source Design
I. Introduction
Synonyms are read in from file(s) and kept in the following table:
Vector<SynonymObj> to keep all synonym information
Hashtable<String, Vector<Integer>> to keep the indexes of each word
Theoretically, all synonyms are symmetric (bi-directional), so only one (direction) synonym is needed to read in from users. The system will automatically generate the symmetric synonym. In addition, duplicated synonyms are ignored. This information is stored in a Vector of Synonym pairs as a result of:
II. Algorithm
III. Java Classes
IV. Example
Inputs:
Vector<Synonym> synonymList_
| index | Synonym | |
|---|---|---|
| word | synonym | |
| 0 | dog | canine |
| 1 | canine | dog |
| 2 | cat | feline |
| 3 | feline | cat |
| 4 | canine | mutt |
| 5 | mutt | canine |
Hashtable<String, Vector<Integer>> synonymIndex_
| key | Values |
|---|---|
| word | Vector<Integer> |
| dog | [0] |
| canine | [1, 4] |
| cat | [2] |
| feline | [3] |
| mutt | [5] |