My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SimpleGraph  
Represents an RDF graph and provides some simple functions for traversing and manipulating it.
Autogenerated
Updated Jan 13, 2010 by innovat...@gmail.com

note: this page is automatically generated from embedded documentation in the PHP source.

Overview

Constructors

Methods

Fields

Constructor Detail

SimpleGraph

public SimpleGraph(mixed graph)

Method Detail

add_graph

public void add_graph(mixed g)

Add the triples in the supplied graph to the current graph

Param:
SimpleGraph g the graph to read

add_json

public void add_json(mixed json)

Add the triples parsed from the supplied JSON to the graph

See:
http://n2.talis.com/wiki/RDF_JSON_Specification
Param:
string json the JSON to parse

add_labelling_property

public void add_labelling_property(mixed p)

add_literal_triple

public void add_literal_triple(mixed s, mixed p, mixed o, mixed lang, mixed dt)

Adds a triple with a literal object to the graph

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate of the triple as a URI
string o the object of the triple as a string
string lang the language code of the triple's object (optional)
string dt the datatype URI of the triple's object (optional)
Return:
boolean true if the triple was new, false if it already existed in the graph

add_rdf

public void add_rdf(mixed rdf, mixed base)

Add the triples parsed from the supplied RDF to the graph - let ARC guess the input

Param:
string rdf the RDF to parse
string base the base URI against which relative URIs in the RDF document will be resolved
Author:
Keith Alexander

add_rdfxml

public void add_rdfxml(mixed rdfxml, mixed base)

Add the triples parsed from the supplied RDF/XML to the graph

Param:
string rdfxml the RDF/XML to parse
string base the base URI against which relative URIs in the RDF/XML document will be resolved

add_resource_triple

public void add_resource_triple(mixed s, mixed p, mixed o)

Adds a triple with a resource object to the graph

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate URI of the triple
string o the object of the triple, either a URI or a blank node in the format :name
Return:
boolean true if the triple was new, false if it already existed in the graph

add_turtle

public void add_turtle(mixed turtle, mixed base)

Add the triples parsed from the supplied Turtle to the graph

See:
http://www.dajobe.org/2004/01/turtle
Param:
string turtle the Turtle to parse
string base the base URI against which relative URIs in the Turtle document will be resolved

diff

public void diff()

diff returns a simpleIndex consisting of all the statements in array1 that weren't found in any of the subsequent arrays

Param:
array1, array2, [array3, ...]
Return:
array
Author:
Keith

from_json

public void from_json(mixed json)

Replace the triples in the graph with those parsed from the supplied JSON

See:
http://n2.talis.com/wiki/RDF_JSON_Specification
Param:
string json the JSON to parse

from_rdfxml

public void from_rdfxml(mixed rdfxml, mixed base)

Replace the triples in the graph with those parsed from the supplied RDF/XML

Param:
string rdfxml the RDF/XML to parse
string base the base URI against which relative URIs in the RDF/XML document will be resolved

from_turtle

public void from_turtle(mixed turtle, mixed base)

Replace the triples in the graph with those parsed from the supplied Turtle

See:
http://www.dajobe.org/2004/01/turtle
Param:
string turtle the Turtle to parse
string base the base URI against which relative URIs in the Turtle document will be resolved

get_description

public void get_description(mixed resource_uri)

get_first_literal

public void get_first_literal(mixed s, mixed p, mixed default, mixed preferred_language)

Fetch the first literal value for a given subject and predicate. If there are multiple possible values then one is selected at random.

Param:
string s the subject to search for
string p the predicate to search for, or an array of predicates
string default a default value to use if no literal values are found
Return:
string the first literal value found or the supplied default if no values were found

get_first_resource

public void get_first_resource(mixed s, mixed p, mixed default)

Fetch the first resource value for a given subject and predicate. If there are multiple possible values then one is selected at random.

Param:
string s the subject to search for
string p the predicate to search for
string default a default value to use if no literal values are found
Return:
string the first resource value found or the supplied default if no values were found

get_index

public void get_index()

Get a copy of the graph's triple index

See:
http://n2.talis.com/wiki/RDF_PHP_Specification

get_label

public void get_label(mixed resource_uri, mixed capitalize, mixed use_qnames)

get_literal_triple_values

public void get_literal_triple_values(mixed s, mixed p)

Fetch the literal values for a given subject and predicate.

Param:
string s the subject to search for
string p the predicate to search for
Return:
array list of literals that are the objects of triples with the supplied subject and predicate

get_prefix

public void get_prefix(mixed ns)

get_resource_triple_values

public void get_resource_triple_values(mixed s, mixed p)

Fetch the resource values for a given subject and predicate.

Param:
string s the subject to search for
string p the predicate to search for
Return:
array list of URIs and blank nodes that are the objects of triples with the supplied subject and predicate

get_subject_properties

public void get_subject_properties(mixed s, mixed distinct)

Fetch the properties of a given subject and predicate.

Param:
string s the subject to search for
boolean distinct if true then duplicate properties are included only once (optional, default is true)
Return:
array list of property URIs

get_subject_property_values

public void get_subject_property_values(mixed s, mixed p)

Fetch the values for a given subject and predicate.

