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

[ML] Preserve casing for never split tokens #81429

Conversation

dimitris-athanasiou
Copy link
Contributor

This fixes a bug introduced by #81254. We are now using
a token trie tree to merge tokens belonging to one of the
never-split tokens back together. However, if the tokenizer
is lower casing, then the merged token will also be lower case
and won't be matched against never split tokens that are expected
to be in upper case.

This commit fixes this by looking up the original text and only
merging tokens together when the original text is matching one
of the never split tokens.

This fixes a bug introduced by elastic#81254. We are now using
a token trie tree to merge tokens belonging to one of the
never-split tokens back together. However, if the tokenizer
is lower casing, then the merged token will also be lower case
and won't be matched against never split tokens that are expected
to be in upper case.

This commit fixes this by looking up the original text and only
merging tokens together when the original text is matching one
of the never split tokens.
@elasticmachine elasticmachine added the Team:ML Meta label for the ML team label Dec 7, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

assertThat(tokenStrings(tokens), contains("Hello", "-", "[", "unk", "]"));
}

public void testNeverSplit_GivenLowerCase() {
Copy link
Member

Choose a reason for hiding this comment

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

this is a good test :D

@dimitris-athanasiou dimitris-athanasiou merged commit 86f31c2 into elastic:master Dec 7, 2021
@dimitris-athanasiou dimitris-athanasiou deleted the preserve-casing-for-never-split-tokens branch December 7, 2021 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:ml Machine learning >non-issue Team:ML Meta label for the ML team v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants