You are on page 1of 2

import edu.smu.tspell.wordnet.

*; /** * Displays word forms and definitions for synsets containing the word form * specified on the command line. To use this application, specify the word * form that you wish to view synsets for, as in the following example which * displays all synsets containing the word form "airplane": * <br> * java TestJAWS airplane */ public class TestJAWS { /** * Main entry point. The command-line arguments are concatenated togethe r * (separated by spaces) and used as the word form to look up. */ public static void main(String[] args) { if (args.length > 0) { // Concatenate the command-line arguments StringBuffer buffer = new StringBuffer(); for (int i = 0; i < args.length; i++) { buffer.append((i > 0 ? " " : "") + args[i]); } String wordForm = buffer.toString(); // Get the synsets containing the wrod form WordNetDatabase database = WordNetDatabase.getFileInstan ce(); Synset[] synsets = database.getSynsets(wordForm); // Display the word forms and definitions for synsets r etrieved if (synsets.length > 0) { System.out.println("The following synsets contai n '" + wordForm + "' or a possible base form " + "of that text:"); for (int i = 0; i < synsets.length; i++) { System.out.println(""); String[] wordForms = synsets[i].getWordF orms(); for (int j = 0; j < wordForms.length; j+ +) { System.out.print((j > 0 ? ", " : "") + wordForms[j]); } System.out.println(": " + synsets[i].get Definition()); } } else {

System.err.println("No synsets exist that contai n " + "the word form '" + wordForm + " '"); } } else { System.err.println("You must specify " + "a word form for which to retrieve synse ts."); } } }

You might also like