Skip to content

Commit ab3565b

Browse files
committed
Merge branch 'main' of https://github.com/vanessaklee/akin
2 parents 75205d5 + 81e0cde commit ab3565b

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

lib/akin.ex

+9-12
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,14 @@ defmodule Akin do
5353

5454
def compare(%Corpus{} = left, %Corpus{} = right, opts) do
5555
Enum.reduce(list_algorithms(opts), %{}, fn algorithm, acc ->
56-
Map.put(acc, algorithm, apply(modulize(algorithm), :compare, [left, right, opts]))
57-
end)
58-
|> Enum.reduce([], fn {k, v}, acc ->
59-
if is_nil(v) do
56+
score = apply(modulize(algorithm), :compare, [left, right, opts])
57+
58+
if is_nil(score) do
6059
acc
6160
else
62-
[{String.replace(k, ".", ""), v} | acc]
61+
Map.put(acc, String.to_atom(algorithm), r(score))
6362
end
6463
end)
65-
|> Enum.map(fn {k, v} -> {String.to_atom(k), r(v)} end)
66-
|> Enum.into(%{})
6764
end
6865

6966
@spec match_names(binary() | %Corpus{}, binary() | %Corpus{} | list(), keyword()) :: float()
@@ -120,11 +117,11 @@ defmodule Akin do
120117
end
121118

122119
@spec match_name_metrics(binary(), binary(), Keyword.t()) :: %{
123-
:left => binary(),
124-
:match => 0 | 1,
125-
:metrics => [any()],
126-
:right => binary()
127-
}
120+
:left => binary(),
121+
:match => 0 | 1,
122+
:metrics => [any()],
123+
:right => binary()
124+
}
128125
@doc """
129126
Compare a string to a string with logic specific to names. Matches are determined by algorithem
130127
metrics equal to or higher than the `match_at` option. Return a list of strings that are a likely

0 commit comments

Comments
 (0)