RDF.Graph.map
You're seeing just the function
map
, go back to RDF.Graph module for more information.
Specs
map(t(), RDF.Statement.term_mapping()) :: map()
Returns a nested map of a RDF.Graph
where each element from its triples 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
or :object
,
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> RDF.Graph.new([
...> {~I<http://example.com/S1>, ~I<http://example.com/p>, ~L"Foo"},
...> {~I<http://example.com/S2>, ~I<http://example.com/p>, RDF.XSD.integer(42)}
...> ])
...> |> RDF.Graph.map(fn
...> {:predicate, predicate} ->
...> predicate
...> |> to_string()
...> |> String.split("/")
...> |> List.last()
...> |> String.to_atom()
...> {_, term} ->
...> RDF.Term.value(term)
...> end)
%{
"http://example.com/S1" => %{p: ["Foo"]},
"http://example.com/S2" => %{p: [42]}
}