new tripleconfig()
Holds configuration for object to triple mappings, and ontology information. Has methods for easily building an ontology for use with MLJS widgets and semantic contexts.
Methods
-
addErrorListener(fl)
-
Adds an error listener to this widget
Parameters:
Name Type Description fl
function The error listener to add
-
addFoaf()
-
Adds FOAF Person, Organisation, and common predicates support
-
addFoafPlaces()
-
Adds links from FOAF:Person and Organisation objects to geonames Place objects. TODO update this for IRI types instead of common names
-
addMappings(mapname, entityJson, namedPredicateArray, validTriplesArray)
-
Adds a new set of semantic objects to this configuration
Parameters:
Name Type Description mapname
string The unique name in this configuration for this entity
entityJson
json The Entity JSON
namedPredicateArray
Array An array with names (not integers) as position markers, with JSON predicate information
validTriplesArray
Array Any new triples associated with just this entity class (E.g. valid relationships between People) as JSON valid triples
-
addMarkLogic()
-
Adds MarkLogic document ontology support. This is an early formed idea, not a standard.
http://adamfowleruk.github.io/mljs/apidocs/core/tutorial-901-ontology.html
-
addMovies()
-
Adds the MLJS sample Movies ontology support, and relationships to FOAF:Person subject (likes predicate)
-
addOpenCalais()
-
Adds common OpenCalais RDF types and their common names to the triple config. (Organization, Person, City, Country, Continent, Province or State, Region, Facility)
-
addPlaces()
-
Adds Geonames Place subject type support. Includes some custom predicates to represent common relationships.
-
addTest()
-
Adds other ontologies used for testing E.g. in the mldbwebtest sample project. Defines a Foodstuff rdf type with foodname, linked to FOAF Person subjects (via likes predicate)
-
addValidTriples(validTriplesArray)
-
Adds new valid triples.
Parameters:
Name Type Description validTriplesArray
Array Any new triples associated with multiple entity classes (E.g. relationships between people and places) as JSON valid triples
-
getEntityFromIRI(iri) → {JSON}
-
Fetch entity info for top level entities (not properties of entities)
Parameters:
Name Type Description iri
string The IRI of the rdf entity type to fetch
Returns:
entityInfo - The Internal MLJS JSON configuration of the specified entity
- Type
- JSON
-
getEntityFromName(name) → {JSON}
-
Fetches entity info based upon a short name, internal to MLJS triple config objects.
Parameters:
Name Type Description name
string The short internal name of the rdf entity type to fetch
Returns:
entityInfo - The Internal MLJS JSON configuration of the specified entity
- Type
- JSON
-
getEntityFromShortIRI(shortIri) → {JSON}
-
Fetches entity info based upon a shortened IRI.
Parameters:
Name Type Description shortIri
string The short IRI of the rdf entity type to fetch
Returns:
entityInfo - The Internal MLJS JSON configuration of the specified entity
- Type
- JSON
-
getEntityProperty(entity, iri)
-
Convenience method to loop through the JSON entityInfo object specified and rethrn the predicate information for the specified predicate IRI
TODO validate this works as expected since change to create an ontologyBuilder set of functions. NB Remove if not used by any other code.
Parameters:
Name Type Description entity
JSON The MLJS entityInfo object
iri
string The full IRI of the predicate whose info should be returned
-
getNameProperty(entity) → {JSON}
-
Returns the IRI of the predicate which represents the specified entity's commonNamePredicate
Parameters:
Name Type Description entity
string The IRI of the RDF type for the entity
Returns:
property - The property JSON or null for the commonNamePredicate
- Type
- JSON
-
getPredicateFromIRI(iri) → {JSON}
-
Returns a predicate info JSON object for the full rdf predicate IRI specified.
Parameters:
Name Type Description iri
string The IRI of the rdf predicate to fetch
Returns:
predicateInfo - The Internal MLJS JSON configuration of the specified predicate
- Type
- JSON
-
getPredicateFromName(name) → {JSON}
-
Returns a predicate info JSON object for the full rdf predicate IRI specified.
Parameters:
Name Type Description name
string The internal MLJS triple config name of the rdf predicate to fetch
Returns:
predicateInfo - The Internal MLJS JSON configuration of the specified predicate
- Type
- JSON
-
getPredicateFromShortIRI(shortIri) → {JSON}
-
Returns a predicate info JSON object for the full rdf predicate IRI specified.
Parameters:
Name Type Description shortIri
string The short IRI of the rdf predicate to fetch
Returns:
predicateInfo - The Internal MLJS JSON configuration of the specified predicate
- Type
- JSON
-
getValidPredicates(from, to) → {Array}
-
Returns the valid predicates in the configured ontologies between the two subject RDF types shown (they could be the same values). This function is useful when determining the possible object classes a Subject can be linked to. It does not list intrinsic valued predicates.
Parameters:
Name Type Description from
string IRI of the RDF type on which the predicate exists
to
string IRI of the RDF type to which the predicate points (The RDF type of the Object)
Returns:
predicateArray - The full IRIs of the predicates that are valid between the two RDF types given
- Type
- Array
-
include(rdftype)
-
Includes the specified MLJS RDF Type JavaScript object as an RDF Entity type in this Triple Config object.
Parameters:
Name Type Description rdftype
JSON The RDFType description object to include in this configuration
-
loadOntologyFromSparqlResults(results)
-
Loads the ontology (mappings) from a SPARQL result set. Called by semantic context on initialisation.
Parameters:
Name Type Description results
mljs.SparqlResults The SPARQL response as a JSON document.
-
rdftype(rdfTypeIri, opt_commonNamePredicate)
-
Creates a chainable RDF type JavaScript object. Provides easy creation of a semantic config.
Parameters:
Name Type Description rdfTypeIri
string The IRI of this RDF Type
opt_commonNamePredicate
string The optional predicate to use as the 'common name' for display. Defaults to rdfs:label
-
removeErrorListener(fl)
-
Removes an error listener
Parameters:
Name Type Description fl
function The error listener to remove