RDF.Dataset.map

You're seeing just the function map, go back to RDF.Dataset module for more information.

Specs

Returns a nested map of a RDF.Dataset where each element from its quads is mapped with the given function.

The function fun will receive a tuple {statement_position, rdf_term} where statement_position is one of the atoms :subject, :predicate, :object or :graph_name while rdf_term is the RDF term to be mapped. When the given function returns nil this will be interpreted as an error and will become the overhaul result of the map/2 call.

Examples

iex> [
...>   {~I<http://example.com/S>, ~I<http://example.com/p>, ~L"Foo", ~I<http://example.com/Graph>},
...>   {~I<http://example.com/S>, ~I<http://example.com/p>, RDF.XSD.integer(42), }
...> ]
...> |> RDF.Dataset.new()
...> |> RDF.Dataset.map(fn
...>      {:graph_name, graph_name} ->
...>        graph_name
...>      {:predicate, predicate} ->
...>        predicate
...>        |> to_string()
...>        |> String.split("/")
...>        |> List.last()
...>        |> String.to_atom()
...>    {_, term} ->
...>      RDF.Term.value(term)
...>    end)
%{
  ~I<http://example.com/Graph> => %{
    "http://example.com/S" => %{p: ["Foo"]}
  },
  nil => %{
    "http://example.com/S" => %{p: [42]}
  }
}