Rename RDF.Graph.without_quoted_triples/1 to without_star_statements/1
and RDF.Description.without_quoted_triples/1 to RDF.Description.without_quoted_triple_objects/1
This commit is contained in:
parent
a1bc6b7dd4
commit
601ebf54a0
5 changed files with 22 additions and 20 deletions
|
@ -811,8 +811,8 @@ defmodule RDF.Description do
|
|||
@doc """
|
||||
Removes all objects from a description which are quoted triples.
|
||||
"""
|
||||
@spec without_quoted_triples(t) :: t
|
||||
def without_quoted_triples(%__MODULE__{} = description) do
|
||||
@spec without_quoted_triple_objects(t) :: t
|
||||
def without_quoted_triple_objects(%__MODULE__{} = description) do
|
||||
%__MODULE__{
|
||||
description
|
||||
| predications:
|
||||
|
|
|
@ -652,7 +652,7 @@ defmodule RDF.Graph do
|
|||
|
||||
Note: This function excludes only triples where the subject is a quoted triple.
|
||||
If you want to exclude also triples where the object is a quoted triple,
|
||||
you'll have to use `RDF.Graph.without_quoted_triples/1`.
|
||||
you'll have to use `RDF.Graph.without_star_statements/1`.
|
||||
"""
|
||||
@spec without_annotations(t) :: t
|
||||
defdelegate without_annotations(graph), to: RDF.Star.Graph
|
||||
|
@ -662,10 +662,10 @@ defmodule RDF.Graph do
|
|||
|
||||
This function is relatively costly, since it requires a full walk-through of all triples.
|
||||
In many cases quoted triples are only used on subject position, where you can use
|
||||
`RDF.Graph.without_annotations/1`.
|
||||
the significantly faster `RDF.Graph.without_annotations/1`.
|
||||
"""
|
||||
@spec without_quoted_triples(t) :: t
|
||||
defdelegate without_quoted_triples(graph), to: RDF.Star.Graph
|
||||
@spec without_star_statements(t) :: t
|
||||
defdelegate without_star_statements(graph), to: RDF.Star.Graph
|
||||
|
||||
@doc """
|
||||
Gets and updates the description of the given subject, in a single pass.
|
||||
|
|
|
@ -63,14 +63,15 @@ defmodule RDF.Star.Graph do
|
|||
}
|
||||
end
|
||||
|
||||
@spec without_quoted_triples(Graph.t()) :: Graph.t()
|
||||
def without_quoted_triples(%Graph{} = graph) do
|
||||
@spec without_star_statements(Graph.t()) :: Graph.t()
|
||||
def without_star_statements(%Graph{} = graph) do
|
||||
%Graph{
|
||||
graph
|
||||
| descriptions:
|
||||
Enum.reduce(graph.descriptions, graph.descriptions, fn
|
||||
{subject, description}, descriptions when not is_tuple(subject) ->
|
||||
description_without_quoted_triples = Description.without_quoted_triples(description)
|
||||
description_without_quoted_triples =
|
||||
Description.without_quoted_triple_objects(description)
|
||||
|
||||
if Enum.empty?(description_without_quoted_triples) do
|
||||
Map.delete(descriptions, subject)
|
||||
|
|
|
@ -205,9 +205,10 @@ defmodule RDF.Star.Description.Test do
|
|||
assert Description.describes?(annotation_description(), coercible_statement())
|
||||
end
|
||||
|
||||
describe "without_quoted_triples/1" do
|
||||
describe "without_quoted_triple_objects/1" do
|
||||
test "empty description" do
|
||||
assert Description.without_quoted_triples(description()) == Description.new(description())
|
||||
assert Description.without_quoted_triple_objects(description()) ==
|
||||
Description.new(description())
|
||||
end
|
||||
|
||||
test "when the description has no quoted triples on object position" do
|
||||
|
@ -219,7 +220,7 @@ defmodule RDF.Star.Description.Test do
|
|||
]
|
||||
)
|
||||
|
||||
assert Description.without_quoted_triples(description) == description
|
||||
assert Description.without_quoted_triple_objects(description) == description
|
||||
end
|
||||
|
||||
test "when the description has quoted triples" do
|
||||
|
@ -230,7 +231,7 @@ defmodule RDF.Star.Description.Test do
|
|||
{EX.ap2(), statement()}
|
||||
]
|
||||
)
|
||||
|> Description.without_quoted_triples() ==
|
||||
|> Description.without_quoted_triple_objects() ==
|
||||
Description.new(statement(), init: {EX.ap1(), EX.ao()})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1798,26 +1798,26 @@ defmodule RDF.Star.GraphTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "without_quoted_triples/1" do
|
||||
describe "without_star_statements/1" do
|
||||
test "when no annotations exist" do
|
||||
assert Graph.without_quoted_triples(RDF.graph()) == RDF.graph()
|
||||
assert Graph.without_quoted_triples(RDF.graph(statement())) == RDF.graph(statement())
|
||||
assert Graph.without_star_statements(RDF.graph()) == RDF.graph()
|
||||
assert Graph.without_star_statements(RDF.graph(statement())) == RDF.graph(statement())
|
||||
end
|
||||
|
||||
test "when annotations exist" do
|
||||
assert Graph.without_quoted_triples(graph_with_annotation()) == RDF.graph()
|
||||
assert Graph.without_star_statements(graph_with_annotation()) == RDF.graph()
|
||||
|
||||
assert graph_with_annotation()
|
||||
|> Graph.add(statement())
|
||||
|> Graph.without_quoted_triples() == RDF.graph(statement())
|
||||
|> Graph.without_star_statements() == RDF.graph(statement())
|
||||
end
|
||||
|
||||
test "quoted triples on object position" do
|
||||
assert Graph.without_quoted_triples(graph_with_quoted_triples()) == RDF.graph()
|
||||
assert Graph.without_star_statements(graph_with_quoted_triples()) == RDF.graph()
|
||||
|
||||
assert graph_with_quoted_triples()
|
||||
|> Graph.add(statement())
|
||||
|> Graph.without_quoted_triples() == RDF.graph(statement())
|
||||
|> Graph.without_star_statements() == RDF.graph(statement())
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue