1 package gate.lexicon;
2
3 import java.util.Iterator;
4
5 import gate.creole.AbstractProcessingResource;
6 import gate.creole.ExecutionException;
7 import gate.util.Out;
8
9 public class TestNLGLexiconPR extends AbstractProcessingResource {
10
11 private NLGLexicon lexicon;
12 private boolean printOnly = false;
13
14 public TestNLGLexiconPR() {
15 }
16
17 public void setLexicon(NLGLexicon myLexicon) {
18 lexicon = myLexicon;
19 }
20
21 public NLGLexicon getLexicon(){
22 return lexicon;
23 }
24
25 public void setPrintOnly(Boolean isPrintOnly) {
26 printOnly = isPrintOnly.booleanValue();
27 }
28
29 public Boolean getPrintOnly(){
30 return new Boolean(printOnly);
31 }
32
33 public void execute() throws gate.creole.ExecutionException {
34 if (lexicon == null)
35 throw new ExecutionException("Lexicon not set");
36
37 Out.prln(lexicon.getVersion());
38
39 if (! printOnly) {
40 lexicon.setVersion("2.0");
41 MutableLexKBSynset newSynset = lexicon.addSynset();
42 newSynset.setDefinition("my synset definition");
43 newSynset.setPOS(NLGLexicon.POS_ADJECTIVE);
44 Out.prln(newSynset.getDefinition());
45 Out.prln(newSynset.getId());
46 Out.prln(newSynset.getPOS());
47 }
48
49 Iterator iter = lexicon.getSynsets(NLGLexicon.POS_ADJECTIVE);
50 while (iter.hasNext()) {
51 LexKBSynset synset = (LexKBSynset) iter.next();
52 Out.prln("definition: " + synset.getDefinition());
53 Out.prln("id " + synset.getId());
54 Out.prln("pos " + synset.getPOS());
55
56 }
57
58 }
59
60 }