1
15
16 package gate.wordnet;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import junit.framework.Assert;
22 import net.didion.jwnl.JWNLException;
23 import net.didion.jwnl.data.IndexWord;
24 import net.didion.jwnl.data.IndexWordSet;
25 import net.didion.jwnl.dictionary.Dictionary;
26
27 public class WordImpl implements Word {
28
29 private String lemma;
30 private int senseCount;
31 private ArrayList wordSenses;
32 private Dictionary wnDictionary;
33
34 public WordImpl(String _lemma, int _senseCount, Dictionary _wnDictionary) {
35
36 Assert.assertNotNull(_lemma);
38 Assert.assertNotNull(_wnDictionary);
39 Assert.assertTrue(_senseCount > 0);
40
41 this.lemma = _lemma;
42 this.senseCount = _senseCount;
43 this.wnDictionary = _wnDictionary;
44 }
45
46
47
48 public List getWordSenses() throws WordNetException{
49
50 if (null == this.wordSenses) {
52 _loadWordSenses();
53 }
54
55 return this.wordSenses;
56 }
57
58 private void _loadWordSenses() throws WordNetException {
59
60
62 try {
63 IndexWordSet iwSet = this.wnDictionary.lookupAllIndexWords(this.lemma);
64 IndexWord[] arrIndexWords = iwSet.getIndexWordArray();
65
66 for (int i=0; i< arrIndexWords.length; i++) {
67 IndexWord iWord = arrIndexWords[i];
68 net.didion.jwnl.data.Synset[] synsets = iWord.getSenses();
69 for (int j=0; j< synsets.length; j++) {
70 net.didion.jwnl.data.Synset currSynset = synsets[j];
71 }
72 }
73
74 }
76 catch(JWNLException jwne) {
77 throw new WordNetException(jwne);
78 }
79
80 }
81
82
83
84 public String getLemma(){
85 return this.lemma;
86 }
87
88
89
90 public int getSenseCount(){
91 return this.senseCount;
92 }
93 }