String[] args=request.getParameterValues("text1");
System.setProperty("wordnet.database.dir", "C:/Program Files/WordNet/2.1/dict/");
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.getFileInstance();
Synset[] synsets = database.getSynsets(wordForm);
// Display the word forms and definitions for synsets retrieved
if (synsets.length > 0)
{
out.println("The following synsets contain '" +
wordForm + "' or a possible base form " +
"of that text:");
for (int i = 0; i < synsets.length; i++)
{
out.println("");
String[] wordForms = synsets[i].getWordForms();
for (int j = 0; j < wordForms.length; j++)
{
out.print((j > 0 ? ", " : "") +
wordForms[j]);
}
out.println(": " + synsets[i].getDefinition());
}
}
else
{
out.println("No synsets exist that contain " +
"the word form '" + wordForm + "'");
}
}
else
{
out.println("You must specify " +
"a word form for which to retrieve synsets.");
}
错误:
An error occurred at line: 29 in the jsp file: /index.jsp
Synset cannot be resolved to a type
26: String wordForm = buffer.toString();
27: // Get the synsets containing the wrod form
28: WordNetDatabase database = WordNetDatabase.getFileInstance();
29: Synset[] synsets = database.getSynsets(wordForm);
30: // Display the word forms and definitions for synsets retrieved
31: if (synsets.length > 0)
32:
{
堆栈跟踪:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:443)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:744)