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

enh(parser) beginKeyword no longer bestows double relevance #2953

Merged

Conversation

joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented Jan 7, 2021

Previously something like:

{ 
  beginKeywords: "def"
  // which also implies:
  // keywords: "def"
}

Would bestow 2 relevance. 1 for the rule match and a second for the
keywords match. This is not correct behavior. A single "token" should
default to a single relevance point, not 2.

Changes

This changes the default relevance of a mode containing beginKeywords
to 0 forcing it to only gain relevance from keyword matches alone.

This of course revealed a few auto-detect balance issues (because some
grammars had been benefiting from this extra boost) which this PR
also resolves.

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md
  • Added myself to AUTHORS.txt, under Contributors

@joshgoebel joshgoebel added enhancement An enhancement or new feature parser labels Jan 7, 2021
@joshgoebel
Copy link
Member Author

Commit history here is clean if one wanted to review per commit.

@joshgoebel joshgoebel added this to the 10.6 milestone Jan 7, 2021
Copy link
Collaborator

@egor-rogov egor-rogov left a comment

Choose a reason for hiding this comment

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

Looks good, but do we really need floating-point relevance (1.5)? I guess 2 didn't work, but still...

@joshgoebel
Copy link
Member Author

joshgoebel commented Jan 19, 2021

Looks good, but do we really need floating-point relevance (1.5)? I guess 2 didn't work, but still...

Well, need is a strong word. I don't want to encourage it (if not necessary), but it was helpful here; and honestly DOUBLE relevance (not to mention 10x) is really a pretty huge multiple to be the only choice. And many of the really "smart" things we could do with relevance will ultimately result in fractional relevance values.

Math.floor is just me being ridiculously careful with compatibility. I wager it wouldn't matter, but was easy enough to add and then remove with v11 (allowing fractional relevance values).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants