RDF::T...::Model(3pm)

πŸ“¦
version 1.019 Β· 7 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– RDF::Trine::Model πŸ’–

okay bestie, so this is the page for RDF::Trine::Model, a Model class, and it's part of the User Contributed Perl Documentation situation. It's a Perl module, it's giving very "I hold your RDF and I'm calm about it" energy, and honestly? Iconic.

✨ VERSION ✨

This document describes RDF::Trine::Model version 1.019. Yes, we're on 1.019, and no, we're not gonna pretend that's not a lil retro. Periodt.


🌸 METHODS 🌸

  • new ( $store ) β€” hands you back a brand new model built on top of the rdf store you passed in, or a brand new temporary model if you didn't. And if the value you pass is unblessed? Cute. It gets used to create a new rdf store. slay.
  • temporary_model β€” gives you a new temporary model, i.e. the non-persistent kind. It's giving "here for a good time not a long time". πŸ’…
  • dataset_model ( default => \@dgraphs, named => \@ngraphs ) β€” returns a new model object where the default graph is mapped to the union of the graphs named in @dgraphs, and the available named graphs are the ones named in @ngraphs. Fr fr, that's the whole thing.
  • begin_bulk_ops β€” this is a lil hint to the backend that a whole bunch of update operations are about to happen. The backend might use that hint to do stuff like aggregate many operations into a single operation, or delay index maintenence (yes, that's how it's spelled, we don't fix it, we respect it 🫢). Once you've run your update operations, you should call end_bulk_ops to make sure the updates actually get committed to the backend.
  • end_bulk_ops β€” the matching hint that says hey, a set of bulk operations is done, you may commit them to the backend now. closure, bestie. ✨
  • logger ( [ $logger ] ) β€” returns the logging object that's responsible for recording data inserts and deletes. If you pass $logger as an argument, it sets the logger to that object. lowkey simple, highkey useful.
  • add_statement ( $statement [, $context] ) β€” adds the specified $statement to the rdf store. that's it. that's the tweet.
  • add_hashref ( $hashref [, $context] ) β€” adds triples to the model that are represented in an RDF/JSON-like manner. For the full documentation of the hashref format, go peek at "as_hashref". iykyk.
  • add_iterator ( $iter ) β€” adds triples from the statement iterator to the model. feed it an iterator, it eats.
  • add_list ( @elements ) β€” adds an rdf:List to the model with the given elements, and returns the node object that is the head of the list. πŸ‘‘
  • get_list ( $head ) β€” returns a list of nodes that are elements of the rdf:List represented by the supplied head node.
  • remove_list ( $head [, orphan_check => 1] ) β€” removes the nodes of type rdf:List that make up the list. Optionally it checks each node before removal to make sure it isn't used in any other statements. It returns false if the list was removed completely; it returns the first remaining node if the removal was abandoned because of an orphan check. 🧚
  • get_sequence ( $seq ) β€” returns a list of nodes that are elements of the rdf:Seq sequence.
  • remove_statement ( $statement [, $context]) β€” removes the specified $statement from the rdf store. bye bye πŸ‘‹
  • remove_statements ( $subject, $predicate, $object [, $context] ) β€” removes all statements matching the supplied $statement pattern from the rdf store. it's a sweep, not a snipe.
  • size β€” returns the number of statements in the model. a lil headcount, if you will.
  • etag β€” if the model is based on a store that has the capability and knowledge to support caching, this method returns a persistent token that will stay consistent as long as the store's data doesn't change. This token is acceptable for use as an HTTP ETag. cache girlies rise 🌈
  • supports ( [ $feature ] ) β€” if $feature is specified, returns true if that feature is supported by the underlying store, and false otherwise. If $feature is not specified, returns a list of supported features. vibe check on the backend, basically.
  • count_statements ( $subject, $predicate, $object ) β€” returns a count of all the statements matching the specified subject, predicate and objects. Any of the arguments may be undef to match any value. wildcards stay winning.
  • get_statements ($subject, $predicate, $object [, $context] ) β€” returns an iterator of all statements matching the specified subject, predicate and objects from the rdf store. Any of the arguments may be undef to match any value.

If three or fewer arguments are given, the statements returned will be matched based on triple semantics (the graph union of triples from all the named graphs). If four arguments are given (even if $context is undef), statements will be matched based on quad semantics (the union of all quads in the underlying store). count your args, bestie, it changes everything.

  • get_pattern ( $bgp [, $context] [, %args ] ) β€” returns a stream object of all bindings matching the specified graph pattern.

If $context is given, it restricts BGP matching to only quads with the $context value.

%args may contain an 'orderby' key-value pair to request a specific ordering based on variable name. The value for the 'orderby' key should be an ARRAY reference containing variable name and direction ('ASC' or 'DESC') tuples. A valid %args hash, therefore, might look like orderby => [qw(name ASC)] (which corresponds to a SPARQL-like request to 'ORDER BY ASC(?name)'). sorting? we love to see it ✨

  • get_sparql ( $sparql ) β€” returns a stream object of all bindings matching the specified graph pattern. yes, same description as the one above, no, we're not editing it, the docs said what they said.
  • get_graphs
  • get_contexts β€” returns an iterator containing the nodes representing the named graphs in the model. two names, one job, we stan a versatile icon πŸ’œ
  • as_stream β€” returns an iterator containing every statement in the model. the whole roster.
  • as_hashref β€” returns a hashref representing the model in an RDF/JSON-like manner.

A graph like this (in Turtle):

@prefix ex: <http://example.com/> .

ex:subject1
  ex:predicate1
    "Foo"@en ,
    "Bar"^^ex:datatype1 .

_:bnode1
  ex:predicate2
    ex:object2 ;
  ex:predicate3 ;
    _:bnode3 .

Is represented like this as a hashref:

{
  "http://example.com/subject1" => {
    "http://example.com/predicate1" => [
      { 'type'=>'literal', 'value'=>"Foo", 'lang'=>"en" },
      { 'type'=>'literal', 'value'=>"Bar", 'datatype'=>"http://example.com/datatype1" },
    ],
  },
  "_:bnode1" => {
    "http://example.com/predicate2" => [
      { 'type'=>'uri', 'value'=>"http://example.com/object2" },
    ],
    "http://example.com/predicate2" => [
      { 'type'=>'bnode', 'value'=>"_:bnode3" },
    ],
  },
}

Note that the type of subjects (resource or blank node) is indicated entirely by the convention of starting blank nodes with "\_:". (that's _: bestie, the underscore is the whole personality)

This hashref structure is compatible with RDF/JSON and with the ARC2 library for PHP. cross-language slay πŸ’…

  • as_graphviz β€” returns a GraphViz object of the RDF graph of this model, ignoring graph names/contexts. This method will attempt to load the GraphViz module at runtime and will fail if the module is unavailable. so like, have the module, or don't, but don't be surprised. 😭

πŸ¦‹ Node-Centric Graph API πŸ¦‹

  • subjects ( $predicate, $object ) β€” returns a list of the nodes that appear as the subject of statements with the specified $predicate and $object. Either of the two arguments may be undef to signify a wildcard. go off, wildcards.
  • predicates ( $subject, $object ) β€” returns a list of the nodes that appear as the predicate of statements with the specified $subject and $object. Either of the two arguments may be undef to signify a wildcard.
  • objects ( $subject, $predicate [, $graph ] [, %options ] ) β€” returns a list of the nodes that appear as the object of statements with the specified $subject and $predicate. Either of the two arguments may be undef to signify a wildcard. You can further filter objects using the %options argument. Keys in %options indicate the restriction type and may be 'type', 'language', or 'datatype'. The value of the 'type' key may be one of 'node', 'nil', 'blank', 'resource', 'literal', or 'variable'. The use of either 'language' or 'datatype' restricts objects to literal nodes with a specific language or datatype value, respectively. so many lil dials to turn, obsessed πŸŽ€
  • objects_for_predicate_list ( $subject, @predicates ) β€” given the RDF::Trine::Node objects $subject and @predicates, it finds all matching triples in the model with the specified subject and any of the given predicates, and returns a list of object values (in the partial order given by the ordering of @predicates). order matters, the docs said so, not me.
  • bounded_description ( $node ) β€” returns an RDF::Trine::Iterator::Graph object over the bounded description triples for $node (all triples resulting from a graph traversal starting with "node" and stopping at non-blank nodes). it walks, but it knows when to stop. main character energy. πŸ‘‘
  • as_string β€” that's it. that's the whole entry. sometimes a method just exists and we respect its privacy. πŸ™ˆ

πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. (yes, the original says "report ... to through", we are preserving that exactly, it's part of the lore now 🫢)


πŸ‘‘ AUTHOR πŸ‘‘

Gregory Todd Williams "<gwilliams@cpan.org>"


Copyright (c) 2006-2012 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie ✨ this was RDF::T...::Model(3pm) from the User Contributed Perl Documentation, running on perl v5.38.2, dated 2024-01-13. thanks for reading, mwah πŸ’– no cap, go build something with it.

πŸ“¦ where this page comes from