forked from mark-watson/java_practical_semantic_web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lots of code cleanup, and new test code snippets for CLjure, Scala, a…
…nd JRuby
- Loading branch information
1 parent
94fa7ee
commit 96a3a62
Showing
8 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import com.knowledgebooks.rdf.SparqlClient | ||
|
||
/** | ||
* Copyright Mark Watson 2008-2010. All Rights Reserved. | ||
* License: AGPL version 3 (http://www.gnu.org/licenses/agpl-3.0.txt) | ||
* Alternative commercial license used under special arrangement (contact markw <at> markwatson <dot> com): | ||
* http://markwatson.com/commerciallicense.txt | ||
*/ | ||
|
||
|
||
object TestScalaSparqlClient { | ||
def main(args: Array[String]) { | ||
val sparql = | ||
"""PREFIX foaf: <http://xmlns.com/foaf/0.1/> | ||
PREFIX dbpedia2: <http://dbpedia.org/property/> | ||
PREFIX dbpedia: <http://dbpedia.org/> | ||
SELECT ?name ?person WHERE { | ||
?person dbpedia2:birthPlace <http://dbpedia.org/resource/California> . | ||
?person foaf:name ?name . | ||
} | ||
LIMIT 10 | ||
""" | ||
val results = new SparqlClient("http://dbpedia.org/sparql", sparql) | ||
println(results.variableBindings) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import com.knowledgebooks.info_spiders.WebSpider | ||
|
||
/** | ||
* Copyright Mark Watson 2008-2010. All Rights Reserved. | ||
* License: AGPL version 3 (http://www.gnu.org/licenses/agpl-3.0.txt) | ||
* Alternative commercial license used under special arrangement (contact markw <at> markwatson <dot> com): | ||
* http://markwatson.com/commerciallicense.txt | ||
*/ | ||
|
||
|
||
object TestScalaWebSpider { | ||
def main(args: Array[String]) { | ||
val results = new WebSpider("http://www.knowledgebooks.com", 2) | ||
println(results.url_content_lists.get(0)) | ||
println(results.url_content_lists.get(1)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(import '(com.knowledgebooks.info_spiders WebSpider)) | ||
|
||
(defn get-pages [starting-url max-pages] | ||
(let [ws (new WebSpider starting-url max-pages)] | ||
(map seq (.url_content_lists ws)))) | ||
|
||
(println (get-pages "http://www.knowledgebooks.com" 2)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'java' | ||
(Dir.glob("lib/*.jar")).each do |fname| | ||
require fname | ||
end | ||
require "knowledgebooks.jar" | ||
require 'pp' | ||
|
||
results = com.knowledgebooks.info_spiders.WebSpider.new("http://www.knowledgebooks.com", 2) | ||
pp results.url_content_lists |