If Docker is installed on your machine, run the following:
$ alias g2g='docker run --rm -v $PWD:/work g2glab/g2g:0.3.8 g2g'
$ g2g --version
0.3.8
Otherwise, install Git and Node, then run the following:
$ git clone -b v0.3.8 https://github.com/g2glab/g2g.git
$ cd g2g
$ sh install.sh
$ g2g --version
0.3.8
If you use local file mode without Docker, install Apache Jena ARQ and make sure that arq
command can be executed.
$ cd ~
$ wget http://ftp.jaist.ac.jp/pub/apache/jena/binaries/apache-jena-3.17.0.zip
$ unzip apache-jena-3.17.0.zip
$ export PATH=$PATH:~/apache-jena-3.17.0/bin
If you want to check whether your installation works correct, run the following:
(With Docker)
$ docker run --rm g2glab/g2g:0.3.8 bash -c "cd /opt/g2g && sh test.sh"
(Without Docker)
$ sh test.sh
Usage:
$ g2g [options] <g2gml_file> <data_source>
Options:
-V, --version shows the version number
-f, --format [format] format of results <rq|pg|pgx|neo|dot|aws|all (default: pg)>
-o, --output_dir [prefix] output directory (default: output/<input_prefix>)
-h, --help output usage information
Download example g2g file:
$ wget https://raw.githubusercontent.com/g2glab/g2g/master/examples/musician/musician.g2g
musician.g2g
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
...
# Node mappings
(mus:musician {vis_label:nam, born:dat, hometown:twn, page_length:len})
?mus rdf:type foaf:Person, dbpedia-owl:MusicalArtist .
...
# Edge mappings
(mus1:musician)-[:same_group {label:nam, hometown:twn, page_length:len}]->(mus2:musician)
?grp a schema:MusicGroup ;
...
Run (mapping against SPARQL endpoint):
$ g2g musician.g2g http://dbpedia.org/sparql
Check the output file:
$ more output/musician/musician.pg
musician.pg
"http://dbpedia.org/resource/Martin_Glover" :musician vis_label:"Martin Glover"
"http://dbpedia.org/resource/Per_Wiberg" :musician vis_label:"Per Wiberg" hometown:Stockholm
"http://dbpedia.org/resource/Tex_Perkins" :musician vis_label:"Tex Perkins"
"http://dbpedia.org/resource/Michelle_DaRosa" :musician vis_label:"Michelle DaRosa"
"http://dbpedia.org/resource/Raúl_Sánchez_(musician)" :musician vis_label:"Raúl Sánchez (musician)" hometown:"Valencia, Spain"
...
"http://dbpedia.org/resource/Jin_Tielin" -> "http://dbpedia.org/resource/Zu_Hai" :influenced
"http://dbpedia.org/resource/George_Lam" -> "http://dbpedia.org/resource/Eason_Chan" :influenced
"http://dbpedia.org/resource/Aaron_Kwok" -> "http://dbpedia.org/resource/Alien_Huang" :influenced
"http://dbpedia.org/resource/Samuel_Hui" -> "http://dbpedia.org/resource/Albert_Au" :influenced
"http://dbpedia.org/resource/George_Lam" -> "http://dbpedia.org/resource/Albert_Au" :influenced
...
"http://dbpedia.org/resource/Ville_Valo" -> "http://dbpedia.org/resource/Linde_Lindström" :same_group label:"HIM (Finnish band)" hometown:Helsinki
"http://dbpedia.org/resource/Jerry_Donahue" -> "http://dbpedia.org/resource/Sally_Barker" :same_group label:Fotheringay
"http://dbpedia.org/resource/Line_Horntveth" -> "http://dbpedia.org/resource/Øystein_Moen" :same_group label:"Jaga Jazzist" hometown:Norway
"http://dbpedia.org/resource/Adam_von_Buhler" -> "http://dbpedia.org/resource/Kasson_Crooker" :same_group label:"Splashdown (band)" hometown:"United States"
"http://dbpedia.org/resource/Jeong_Jinwoon" -> "http://dbpedia.org/resource/Lee_Chang-min_(singer)" :same_group label:"2AM (band)" hometown:"South Korea"
...
Download example turtle file:
$ wget https://raw.githubusercontent.com/g2glab/g2g/master/examples/mini-05/mini-05.ttl
mini-05.ttl
@prefix : <http://example.org/> .
:person1 a :Person .
:person2 a :Person .
[] a :Follow ;
:follower :person1 ;
:followed :person2 ;
:since 2017 .
Download example g2g file:
$ wget https://raw.githubusercontent.com/g2glab/g2g/master/examples/mini-05/mini-05.g2g
mini-05.g2g
PREFIX : <http://example.org/>
(p:person)
?p a :Person .
(p1:person)-[:follows {since:s}]->(p2:person)
?f :follower ?p1 ;
:followed ?p2 ;
:since ?s .
Run (mapping against RDF data file):
$ g2g mini-05.g2g mini-05.ttl
Check the output file:
$ more output/mini-05/mini-05.pg
mini-05.pg
"http://example.org/person1" :person
"http://example.org/person2" :person
"http://example.org/person1" -> "http://example.org/person2" :follows since:2017
- Interprets G2GML and generates SPARQL queries to retrieve data
- Issues SPARQL queries against public endpoints or given RDF data
- Obtains the query results and transforms it into PG format
- (optional) Translates PG data into specific formats for graph databases
- Use
-f pg
or no-f
option (default) - Number of output files: 1 (sample.pg)
- PG tools can transform PG into other common formats.
- Use
-f json
- Number of output files: 1 (sample.json)
- Use
-f neo
- Number of output files: 2 (sample.neo.nodes, sample.neo.edges)
- Use
-f pgx
- Number of output files: 3 (sample.pgx.nodes (opv), sample.pgx.edges (ope), sample.pgx.json (config))
- Use
-f aws
- Number of output files: 2 (sample.aws.nodes, sample.aws.edges)
- Use
-f dot
- Number of output files: 1 (sample.dot)