ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
738 stars 134 forks source link

Make inexact queries much more heuristic #14

Closed jwiegley closed 11 years ago

jwiegley commented 11 years ago

For example, exact matches with respect to case are always at the top. Next come prefix matches with respect to case, then case insensitive exact matches, then case insensitive prefix matches, then substring matches. Sorting of results weights exactitude higher than the number of times something was seen. Sorting is done after databases are merged.

With these changes, the queries for "map" and "Map", or "bimap" and "Bimap", return what you'd expect to see first. Otherwise, it's rather hard to search for Map, since there are were many case insensitive identifiers that have map as a substring. Basically you couldn't find it without specify the package or the module.

jwiegley commented 11 years ago

@ndmitchell @snoyberg You can try this out at http://hoogle.newartisans.com. When you have a lot of packages indexed (as I do), it really makes a difference when searching for things that otherwise turn up lots of substring matches.

Oh, and my version is currently reporting the exactitude of the match. This is just debug info and isn't in this commit.

ndmitchell commented 11 years ago

It certainly used to do the case-sensitive preference and the prefix first, but I suspect I broke it at some point (in the days before I used test suites as extensively as I do now!).

jwiegley commented 11 years ago

@ndmitchell Just FYI, this particular improvement grew out of a discussion on #haskell today about Hayoo vs. Hoogle and what could be done to make Hoogle queries better. Thanks for merging it so quickly!