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