@@ -53,17 +53,14 @@ defmodule Akin do
53
53
54
54
def compare ( % Corpus { } = left , % Corpus { } = right , opts ) do
55
55
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
60
59
acc
61
60
else
62
- [ { String . replace ( k , "." , "" ) , v } | acc ]
61
+ Map . put ( acc , String . to_atom ( algorithm ) , r ( score ) )
63
62
end
64
63
end )
65
- |> Enum . map ( fn { k , v } -> { String . to_atom ( k ) , r ( v ) } end )
66
- |> Enum . into ( % { } )
67
64
end
68
65
69
66
@ spec match_names ( binary ( ) | % Corpus { } , binary ( ) | % Corpus { } | list ( ) , keyword ( ) ) :: float ( )
@@ -120,11 +117,11 @@ defmodule Akin do
120
117
end
121
118
122
119
@ 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
+ }
128
125
@ doc """
129
126
Compare a string to a string with logic specific to names. Matches are determined by algorithem
130
127
metrics equal to or higher than the `match_at` option. Return a list of strings that are a likely
0 commit comments