Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added boost for matches directly following the last period #708

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

scohen
Copy link
Collaborator

@scohen scohen commented Apr 19, 2024

If something matches starting after the last period (of a likely module) it is boosted. This makes a match for MyModule.Structs.User take precedence over MyModule.User.Something while querying for User

@scohen scohen requested review from zachallaun and scottming April 19, 2024 18:21
Copy link
Collaborator

@scottming scottming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR solves this problem:

This makes a match for MyModule.Structs.User take precedence over MyModule.User.Something while querying for User

but it doesn't address the issue with mixed case. Instead, it pushes modules with capital letters further down. The screenshot illustrates the problem; the module with 'User' at the top is sorted towards the end.

CleanShot 2024-04-20 at 20 23 28@2x

You can also reproduce the issue with this unit test:

    test "matches when there're mixed case characters" do
      results = score_and_sort(~w(create_user save_user Demo.Accounts.User), "User")
      assert results == ~w(Demo.Accounts.User create_user save_user)
    end

@scohen
Copy link
Collaborator Author

scohen commented Apr 22, 2024

@scottming i made some changes to the scoring that should improve the situations you've mentioned.

@scohen scohen force-pushed the tail_module_boost branch from 462cbb3 to 1b1b469 Compare April 23, 2024 16:11
scohen added 3 commits April 23, 2024 09:33
If something matches starting after the last period (of a likely
module) it is boosted. This makes a match for `MyModule.Structs.User`
take precedence over `MyModule.User.Something` while querying for `User`
  * Removed case match bonus in favor of camel case bonus
  * Removed pattern length bonus, since it's the same for all subjects
  * Changed incompleteness penalty to be based on the number of
    characters matched in the subject rather than the size of the
    pattern
@scohen scohen requested review from scottming and zachallaun April 23, 2024 23:27
@scohen scohen force-pushed the tail_module_boost branch from 1b1b469 to 01d9f11 Compare April 23, 2024 23:32
Copy link
Collaborator

@scottming scottming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it and I think the latest version works really well, thank you. I believe that boosting the last module is extremely effective because once we pinpoint the module, we can narrow the scope and more quickly locate the specific symbol.

@scohen scohen merged commit 2f6ea89 into main Apr 24, 2024
9 checks passed
@scohen scohen deleted the tail_module_boost branch April 24, 2024 15:10
scohen added a commit that referenced this pull request Apr 26, 2024
* Added boost for matches directly following the last period

If something matches starting after the last period (of a likely
module) it is boosted. This makes a match for `MyModule.Structs.User`
take precedence over `MyModule.User.Something` while querying for `User`

* Simplified scoring rules

  * Removed case match bonus in favor of camel case bonus
  * Removed pattern length bonus, since it's the same for all subjects
  * Changed incompleteness penalty to be based on the number of
    characters matched in the subject rather than the size of the
    pattern
* dropped min query length to 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants