-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add support for the char_group tokenizer #3427
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6a0d86d
re-arch the way we do anlysis tests by making it easier for test clas…
Mpdreamz f0a0912
continueing to port analysis over to more isolated chunchs
Mpdreamz d536fd9
Ported normalizers over to new test format
Mpdreamz 537f9f9
clean up namespaces
Mpdreamz 5f6f5ef
All analysis unit/integ tests pass again
Mpdreamz 8a8e05d
abstracted analysis base classes even further to all share a base whi…
Mpdreamz 22502cf
add support for the char_group tokenizer
Mpdreamz e21d93c
Update XML comment
russcam 34d1490
Merge branch '6.4' into feature/char-group-tokenizer
russcam 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 hidden or 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,48 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Nest | ||
{ | ||
/// <summary> | ||
/// A tokenizer that breaks text into terms whenever it encounters a character which is in a defined set. It is mostly useful | ||
/// for cases where a simple custom tokenization is desired, and the overhead of use of <see cref="PatternTokenizer"/> is not acceptable. | ||
/// </summary> | ||
public interface ICharGroupTokenizer : ITokenizer | ||
{ | ||
/// <summary> | ||
/// A list containing a list of characters to tokenize the string on. Whenever a character from this list is encountered, a | ||
/// new token is started. This accepts either single characters like eg. -, or character groups: whitespace, letter, digit, | ||
/// punctuation, symbol. | ||
/// </summary> | ||
[JsonProperty("tokenize_on_chars")] | ||
IEnumerable<string> TokenizeOnCharacters { get; set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. specialized type that takes a union of enum and |
||
} | ||
|
||
/// <inheritdoc cref="ICharGroupTokenizer"/> | ||
public class CharGroupTokenizer : TokenizerBase, ICharGroupTokenizer | ||
{ | ||
internal const string TokenizerType = "char_group"; | ||
|
||
public CharGroupTokenizer() => this.Type = TokenizerType; | ||
|
||
/// <inheritdoc cref="ICharGroupTokenizer.TokenizeOnCharacters"/> | ||
public IEnumerable<string> TokenizeOnCharacters { get; set; } | ||
} | ||
|
||
/// <inheritdoc cref="ICharGroupTokenizer"/> | ||
public class CharGroupTokenizerDescriptor | ||
: TokenizerDescriptorBase<CharGroupTokenizerDescriptor, ICharGroupTokenizer>, ICharGroupTokenizer | ||
{ | ||
protected override string Type => CharGroupTokenizer.TokenizerType; | ||
|
||
IEnumerable<string> ICharGroupTokenizer.TokenizeOnCharacters { get; set; } | ||
|
||
/// <inheritdoc cref="ICharGroupTokenizer.TokenizeOnCharacters"/> | ||
public CharGroupTokenizerDescriptor TokenizeOnCharacters(params string[] characters) => | ||
Assign(a => a.TokenizeOnCharacters = characters); | ||
|
||
/// <inheritdoc cref="ICharGroupTokenizer.TokenizeOnCharacters"/> | ||
public CharGroupTokenizerDescriptor TokenizeOnCharacters(IEnumerable<string> characters) => | ||
Assign(a => a.TokenizeOnCharacters = characters); | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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.
I think the documentation should be