Skip to content

Commit

Permalink
improve type signature compatibility rating
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobiasd committed Jun 22, 2016
1 parent 0ba9c0c commit 0afd93d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 2 additions & 8 deletions api_search/frontend/src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,11 @@ boolToNum value b =

typeRating :
Float
-> Float
-> TypeSignature.Signature
-> TypeSignature.Signature
-> Float
typeRating weight factor query db =
typeRating weight query db =
TypeSignature.functionCompatibility db query
|> (*) factor
|> (*) weight


Expand Down Expand Up @@ -444,12 +442,8 @@ functionRating queryOrig querySig querySigLower function =
case maybeSig of
Just sig ->
let
typeWeight =
stringLengthFloat (TypeSignature.showSignature True sig)
/ stringLengthFloat function.signature

allRatings =
List.map (typeRating factor typeWeight sig)
List.map (typeRating factor sig)
function.subSignatures
in
allRatings
Expand Down
6 changes: 3 additions & 3 deletions api_search/frontend/src/TypeSignature.elm
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ sortSignatures =
functionCompatibility : Signature -> Signature -> Float
functionCompatibility db query =
case ( db, query ) of
( VariableType _, TypeConstructor "String" ) ->
1.0
( VariableType _, ListType (TypeConstructor "Char")) ->
0.9

( VariableType _, TypeConstructor _ ) ->
0.6
0.95

( VariableType _, ListType _ ) ->
0.7
Expand Down

0 comments on commit 0afd93d

Please sign in to comment.