Update test to work around SBCL cleverness (thanks to Patrick Stein)
[trivial-backtrace.git] / dev / mucking.lisp
blob2be26a5a870e2db016c3fa2a19a178fbec1ce4ab
1 (in-package #:metabang.gsn)
3 #|
4 Need to account for different kinds of links
5 in gsn-nodes-from-json, need to return pairs of node and attributes
7 hash-table for nodes to prevent duplicates
8 queue or stack for nodes to expand
9 hash-table for links (triples of A link B?) to handle duplicates
12 (defgeneric expand-node (context node)
15 (defgeneric find-neighbors (context node)
18 (defgeneric expand-node-p (context node)
21 (defgeneric add-node (context node)
24 (defgeneric add-link (context node neighbor direction)
27 (defgeneric update-node-data (context node data)
30 (defclass abstract-context ()
31 ())
33 (defclass gsn-context (abstract-context)
34 ())
36 (defparameter +gsn-root+ "http://socialgraph.apis.google.com/")
38 (defmethod expand-node ((context abstract-context) node)
39 (bind (((to from) (find-neighbors context node)))
40 (dolist (neighbor to)
41 (add-node context neighbor)
42 (add-link context node neighbor :to))
43 (dolist (neighbor from)
44 (add-node context neighbor)
45 (add-link context node neighbor :from))))
49 (defmethod find-neighbors ((context gsn-context) node)
50 (bind (((result headers stream)
51 (http-get
52 (format nil "~alookup?edo=1&edi=1&pretty=1&q=~a"
53 +gsn-root+ node)))
54 json)
55 (unwind-protect
56 (setf json (json:decode-json stream))
57 (close strea))
58 (update-node-data context node json)
59 (list (gsn-nodes-from-json json :to)
60 (gsn-nodes-from-json json :from))))
62 (gsn-nodes-from-json x :from)
64 (defun gsn-test (who)
65 (destructuring-bind (result headers stream)
66 (http-get
67 (format nil "http://socialgraph.apis.google.com/lookup?edo=1&edi=1&pretty=1&q=~a" who))
68 (declare (ignore result headers))
69 (json:decode-json stream)))
71 (assoc :nodes_referenced
72 (assoc :nodes (gsn-test "TWITTER.COM/GWKING") :key #'first))
75 (setf x (gsn-test "TWITTER.COM/GWKING"))