Download the PHP package sweetrdf/term-templates without Composer
On this page you can find all versions of the php package sweetrdf/term-templates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sweetrdf/term-templates
More information about sweetrdf/term-templates
Files in sweetrdf/term-templates
Package term-templates
Short Description A set of Term templates for the rdfInterface
License MIT
Homepage https://github.com/sweetrdf/termTemplates
Informations about the package term-templates
termTemplates
Provides:
- A set of term templates allowing to match desired RDF named nodes, literals and quads.
To be used mainly as
rdfInterface\Datasetmethods$filterparameter. - A convenient methods for extracting single terms and/or their values from
rdfInterface\Dataset.
Quad-matching classes
termTemplates\QuadTemplatetermTemplates\PredicateTemplate- atermTemplates\QuadTemplatevariant skipping the subject (convenient for filtering therdfInterface\DatasetNode)
Term-matching classes
(all classes in the termTemplate namespace)
| Match by | Supported matchModes | Match both named nodes and literals | Match only named nodes | Match only literals | Remarks |
|---|---|---|---|---|---|
| term's string value | ==, !=, <, >, <=, >=, starts, ends, contains, regex, any | ValueTemplate |
NamedNodeTemplate |
LiteralTemplate [1] |
|
| term's numeric value | ==, !=, <, >, <=, >=, any | NA | NA | NumericTemplate |
[2] |
[1] Supports filtering also by literal's lang (using == and any operators) and datatype (only using == operator).
[2] Supports both strict and non-strict mode. In the strict mode comparison with literals with non-numeric datatype returns false no matter their value.
Other classes
termTemplates\NotTemplate- negates the result of theequals()operation on a givenrdfInterface\TermCompareobject.termTemplates\AnyOfTemplate- matches terms being equal to any of given list ofrdfInterface\TermCompareobjects. as singlerdfInterface\Term, single value, array ofrdfInterface\Termor array of values.
Installation
- Obtain the Composer
- Run
composer require sweetrdf/term-templates
Automatically generated documentation
https://sweetrdf.github.io/termTemplates/namespaces/termtemplates.html
It's very incomplete but better than nothing.\ RdfInterface documentation is included which explains the most important design decisions.
Usage examples
Remarks:
- The comparison with term templates isn't symmetric!
You should always call
$termTemplate->equals($termToBeCompared)and never$termToBeCompared->equals($termTemplate). The latter one will always return false. - See also here for examples of using term templates in conjuction with an RDF datasets.
- To run this examples an RDF terms factory is needed. Here we will use the one from the quickRdf library.
You can install it with
composer require sweetrdf/quick-rdf. - In the examples below the comparison operators are specified by stating corresponding
termTemplates\ValueTemplateclass constants but you can also use corresponding constants values as listed in the table above (e.g.>=orregex). - If you are tired with the long code, define class aliases, e.g.
use termTemplates\QuadTemplate as QT;,use termTemplates\ValueTemplate as VT;, etc.