Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bvds/andes
Browse files Browse the repository at this point in the history
  • Loading branch information
asamiam committed Feb 3, 2011
2 parents daf6753 + a8f04bb commit 5347a1c
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 74 deletions.
161 changes: 87 additions & 74 deletions Help/Entry-API.cl
Expand Up @@ -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*)
Expand All @@ -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~%"
Expand All @@ -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
Expand All @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions andes-help.asd
Expand Up @@ -105,6 +105,10 @@
"word-suggest"
"grammar" "symbols"
"Commands"))))
(:module "dashboard"
:depends-on ("Help")
:components (
(:file "dashboard")))
(:module "Testcode"
:depends-on ("Help" "HelpStructs")
:components (
Expand Down
42 changes: 42 additions & 0 deletions 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
;;; <http:;;;www.gnu.org/licenses/>.


;; 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.
)
6 changes: 6 additions & 0 deletions lisp-site-install/Makefile
Expand Up @@ -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")
Expand Down

0 comments on commit 5347a1c

Please sign in to comment.