Skip to content

Commit a775b44

Browse files
committed
-
1 parent daa7393 commit a775b44

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/kgsampler/kgsampler.lisp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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
@@ -13,6 +14,7 @@
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
@@ -79,6 +81,7 @@
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)
@@ -98,11 +101,13 @@
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>"

0 commit comments

Comments
 (0)