mirror of
https://github.com/fooflington/wordbubbles.git
synced 2025-04-04 18:19:08 +00:00
allow dictionary picking
This commit is contained in:
parent
acd359f2be
commit
6e5eb2b2c5
@ -1,12 +1,31 @@
|
||||
<html>
|
||||
<head><title>Wordbubbles solver</title></head>
|
||||
<%@ page import="uk.org.mafoo.wordbubbles.*" %>
|
||||
<%@ page import="java.io.File" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<body>
|
||||
<h1>Wordbubbles or Boggle solver</h1>
|
||||
<h2>Input grid</h2>
|
||||
<form action="solver.jsp">
|
||||
<input type="radio" name="dictionary" checked>twl06</input><br />
|
||||
|
||||
<%
|
||||
File directory = new File(application.getRealPath("WEB-INF/dicts"));
|
||||
File[] fList = directory.listFiles();
|
||||
boolean first = true;
|
||||
List<String> filelist = new ArrayList<String>();
|
||||
for (File file : fList) {
|
||||
if(file.getName().matches("^[a-z\\-_]+$")) {
|
||||
filelist.add(file.getName());
|
||||
}
|
||||
}
|
||||
Collections.sort(filelist);
|
||||
for(String file : filelist) {
|
||||
%>
|
||||
<input type="radio" name="dict" value="<%= file %>" <% if(first) { %>checked<%}%>><%= file %></input>
|
||||
<%
|
||||
first = false;
|
||||
}
|
||||
%>
|
||||
<br />
|
||||
<textarea name="grid" rows="10" cols="10" style="font-family: monospace;">
|
||||
som e
|
||||
te xt
|
||||
|
@ -8,7 +8,16 @@
|
||||
|
||||
// String dict = request.getParameter("dictionary");
|
||||
// if(dict != "twl06") throw new Exception("failed to get dictionary");
|
||||
String dict = "/usr/share/dict/twl06";
|
||||
String dict_file = "words";
|
||||
if(request.getParameter("dict") != null) {
|
||||
if(request.getParameter("dict").matches("^[a-z\\-_]+$")) {
|
||||
dict_file = request.getParameter("dict");
|
||||
} else {
|
||||
throw new Exception ("invalict dict paramter");
|
||||
}
|
||||
}
|
||||
|
||||
String dict = application.getRealPath("WEB-INF/dicts") + "/" + dict_file;
|
||||
|
||||
uk.org.mafoo.wordbubbles.Lexicon words = uk.org.mafoo.wordbubbles.Lexicon.loadLexiconFromFile(dict);
|
||||
ArrayList<ArrayList<Character>> grid = new ArrayList<ArrayList<Character>>();
|
||||
@ -65,13 +74,18 @@ for ( LinkedHashSet<Cell> w : found ) {
|
||||
%>
|
||||
</table>
|
||||
|
||||
<% if(desired_active) { %> Looking for words of length(s): <%= desired %> <% } %>
|
||||
<h2>Results</h2>
|
||||
<% if(desired_active) { %> Looking for words of length(s): <%= desired %> <% } %><br />
|
||||
Using dictionary: <%= dict_file %>
|
||||
|
||||
<ul style="font-family: monospace;">
|
||||
<%
|
||||
<%
|
||||
List<String> output = new ArrayList<String>(foundwords);
|
||||
Collections.sort(output);
|
||||
%>
|
||||
|
||||
<h2>Results</h2>
|
||||
Count: <%= output.size() %>
|
||||
<ul style="font-family: monospace;">
|
||||
<%
|
||||
for (String word : output) { %>
|
||||
<li><%= word %></li>
|
||||
<% } %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user