Skip to content

Instantly share code, notes, and snippets.

View danbri's full-sized avatar

Dan Brickley danbri

View GitHub Profile
OK, ... imagine this table is filled out, and we have some match for a lot of the schema.org classes.
For each type we can go to http://dbpedia.org/sparql and do:
select ?x where { ?x a <http://dbpedia.org/resource/Non-governmental_organization> . }
...and get instances back. Well this query isn't working but something like it should. We can get json too...
Corporation http://dbpedia.org/resource/Corporation
@prefix so: <http://schema.org/> .
<http://schema.org/> <http://purl.org/dc/terms/title> "full_md unescaped" ;
<http://www.w3.org/1999/xhtml/microdata#item> so:AboutPage, so:AccountingService, so:AdministrativeArea, so:AdultEntertainment, so:AggregateOffer, so:AggregateRating, so:Airport, so:AmusementPark, so:AnimalShelter, so:ApartmentComplex, so:Aquarium, so:ArtGallery, so:Article, so:Attorney, so:AudioObject, so:AutoBodyShop, so:AutoDealer, so:AutoPartsStore, so:AutoRental, so:AutoRepair, so:AutoWash, so:AutomatedTeller, so:AutomotiveBusiness, so:Bakery, so:BankOrCreditUnion, so:BarOrPub, so:Beach, so:BeautySalon, so:BedAndBreakfast, so:BikeStore, so:Blog, so:BlogPosting, so:BodyOfWater, so:Book, so:BookFormatType, so:BookStore, so:Boolean, so:BowlingAlley, so:Brewery, so:BuddhistTemple, so:BusStation, so:BusStop, so:BusinessEvent, so:CafeOrCoffeeShop, so:Campground, so:Canal, so:Casino, so:CatholicChurch, so:Cemetery, so:CheckoutPage, so:ChildCare, so:ChildrensEvent, so:Church, so:City, so:CityHall, so:
<html>
<head><title>a page about Noah</title></head>
<body profile="http://zoo.foaf.tv">
<div typeof="Person">
This is a sentence about a person called <span property="name">Noah</span>
who <span rel="creator">wrote a book called <span property="title">Noah's Story.</span>
</span>
</div>
<div xmlns:zoo="http://zoo.foaf.tv/">
<div typeof="zoo:Person">
This is a sentence about a person called <span property="zoo:name">Noah</span>
who <span rel="zoo:creator">wrote a book called <span property="zoo:title">Noah's Story.</span>
</span>
</div>
</div>
<div xmlns:zoo="http://zoo.foaf.tv/" typeof="zoo:Person">
This is a sentence about a person called
<span property="ex:name">Noah</span> who
<span rel="zoo:made">wrote
<span typeof="zoo:Book">a book called
<span property="zoo:title">Noah's Story.</span>
</span>
</span>
</div>
<html>
<head><title>Test Snippet</title></head>
<body profile="http://zoo.foaf.tv">
<div typeof="Person">
This is a sentence about a person called
<span property="name">Noah</span> who
<span rel="made">wrote
<span typeof="Book">a book called
<span property="title">Noah's Story.</span>
</span>
@danbri
danbri / uuid_wrapper
Created June 12, 2011 09:18
Redland rapper wrapper for UUID bnodes
#!/usr/bin/perl
use Data::UUID;
use IPC::Open3;
use strict;
# A UUID wrapper for Redland's rapper RDF parser.
# Dan Brickley <[email protected]>
#
# Expands genid bnode labels to be prefixed with a UUID, allowing output
TellyClub:rdflib-microdata danbri$ cat foo.py
#!/usr/bin/env python
import rdflib
import rdflib_microdata
g = rdflib.Graph()
g.parse("https://raw.github.com/edsu/microdata/master/test-data/example.html", format="microdata")
print g.serialize(format="nt")
TellyClub:rdflib-microdata danbri$ ./foo.py
#================================================================
# Ready to make.
#================================================================
Compiling Kyoto Cabinet...
g++ -c -I. -I/Users/danbri/working/graphlab/graphlabapi/deps/include -I/usr/local/include -DNDEBUG -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D__EXTENSIONS__ -D_MYZLIB -D_MYGCCATOMIC -D_KC_PREFIX="\"/Users/danbri/working/graphlab/graphlabapi/deps\"" -D_KC_INCLUDEDIR="\"/Users/danbri/working/graphlab/graphlabapi/deps/include\"" -D_KC_LIBDIR="\"/Users/danbri/working/graphlab/graphlabapi/deps/lib\"" -D_KC_BINDIR="\"/Users/danbri/working/graphlab/graphlabapi/deps/bin\"" -D_KC_LIBEXECDIR="\"/Users/danbri/working/graphlab/graphlabapi/deps/libexec\"" -D_KC_APPINC="\"-I/Users/danbri/working/graphlab/graphlabapi/deps/include\"" -D_KC_APPLIBS="\"-L/Users/danbri/working/graphlab/graphlabapi/deps/lib -lkyotocabinet -lz -lstdc++ -lpthread -lm -lc \"" -m64 -g -O2 -Wall -fPIC -fsigned-char -g0 -O2 -Os kcutil.cc
g++ -c -I. -I/Users/danbri/wor
public static void user_recommender_5(DataModel model) {
try {
final int neighbours = 3;
RandomUtils.useTestSeed();
RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
RecommenderBuilder builder = new RecommenderBuilder() {
@Override
public Recommender buildRecommender(DataModel model) throws TasteException {
// TanimotoCoefficientSimilarity ignores pref values