;=========================================================================== ; labeler.ss : labeling module for recognition section ;=========================================================================== ; globals: *parts* list of parts in quanta-pair form (unlabeled) ;--------------------------------------------------------------------------- ; Here is where a coderack is first used. The *workspace* consists of ; the *parts* all labeled with some whinyness. Codelets run around ; attempting to label parts (see codelets.ss) and maybe joining especially ; whiny parts. ; number of labeler codelets to spin (by looker) (set! *labelers* 10) ; The workspace will have the form of a list of joints followed by ; a list of labels. In the beginning the label (**whine 20) is attached ; to each of the parts. A part whines until it has been looked over ; and "passed" by a looker-codelet. (define set-up-workspace (lambda () (let ((pls *parts*)) (letrec ((attach-whine (lambda (part) (snoc '(**whine 20) (list part)))) (loop (lambda (pls) (cond ((null? pls) '()) (else (cons (attach-whine (car pls)) (loop (cdr pls)))))))) (set! *workspace* (loop pls)))))) ; two lookers for each item in the workspace ; *gestalt-codelet* gestalt-codelets at low activation (define initialize-coderack (lambda () (add-n-to-coderack *gestalt-codelets* gestalt-codelet 'gestalt *very-high-urgency* 1) (let ((ctr (length *workspace*))) (letrec ((loop (lambda (n) (cond ((= n 0) #t) (else (add-to-coderack looker-codelet 'looker *medium-urgency* 3) (loop (sub1 n))))))) (loop (* 2 ctr)))))) (define label-parts (lambda () (if *graphics* (draw-info-bar "recognizing...")) (set-up-workspace) ; sun graphics (if *graphics* (begin (draw-subgloms (make-display-list *workspace*)) (if (not *draw-codelets*) (draw-no-codelets) (draw-codelet-message-back)))) (set! *coderack* '()) (initialize-coderack) (smart-parse) ; dangerous stuff!!! Added 12/9/98 ; JAR added new bonding to help with parsing (helps?) (set! *joints* '()) (set! *redund-ants* 0) (if (not (null? (apply append (map pick-neighbor-to-glom *quanta-list*)))) (bond-quanta) (smart-parse)) (exam-run))) ;----------------------( labeling functions )-------------------------------- ; add some to the whine label of a part - direct side-effect to *workspace* (set! *whine-constant* 10) ; Add whine-constant whiny points to a given part (define increase-whine (lambda (part) (let ((new-whine (+ (lookup-score '**whine part) *whine-constant*))) (begin (remove-whine part) (add-label (car part) (list '**whine new-whine)))))) ; Remove the whine label from a part (define remove-whine (lambda (part) (set! *workspace* (cons (without-whine part) (remq part *workspace*))))) (define without-whine (lambda (ls) (cond ((null? ls) '()) ((and (not (atom? (car ls))) (eq? (caar ls) '**whine)) (without-whine (cdr ls))) (else (cons (car ls) (without-whine (cdr ls))))))) ; Add a label to a part (may be a list of the form (