Change naming of statement count functions to be consistent
Previous names are provided as delegation functions.
This commit is contained in:
parent
072d4a0c01
commit
9ecc59b542
2 changed files with 11 additions and 7 deletions
|
@ -636,13 +636,15 @@ defmodule RDF.Description do
|
|||
@doc """
|
||||
Returns the number of statements of a `RDF.Description`.
|
||||
"""
|
||||
@spec count(t) :: non_neg_integer
|
||||
def count(%__MODULE__{} = description) do
|
||||
@spec statement_count(t) :: non_neg_integer
|
||||
def statement_count(%__MODULE__{} = description) do
|
||||
Enum.reduce(description.predications, 0, fn {_, objects}, count ->
|
||||
count + Enum.count(objects)
|
||||
end)
|
||||
end
|
||||
|
||||
defdelegate count(description), to: __MODULE__, as: :statement_count
|
||||
|
||||
@doc """
|
||||
Checks if the given `input` statements exist within `description`.
|
||||
"""
|
||||
|
@ -827,7 +829,7 @@ defmodule RDF.Description do
|
|||
alias RDF.Description
|
||||
|
||||
def member?(desc, triple), do: {:ok, Description.include?(desc, triple)}
|
||||
def count(desc), do: {:ok, Description.count(desc)}
|
||||
def count(desc), do: {:ok, Description.statement_count(desc)}
|
||||
def slice(_desc), do: {:error, __MODULE__}
|
||||
|
||||
def reduce(%Description{predications: predications}, {:cont, acc}, _fun)
|
||||
|
|
|
@ -675,17 +675,19 @@ defmodule RDF.Graph do
|
|||
...> {EX.S1, EX.p1, EX.O1},
|
||||
...> {EX.S2, EX.p2, EX.O2},
|
||||
...> {EX.S1, EX.p2, EX.O3}])
|
||||
...> |> RDF.Graph.triple_count()
|
||||
...> |> RDF.Graph.statement_count()
|
||||
3
|
||||
|
||||
"""
|
||||
@spec triple_count(t) :: non_neg_integer
|
||||
def triple_count(%__MODULE__{} = graph) do
|
||||
@spec statement_count(t) :: non_neg_integer
|
||||
def statement_count(%__MODULE__{} = graph) do
|
||||
Enum.reduce(graph.descriptions, 0, fn {_subject, description}, count ->
|
||||
count + Description.count(description)
|
||||
end)
|
||||
end
|
||||
|
||||
defdelegate triple_count(graph), to: __MODULE__, as: :statement_count
|
||||
|
||||
@doc """
|
||||
The set of all subjects used in the statements within a `RDF.Graph`.
|
||||
|
||||
|
@ -1087,7 +1089,7 @@ defmodule RDF.Graph do
|
|||
alias RDF.Graph
|
||||
|
||||
def member?(graph, triple), do: {:ok, Graph.include?(graph, triple)}
|
||||
def count(graph), do: {:ok, Graph.triple_count(graph)}
|
||||
def count(graph), do: {:ok, Graph.statement_count(graph)}
|
||||
def slice(_graph), do: {:error, __MODULE__}
|
||||
|
||||
def reduce(%Graph{descriptions: descriptions}, {:cont, acc}, _fun)
|
||||
|
|
Loading…
Reference in a new issue