anchor.diff:  	  (push token tokens)
   	  (setf token (next-token ts)))
   	(reverse tokens)))))
  +
  +
  +(require :json)
  +
  +(use-package :json)
  +
  +(defmethod encode-json ((p paste) stream)
  +  (let ((props `((:number . ,(paste-number p))
  +		 (:user . ,(paste-user p))
  +		 (:date . ,(paste-date p))
  +		 (:channel . ,(paste-channel p))
  +		 (:title . ,( paste-title p))
  +		 (:contents . ,(paste-contents p)))))
  +    (encode-json-alist props stream)))
  +
  +(defun write-json-pastes ()
  +  (with-open-file (f (make-pathname :name "pastes" :type "json" :defaults *corpus-path*)
  +		     :direction :output
  +		     :if-exists :supersede)
  +    (encode-json *pastes* f)))
  +
  
positive.code:     (index-paste *paste-index* paste))
    (optimize *paste-index*))
  
  (defun index-paste (index paste)
    (let ((doc (make-instance 'document)))
      ;; I'm just using the paste format as returned by
      ;; paste.lisp.org's XML-RPC API.
      (let ((number   (make-field "number"   (format nil "~S" (paste-number paste))
  				:index :untokenized :stored T))
  	  (user     (make-field "user"     (paste-user paste)
  				:index :untokenized :stored T))
  	  (date     (make-field "date"     (format nil "~S" (paste-date paste))
  				:index :untokenized :stored T))
  	  (channel  (make-field "channel"  (paste-channel paste)
  				:index :untokenized :stored T))
  
negative.code:     (search-each *paste-index* query
  		 #'(lambda (doc score)
  		     (when (= num-results 0)
  		       (format T "~&~5A ~19A ~5A ~15A" "Score" "Date" "#" "User")
  		       (format T "~&-------------------------------------------"))
  		     (incf num-results)
  		     (print-result doc score))
  		 options)
  