From 23bacb60a80c9dcb41031d498856b9d066c547c8 Mon Sep 17 00:00:00 2001 From: Brett van de Sande Date: Mon, 24 Jan 2011 17:58:36 -0700 Subject: [PATCH 1/3] Clean up and document rules for matching quantities. Fix Bug #1857. Lower max bound a bit. --- Help/Entry-API.cl | 161 +++++++++++++++++++++++++--------------------- 1 file changed, 87 insertions(+), 74 deletions(-) diff --git a/Help/Entry-API.cl b/Help/Entry-API.cl index 07b994087..607ae95c7 100644 --- a/Help/Entry-API.cl +++ b/Help/Entry-API.cl @@ -204,24 +204,36 @@ ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Here is what is missing: -;; Should include "bad" quantity definitions in matching. ;; Should have something to handle extra stuff like setting ;; given values in definition. (either handle it or warning/error). +;; 1. Score is number of words wrong plus one for the wrong tool. +;; 2. In the event of a tie, a word error has higher weight than +;; a tool error. +;; 3. Assume, for determining bounds, that scores are integer +;; valued. Thus, if we want to do better, than we demand the +;; bound be decreased by 1. + (defun match-student-phrase0 (student tool-prop &key (cutoff-fraction 0.4) ;; If larger, too slow on benchmarks - (cutoff-max 4)) + (cutoff-max 3.7)) "Match student phrase to Ontology, returning best matches for tool or other tool." - ;; :cutoff-fraction is fractional length of student phrase to use as bound. - ;; :cutoff-count is maximum allowed score to use as bound. + ;; :cutoff-fraction is fractional length of student phrase plus one + ;; (for the tool) to use as bound. This should be adjusted to + ;; balance type 1 and type 2 errors: + ;; bad matches that are accepted vs. + ;; good matches that are missed + ;; :cutoff-max is maximum allowed score to use as bound. This should + ;; be adjusted to so that very long student phrases can + ;; be matched quickly enough. (let* ((sysentries (remove (cons tool-prop '?rest) *sg-entries* :key #'SystemEntry-prop :test-not #'unify)) - ;; used for best and maybe for wrong-tool-best - (initial-cutoff (max 2 ;always allow wrong-tool, wrong-prop error - (min (* cutoff-fraction (length student)) - cutoff-max))) + (initial-cutoff (min (* cutoff-fraction (+ (length student) 1)) + cutoff-max)) + ;; To speed up best-wrong-match for long phrases, maybe reduce + ;; max cutoff a bit. + (wrong-cutoff-max (- cutoff-max 0)) ;; For any debugging prints in matching package. ;; This also applies to any wrong matches below. (*standard-output* webserver:*stdout*) @@ -234,10 +246,10 @@ sysentries) :cutoff initial-cutoff)) ;; The value of the best correct match or the initial cutoff. - ;; This is used to determine cutoffs for wrong quantity matches. - (best-correct (if best (best-value best) initial-cutoff)) + ;; This is used to determine cutoffs for wrong quantity searches. + (wrong-bound (if best (best-value best) initial-cutoff)) wrong-tool-best) - + ;; Debug printout: (when nil (format t "Best match to ~s is~% ~S~% from ~S~%" @@ -249,19 +261,16 @@ best) (mapcar #'systementry-prop sysentries))) - ;; If there isn't a good match to solution quantities, - ;; try another tool and non-solution quanitities. - (when (>= best-correct 1) - - ;; Attempt to detect a wrong tool error. - ;; The strategy is to treat the choice of tool as being - ;; worth 1 word, when matching. - ;; - ;; Cases: - ;; wrong-tool-best same as best-1 (using equiv) - ;; toss-up: give unsolicited hint and pass through. - ;; wrong-tool-best less than best score minus 1 or no best. - ;; this certainly should be given wrong tool help. + ;; Attempt to detect a wrong tool error. + ;; The strategy is to treat the choice of tool as being + ;; worth 1 word, when matching. + ;; + ;; Cases: + ;; wrong-tool-best same as best-1 (using equiv) + ;; toss-up: give unsolicited hint and pass through. + ;; wrong-tool-best less than best score minus 1 or no best. + ;; this certainly should be given wrong tool help. + (when (>= wrong-bound 1) (let* ((allowed-tools (remove tool-prop *tool-props-with-definitions*)) (sysentries (remove-if #'(lambda (x) (not (member @@ -278,61 +287,65 @@ ;; If there is no match in best, then the help is ;; pretty weak. In that case, just find anything ;; below the cutoff. - :cutoff (- best-correct 1)))) - - ;; Attempt to match to quantities not in solution, - ;; assuming no wrong-tool error. - ;; Never returns more than one quantity: There is no - ;; point in having the student resolve an ambiguity if - ;; quantities are wrong anyway. - - ;; We don't have any way of handling inheritance for - ;; non-solution quantities. As a cheap work-around, - ;; take shortest matching proposition. - ;; need to pre-order quantities so that shorter propositions - ;; are matched first... + :cutoff (- wrong-bound 1))))) + + ;; Attempt to match to quantities not in solution, + ;; assuming no wrong-tool error. + ;; Never returns more than one quantity: There is no + ;; point in having the student resolve an ambiguity if + ;; quantities are wrong anyway. + + ;; We don't have any way of handling inheritance for + ;; non-solution quantities. As a cheap work-around, + ;; take shortest matching proposition. + ;; need to pre-order quantities so that shorter propositions + ;; are matched first... + (when (or (null best) (>= (best-value best) 1)) (update-bound best (best-wrong-match student tool-prop - :cutoff (min (- best-correct 1) + :cutoff (min wrong-cutoff-max + (if best + (- (best-value best) 1) + initial-cutoff) (if wrong-tool-best - (best-value wrong-tool-best) - initial-cutoff)))) - - ;; Attempt to match to quantities not in solution where - ;; the wrong tool has also been used. - ;; Must be better than any quantity in solution, but allow - ;; for ties with one plus any quantity not in solution. - (when (and (>= best-correct 2) - (or (null best) (>= (best-value best) 1))) - (let ((tool-props (intersection - ;; other tools that have natural-language. - (remove tool-prop *tool-props-with-definitions*) - ;; list of tools in this problem solution. - (mapcar #'(lambda (x) (car (SystemEntry-prop x))) - *sg-entries*)))) - (dolist (tool-prop tool-props) - (when (or (null wrong-tool-best) - (>= (best-value wrong-tool-best) 1)) - (when nil ;debug print - (format t "Starting wrong tool ~A:~%" tool-prop)) - (update-bound - wrong-tool-best - (best-wrong-match - student - tool-prop - :cutoff (min (- best-correct 2) - (if best - (- (best-value best) 1) - initial-cutoff) - (if wrong-tool-best - (- (best-value wrong-tool-best) 1) - initial-cutoff)))))))) - ) ;end of things to try if there isn't good solution match. - - (values best wrong-tool-best best-correct sysentries))) + (best-value wrong-tool-best) + initial-cutoff))))) + + ;; Attempt to match to quantities not in solution where + ;; the wrong tool has also been used. + ;; Must be better than any quantity in solution, but allow + ;; for ties with one plus any quantity not in solution. + (when (and (>= wrong-cutoff-max 1) + (>= wrong-bound 1) + (or (null best) (>= (best-value best) 1))) + (let ((tool-props (intersection + ;; other tools that have natural-language. + (remove tool-prop *tool-props-with-definitions*) + ;; list of tools in this problem solution. + (mapcar #'(lambda (x) (car (SystemEntry-prop x))) + *sg-entries*)))) + (dolist (tool-prop tool-props) + (when (or (null wrong-tool-best) + (>= (best-value wrong-tool-best) 1)) + (when nil ;debug print + (format t "Starting wrong tool ~A:~%" tool-prop)) + (update-bound + wrong-tool-best + (best-wrong-match + student + tool-prop + :cutoff (- (min wrong-cutoff-max + (if best + (best-value best) + wrong-bound) + (if wrong-tool-best + (best-value wrong-tool-best) + wrong-bound)) 1))))))) + + (values best wrong-tool-best wrong-bound sysentries))) (defun match-student-phrase (entry tool-prop) "Match student phrase to Ontology, returning best match prop, tutor turn (if there is an error) and any unsolicited hints." From ba6ba0e1a4bfcdfd78f9e97aa611d0e7ff09144c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 26 Jan 2011 12:13:19 -0700 Subject: [PATCH 2/3] Added new processor names for Ubuntu install (cherry picked from commit 7fada018badd3299c6dbe940abd5ceef99d5aae8) --- lisp-site-install/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp-site-install/Makefile b/lisp-site-install/Makefile index 8057b4d4d..981b57480 100644 --- a/lisp-site-install/Makefile +++ b/lisp-site-install/Makefile @@ -31,12 +31,18 @@ ifeq ($(shell uname),Linux) ifeq ($(shell uname -p),i686) binary-release = sbcl-1.0.35-x86-linux-binary.tar.bz2 endif +ifeq ($(shell uname -m),i686) + binary-release = sbcl-1.0.35-x86-linux-binary.tar.bz2 +endif ifeq ($(shell uname -p),pentium4) # Andrew linux at CMU binary-release = sbcl-1.0.35-x86-linux-binary.tar.bz2 endif ifeq ($(shell uname -p),x86_64) binary-release = sbcl-1.0.29-x86_64-linux-binary-r2.tar.bz2 endif +ifeq ($(shell uname -m),x86_64) + binary-release = sbcl-1.0.29-x86_64-linux-binary-r2.tar.bz2 +endif endif ifndef binary-release $(error "Unknown architecture") From a8f04bbe81510f658374c6c6abc386c000bc4540 Mon Sep 17 00:00:00 2001 From: Brett van de Sande Date: Wed, 26 Jan 2011 14:28:52 -0700 Subject: [PATCH 3/3] Add stub for dashboard service. --- andes-help.asd | 4 ++++ dashboard/dashboard.cl | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 dashboard/dashboard.cl diff --git a/andes-help.asd b/andes-help.asd index 6a56f771f..d1af38916 100644 --- a/andes-help.asd +++ b/andes-help.asd @@ -105,6 +105,10 @@ "word-suggest" "grammar" "symbols" "Commands")))) + (:module "dashboard" + :depends-on ("Help") + :components ( + (:file "dashboard"))) (:module "Testcode" :depends-on ("Help" "HelpStructs") :components ( diff --git a/dashboard/dashboard.cl b/dashboard/dashboard.cl new file mode 100644 index 000000000..c041a64f2 --- /dev/null +++ b/dashboard/dashboard.cl @@ -0,0 +1,42 @@ +;;; Copyright 2011 by ... +;;; This file is part of the Andes Intelligent Tutor Stystem. +;;; +;;; The Andes Intelligent Tutor System is free software: you can redistribute +;;; it and/or modify it under the terms of the GNU Lesser General Public +;;; License as published by the Free Software Foundation, either version 3 +;;; of the License, or (at your option) any later version. +;;; +;;; The Andes Solver is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU Lesser General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General Public License +;;; along with the Andes Intelligent Tutor System. If not, see +;;; . + + +;; The method will also have to be added to the Andes3 API which +;; is defined in the file: web-UI/andes/andes3.smd + + +(webserver:defun-method "/help" dasboard (&key this or that) + "Stub for dashboard service method." + + ;; lisp code to handle request would be here. + ;; See file Help/sessions.cl for example methods. + ;; You will note that the other methods use the macro (env-wrap ...) + ;; which saves state information about a particular session; + ;; I don't think you need this for the dashboard? + + ;; To learn about lisp, I suggest the book "ANSI Common Lisp" by + ;; Paul Graham. I have a copy in my office if you want to borrow it. + ;; For reference, the LISP specification is at + ;; http://www.lispworks.com/documentation/HyperSpec/Front + + ;; We will have to discuss where to put the static (HTML) content. + ;; It might make sense to put it as a subdirectory under dashboard + ;; and provide a link in /var/www/html to point to that subdirectory. + ;; However, I assume it will be using Dojo and we need to figure + ;; out how best to do that. +)