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

fix: create custom tokenizer #520

Merged
merged 1 commit into from
Oct 16, 2023
Merged

Conversation

stearm
Copy link
Contributor

@stearm stearm commented Oct 16, 2023

Fixes #492.

Correctly create the tokenizer using the custom one passed via parameters.

Speaking about the linked issue, the provided example seems to be wrong:

const orama = await create({
    schema: {
      foo: "string",
    },
    components: {
      tokenizer: {
        normalizationCache: new Map([["english:foo:Bar", "bar"]]),
        stemming: true,
      },
    },
  });

According to the documentation, a custom tokenizer is made up of at least language, normalizationCache, and the tokenize function (see Tokenizer interface). For the time being, passing a custom normalizationCache is only possible if a custom tokenizer is used.

Passing a custom normalisation cache with default values without using a custom tokenize function could be harmful (or at the very least ineffective), because it would be supplied with specific keys determined by the language inside the native tokenizer.

@vercel
Copy link

vercel bot commented Oct 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orama-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 0:06am

@stearm stearm changed the title fix: use custom tokenizer correctly fix: create custom tokenizer Oct 16, 2023
Copy link
Member

@micheleriva micheleriva left a comment

Choose a reason for hiding this comment

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

LGTM

@micheleriva micheleriva merged commit 0a35cd9 into askorama:main Oct 16, 2023
3 checks passed
@stearm stearm deleted the fix/custom-tokenizer branch October 16, 2023 14:20
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.

Normalization cache overriden when creating orama instance
2 participants