Param:
string s the subject to search for
string p the predicate to search for
Return:
array list of values of triples with the supplied subject and predicate

get_subject_subgraph

public void get_subject_subgraph(mixed s)

Fetch a subgraph where all triples have given subject

Param:
string s the subject to search for
Return:
SimpleGraph triples with the supplied subject

get_subjects

public void get_subjects()

Fetch an array of all the subjects

Return:
array

get_subjects_of_type

public void get_subjects_of_type(mixed t)

Fetch an array of all the subject that have and rdf type that matches that given

Param:
$t the type to match
Return:
array

get_subjects_where_literal

public void get_subjects_where_literal(mixed p, mixed o)

Fetch an array of all the subjects where the predicate and object match a ?s $p $o triple in the graph and the object is a literal value

Param:
$p the predicate to match
$o the resource object to match
Return:
array

get_subjects_where_resource

public void get_subjects_where_resource(mixed p, mixed o)

Fetch an array of all the subjects where the predicate and object match a ?s $p $o triple in the graph and the object is a resource

Param:
$p the predicate to match
$o the resource object to match
Return:
array

get_triples

public void get_triples()

Deprecated:
this is deprecated

has_literal_triple

public void has_literal_triple(mixed s, mixed p, mixed o, mixed lang, mixed dt)

Tests whether the graph contains the given triple

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate URI of the triple
string o the object of the triple as a literal value
Return:
boolean true if the triple exists in the graph, false otherwise

has_resource_triple

public void has_resource_triple(mixed s, mixed p, mixed o)

Tests whether the graph contains the given triple

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate URI of the triple
string o the object of the triple, either a URI or a blank node in the format :name
Return:
boolean true if the triple exists in the graph, false otherwise

has_triples_about

public void has_triples_about(mixed s)

Tests whether the graph contains a triple with the given subject

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
Return:
boolean true if the graph contains any triples with the specified subject, false otherwise

is_empty

public void is_empty()

Tests whether the graph contains any triples

Return:
boolean true if the graph contains no triples, false otherwise

make_resource_array

public void make_resource_array(mixed resource)

Constructs an array containing the type of the resource and its value

Param:
string resource a URI or blank node identifier (prefixed with : e.g. :name)
Return:
array an associative array with two keys: 'type' and 'value'. Type is either bnode or uri

merge

public void merge()

merge merges all rdf/json-style arrays passed as parameters

Param:
array1, array2, [array3, ...]
Return:
array
Author:
Keith

qname_to_uri

public void qname_to_uri(mixed qname)

Convert a QName to a URI using registered namespace prefixes

Param:
string qname the QName to convert
Return:
string the URI corresponding to the QName if a suitable prefix exists, null otherwise

reify

public void reify(mixed resources, mixed nodeID_prefix)

remove_all_triples

public void remove_all_triples()

Clears all triples out of the graph

remove_literal_triple

public void remove_literal_triple(mixed s, mixed p, mixed o)

remove_property_values

public void remove_property_values(mixed s, mixed p)

Removes all triples with the given subject and predicate

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate URI of the triple

remove_resource_triple

public void remove_resource_triple(mixed s, mixed p, mixed o)

Remove a triple with a resource object from the graph

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate URI of the triple
string o the object of the triple, either a URI or a blank node in the format :name

remove_triples_about

public void remove_triples_about(mixed s)

Remove all triples having the supplied subject

Param:
string s the subject of the triple, either a URI or a blank node in the format :name

replace_resource

public void replace_resource(mixed look_for, mixed replace_with)

set_namespace_mapping

public void set_namespace_mapping(mixed prefix, mixed uri)

Map a portion of a URI to a short prefix for use when serialising the graph

Param:
string prefix the namespace prefix to associate with the URI
string uri the URI to associate with the prefix

subject_has_property

public void subject_has_property(mixed s, mixed p)

Tests whether the graph contains a triple with the given subject and predicate

Param:
string s the subject of the triple, either a URI or a blank node in the format :name
string p the predicate URI of the triple
Return:
boolean true if a matching triple exists in the graph, false otherwise

to_html

public void to_html(mixed s)

Serialise the graph to HTML

Return:
string a HTML version of the graph

to_json

public void to_json()

Serialise the graph to JSON

See:
http://n2.talis.com/wiki/RDF_JSON_Specification
Return:
string the JSON version of the graph

to_ntriples

public void to_ntriples()

Serialise the graph to N-Triples

See:
http://www.w3.org/TR/rdf-testcases/#ntriples
Return:
string the N-Triples version of the graph

to_rdfxml

public void to_rdfxml()

Serialise the graph to RDF/XML

Return:
string the RDF/XML version of the graph

to_turtle

public void to_turtle()

Serialise the graph to Turtle

See:
http://www.dajobe.org/2004/01/turtle
Return:
string the Turtle version of the graph

update_prefix_mappings

public void update_prefix_mappings()

uri_to_qname

public void uri_to_qname(mixed uri)

Convert a URI to a QName using registered namespace prefixes

Param:
string uri the URI to convert
Return:
string the QName corresponding to the URI if a suitable prefix exists, null otherwise

Field Detail

Generated by PHPDoctor 2RC2


Sign in to add a comment
Powered by Google Project Hosting