File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 33(in-package # :kgsampler)
44
55(defun dbpedia-as-nt (query)
6+ " Query DBpedia and return results in N-Triples format."
67 (print query)
78 (uiop :run-program
89 (list
1314 :output :string ))
1415
1516(defun construct-from-dbpedia (entity-uri-list &key (output-stream t ))
17+ " For a list of DBpedia entity URIs, fetch all triples for each and write to a stream."
1618 (dolist (entity-uri entity-uri-list)
1719 (format output-stream " ~%~% # ENTITY NAME: ~A~%~% " entity-uri)
1820 (format
7981 (concatenate ' string " <" s " >" )))
8082
8183(defun find-relations (entity-uri-list &key (output-stream t ))
84+ " Discover relationships between pairs of entities in a list of URIs and write them to a stream."
8285 (format output-stream " ~%~% # DISCOVERED RELATIONSHIPS~%~% " )
8386 (dolist (entity-uri1 entity-uri-list)
8487 (dolist (entity-uri2 entity-uri-list)
98101 entity-uri2)))))))
99102
100103(defun sample (entity-uri-list output-filepath)
104+ " Generate a sample knowledge graph from a list of DBpedia entities and save to a file."
101105 (with-open-file (ostream (pathname output-filepath) :direction :output :if-exists :supersede )
102106 (construct-from-dbpedia entity-uri-list :output-stream ostream)
103107 (find-relations entity-uri-list :output-stream ostream)))
104108
105109(defun create-sample-KG ()
110+ " Create a sample knowledge graph with a predefined set of entities."
106111 (kgsampler :sample
107112 ' (" <http://dbpedia.org/resource/Bill_Gates>" " <http://dbpedia.org/resource/Steve_Jobs>"
108113 " <http://dbpedia.org/resource/Microsoft>" " <http://dbpedia.org/resource/Melinda_Gates>"
You can’t perform that action at this time.
0 commit comments