Verified Commit a69fc683 authored by Camil Staps's avatar Camil Staps
Browse files

Fix distance measure for record fields and constructors

parent 685a073e
......@@ -88,11 +88,11 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
Just ds -> appFst Just $ getIndices ds db
= (FunctionResult (
{ general
& distance = toInt $ kindPenalty fe.fe_kind * toReal (general.distance + sum
& distance = kindPenalty fe.fe_kind $ general.distance + sum
[ fromMaybe 0 $ contextPenalty <$> required_context
, fromMaybe 0 $ 'M'.get UnifierSize annots
, length usedsyns
])
]
, documentation = docDescription =<< fe.fe_documentation
},
{ kind = fe.fe_kind
......@@ -127,10 +127,14 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
where
toStr (var, type) = (var, concat $ print False type)
kindPenalty :: FunctionKind -> Real
kindPenalty RecordField = 1.2
kindPenalty Constructor = 1.1
kindPenalty _ = 1.0
kindPenalty :: FunctionKind Int -> Int
kindPenalty k d = toInt $ penalty * toReal d
where
penalty = case k of
RecordField -> further 0.2
Constructor -> further 0.1
_ -> 1.0
further s = if (d < 0) (1.0 - s) (1.0 + s)
contextPenalty :: [(String, [LocationResult])] -> Int
contextPenalty required_context = length [0 \\ (_,[]) <- required_context]
......@@ -254,7 +258,7 @@ where
distance = sum
[ case 'M'.get MatchingNGrams annots of
Nothing -> 0
Just n -> 0 - toInt (toReal n * 100.0 / toReal (size $ getName $ fromJust mbLoc))
Just n -> 0 - toInt (toReal n * 100.0 / toReal (size name))
, case 'M'.get ExactResult annots of
Just 1 -> -1
_ -> 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment