%@ page language="java" import="java.io.*,java.util.*,com.tks.celt.*" %> <%! static int userCount = 0; public String[] parseString(String wholeString){ //System.out.println("whole String" + wholeString); if(wholeString.startsWith("\"")){ wholeString = wholeString.substring(1); } if(wholeString.endsWith("\"")){ wholeString = wholeString.substring(0, wholeString.length()-1); } Vector elements = new Vector(); int index = 0; int previousIndex = 0; while( (index =wholeString.indexOf("\\n", previousIndex)) != -1){ //System.out.println("String " + wholeString.substring(previousIndex, index)); String token = wholeString.substring(previousIndex, index); token = token.replaceAll(" "," "); elements.add(token); previousIndex = index; previousIndex = previousIndex + 2; } if(previousIndex != wholeString.length()){ String token = wholeString.substring(previousIndex, wholeString.length()); token = token.replaceAll(" "," "); elements.add(token); } String[] stringElements = new String[elements.size()]; for(int i=0; i < elements.size(); i++){ stringElements[i] = (String) elements.get(i); } return stringElements; } %> <% HashMap bindings = new HashMap(); String query = request.getParameter("query"); if(query == null){ response.sendRedirect("query.jsp"); return; } String user = (String) session.getAttribute("user"); if(user == null){ user = "user"+userCount++; session.setAttribute("user","user"+userCount++); } PrologHandler prologHandler = new PrologHandler(); String result = ""; try{ result = prologHandler.sendRequest(query,300,user); }catch(Exception e){ System.out.println(e); result = e.getMessage(); } result = result.replaceAll("<->", ":"); //System.out.println("replaced string " + result); StringReader stringReader = new StringReader(result); ResponseProcessor responseProcessor = new ResponseProcessor(); responseProcessor.processResponse(stringReader); bindings = responseProcessor.getBindings(); //responseProcessor.processResponse(result); %>
Controlled English to Logic Translation CELT |
|
English Sentence : | |
<%= query %> | |
No translation at this stage. | |
English Sentence : | |
<%= query %> | |
<%= warning %> | |
English Sentence : | |
<%= query %> | |
Translation to Logic : | |
<%= tokens[i] %> | |
Parsed Sentence : | |
<%= parsedTree %> | |
Speech Act : | |
<%= action %> |