-
Notifications
You must be signed in to change notification settings - Fork 505
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
[DOC] Tokenizers - Classic #8357
Merged
kolchfa-aws
merged 15 commits into
opensearch-project:main
from
leanneeliatra:tokenizer-classic
Jan 3, 2025
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ceff6a6
adding in classic tokenizer page
leanneeliatra 495a8d8
removing unneeded whitespace
leanneeliatra e80f5ea
tokenizers does now have children
leanneeliatra e998f91
Merge branch 'main' into tokenizer-classic
leanneeliatra d7de779
Merge branch 'main' into tokenizer-classic
leanneeliatra f5021f3
doc: small update for page numbers
leanneeliatra caa0811
Merge branch 'main' into tokenizer-classic
leanneeliatra 7217737
format: updates to layout and formatting of page
leanneeliatra 5b8506c
Doc review
kolchfa-aws 1289908
Change example
kolchfa-aws 2f76758
Small rewrite
kolchfa-aws 8179ffa
Apply suggestions from code review
kolchfa-aws ac12e56
Merge branch 'main' into tokenizer-classic
kolchfa-aws 94434a5
Update _analyzers/tokenizers/classic.md
kolchfa-aws 6b54b56
Merge branch 'main' into tokenizer-classic
kolchfa-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
layout: default | ||
title: Classic Tokenizer | ||
parent: Tokenizers | ||
nav_order: 35 | ||
|
||
--- | ||
|
||
# Classic tokenizer | ||
|
||
The classic tokenizer is built to handle English text efficiently, applying grammatical rules to break the text into tokens. It includes specific logic to handle patterns such as: | ||
- acronyms | ||
- email addresses | ||
- domain names | ||
- certain types of punctuation | ||
|
||
This tokenizer works best with the English language, it may not produce optimal results for other languages, especially those with different grammatical structures. | ||
{: .note} | ||
|
||
The classic tokenizer splits words at most punctuation marks while removing the punctuation. Dots that aren't followed by spaces are treated as part of the token. It also breaks words at hyphens, except when a number is present, treating the entire sequence as a single token, like a product code. Additionally, it recognizes email addresses and hostnames as individual tokens to keep them intact. | ||
|
||
## Example using the classic tokenizer | ||
|
||
By using the classic tokenizer, we can see how the tokenizer retains patterns like email addresses and phone numbers, while splitting other text at punctuation marks: | ||
|
||
```json | ||
POST _analyze | ||
{ | ||
"tokenizer": "classic", | ||
"text": "Send an email to john.doe@example.com or call 555-1234!" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The tokenizer keeps the email address `john.doe@example.com` and the phone number `555-1234` as single tokens, while splitting the rest of the sentence at punctuation marks. | ||
|
||
By analyzing the text "Send an email to john.doe@example.com or call 555-1234!", we can see the punctuation has been removed, while email and phone number | ||
|
||
``` | ||
"Send", "an", "email", "to", "john.doe", "example.com", "or", "call", "555-1234" | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I was wondering if it would be better to show entire output as there are different token types.
{"<ALPHANUM>", "<APOSTROPHE>", "<ACRONYM>", "<COMPANY>", "<EMAIL>", "<HOST>", "<NUM>", "<CJ>", "<ACRONYM_DEP>"}