Permalink
Browse files

Remove web for now, move stat to analysis.

  • Loading branch information...
1 parent 100448a commit f8545236b105ea2c993da3d347ac521e4aaec590 @mmcgrana committed Apr 28, 2010
View
@@ -1,7 +1,3 @@
# thompson
A JVM library for performing computational algebra experiments in [Thompson's group F](http://en.wikipedia.org/wiki/Thompson_groups).
-
-The core algorithms are implemented in Java and therefore easily accessible from any JVM language.
-
-This project also implements a web interface to these algorithms, available at [thompson-web.appspot.com](http://thompson-web.appspot.com).
View
@@ -1,13 +0,0 @@
-#!/bin/bash
-set -e
-
-SDK_PATH="/usr/local/appengine-java-sdk-1.3.1"
-JAR_PATH=$SDK_PATH"/lib/user/appengine-api-1.0-sdk-1.3.1.jar"
-WAR_PATH="gae/war"
-
-rm -rf $WAR_PATH/WEB-INF/lib $WAR_PATH/WEB-INF/classes
-cp -r lib $WAR_PATH/WEB-INF/lib
-cp $JAR_PATH $WAR_PATH/WEB-INF/lib
-cp -r classes $WAR_PATH/WEB-INF/classes
-
-$SDK_PATH/bin/appcfg.sh update $WAR_PATH
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
- <application>thompson-web</application>
- <version>1</version>
-</appengine-web-app>
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
- <servlet>
- <servlet-name>thompson-web</servlet-name>
- <servlet-class>thompson.web.prod_server</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>thompson-web</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
@@ -1,10 +1,10 @@
-(ns thompson.stat.calc
+(ns thompson.analysis.calc
(:require [clojure.contrib.duck-streams :as stream]
[clojure.contrib.seq-utils :as seq]
[clojure.contrib.str-utils :as str]
- [thompson.stat.gnuplot :as gnuplot])
+ [thompson.analysis.gnuplot :as gnuplot])
(:import thompson.core.GenExp
- org.apache.commons.math.stat.descriptive.DescriptiveStatistics))
+ org.apache.commons.math.analysis.descriptive.DescriptiveStatistics))
(defn words-path [l]
(str "/tmp/thompson-samples/" l ".txt"))
@@ -1,4 +1,4 @@
-(ns thompson.stat.gnuplot
+(ns thompson.analysis.gnuplot
(:require [clojure.contrib.shell-out :as shell]
[clojure.contrib.duck-streams :as stream]
[clojure.contrib.java-utils :as java]
@@ -1,7 +0,0 @@
-(ns thompson.web.bounce-favicon)
-
-(defn wrap-bounce-favicon [handler]
- (fn [req]
- (if (= "/favicon.ico" (:uri req))
- {:status 404 :headers {"Content-Type" "text/html"} :body ""}
- (handler req))))
@@ -1,12 +0,0 @@
-(ns thompson.web.dev-server
- (:use ring.adapter.jetty
- (ring.middleware reload stacktrace)
- (thompson.web handler bounce-favicon)))
-
-(def dev-app
- (-> #'handle-thompson
- (wrap-reload '(thompson.web.handler))
- wrap-stacktrace
- wrap-bounce-favicon))
-
-(run-jetty dev-app {:port 8080})
@@ -1,133 +0,0 @@
-(ns thompson.web.handler
- (:use (clj-html core helpers)
- (clojure.contrib [def :only (defvar-)])
- ring.handler.dump
- ring.middleware.params)
- (:require (clojure.contrib [str-utils :as str]))
- (:import (thompson.core GenExp TreePair)))
-
-(defvar- sample-input
- "(x_2^-3)(x_1^2)\n(x_1^-4)(x_1^-1)")
-
-(defn- parse-elems [input]
- (map #(GenExp/fromString %) (str/re-split #"\s+" input)))
-
-(defn- unparse-elems [elems]
- (str/str-join "\n" (map str elems)))
-
-(defn- normalize [elems]
- (map #(.toNormalForm #^GenExp %) elems))
-
-(defn- invert [elems]
- (map #(.invert #^GenExp %) elems))
-
-(defn- product [elems]
- (list (GenExp/product (into-array elems))))
-
-(defn- word-length [elems]
- (map #(.wordLength (.toTreePair #^GenExp %)) elems))
-
-(defvar- operation-fns
- {"normalize" normalize
- "invert" invert
- "product" product
- "word length" word-length})
-
-(defn- compute [operation input]
- (try
- (let [in-elems (parse-elems input)
- operation-fn (operation-fns operation)
- out-elems (operation-fn in-elems)]
- (unparse-elems out-elems))
- (catch Exception e
- (let [m (.getMessage e)]
- (if (and m (re-find #"expected" m))
- (str/str-join "\n"
- ["input error:"
- (re-find #"expected.*" m)])
- (throw e))))))
-
-(defn- not-found-view []
- (html
- [:p "404 Not Found"]))
-
-(defn- layout-view [subtitle & content]
- (html
- (doctype :xhtml-transitional)
- [:html {:xmlns "http://www.w3.org/1999/xhtml"}
- [:head
- [:meta {:http-equiv "Content-Type" :content "text/html;charset=utf-8"}]
- [:title (str "thompson: " subtitle)]]
- [:body
- content]]))
-
-(defn- multi-submit [name values]
- (for [value values]
- [:input {:type "submit" :name name :value value}]))
-
-(defn- compute-view [& [input output]]
- (layout-view "compute"
- (form {:to [:post "/compute"]}
- "Input:" [:br]
- (text-area "input" input
- {:rows 10 :cols 140 :spellcheck false}) [:br]
- (multi-submit "compute"
- `("normalize" "invert" "product" "word length")))
- [:br] [:br]
- "Output:" [:br]
- (text-area "output" output
- {:rows 10 :cols 140 :spellcheck false}) [:br]
- [:br]
- (link "about" "/about") " " (link "help" "/help")))
-
-(defn- help-view []
- (layout-view "help"
- [:p "Enter one element from Thompson's group F on each line of the input
- box. Elements must in the form (x_i^a)(x_j^b)(x_k^c) etc."]
- [:p "Then select one of the available operations:"]
- [:p [:code "normalize"]
- ": Find the unique normal form for each given element."]
- [:p [:code "invert"]
- ": Find the inverse for each given element."]
- [:p [:code "product"]
- ": Compute the product of the given elements and show the result in
- unique normal form."]
- [:p [:code "word length"]
- ": Calculate the word length for each given element with respect to the
- {x_0, x_1} generating set."]))
-
-(defn- about-view []
- (layout-view "about"
- [:p "This is the web interface to " [:code "thompson"] ", a JVM library for
- computational algebra in " (link "Thompson's group F"
- "http://en.wikipedia.org/wiki/Thompson_groups") "."]
- [:p "Usage information is available on the " (link "help page" "/help") "."]
- [:p "Please send comments, questions, and bug reports to "
- (link "Mark McGranaghan" "http://markmcgranaghan.com") " at "
- (link "mmcgrana@gmail.com" "mailto:mmcgrana@gmail.com")]
- [:p "The source code for this application is available on "
- (link "GitHub" "http://github.com/mmcgrana/thompson") "."]))
-
-(defn- respond [body & [opts]]
- {:status (:status opts 200)
- :headers {"Content-Type" "text/html"}
- :body body})
-
-(defn- core [req]
- (condp = [(:request-method req) (:uri req)]
- [:get "/"]
- (respond (compute-view sample-input))
- [:post "/compute"]
- (let [input (get (:params req) "input")
- operation (get (:params req) "compute")
- output (compute operation input)]
- (respond (compute-view input output)))
- [:get "/help"]
- (respond (help-view))
- [:get "/about"]
- (respond (about-view))
- (respond (not-found-view) {:status 404})))
-
-(def handle-thompson
- (-> core
- wrap-params))
@@ -1,10 +0,0 @@
-(ns thompson.web.prod-server
- (:use ring.util.servlet
- (thompson.web bounce-favicon handler))
- (:gen-class :extends javax.servlet.http.HttpServlet))
-
-(def prod-app
- (-> handle-thompson
- wrap-bounce-favicon))
-
-(defservice prod-app)
@@ -1,27 +0,0 @@
-(ns thompson.web.handler-test
- (:use clojure.test
- thompson.web.handler))
-
-(deftest test-index
- (let [req {:request-method :get :uri "/"}
- resp (handle-thompson req)]
- (is (re-find #"Input" (:body resp)))))
-
-(deftest test-about
- (let [req {:request-method :get :uri "/about"}
- resp (handle-thompson req)]
- (is (re-find #"information" (:body resp)))))
-
-(deftest test-help
- (let [req {:request-method :get :uri "/help"}
- resp (handle-thompson req)]
- (is (re-find #"operations" (:body resp)))))
-
-(deftest test-compute
- (let [req {:request-method :post :uri "/compute"
- :params {"compute" "invert",
- "input" "(x_2^-3)(x_1^2)\r\n(x_1^-4)(x_1^-1)"}}
- resp (handle-thompson req)]
- (is (= 200 (:status resp)))))
-
-(deftest test-input-error-handling)

0 comments on commit f854523

Please sign in to comment.