-
Notifications
You must be signed in to change notification settings - Fork 191
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
discussing changes to LanguageAnalyzer #788
Open
brentam
wants to merge
10
commits into
opensearch-project:main
Choose a base branch
from
brentam:Reverting-analyzers-for-extra-languages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
54ab458
1.adding analyzer class for other languages.
brentam 12bf07b
test to verify the language analyzers are parsed correctly
brentam 31a7621
dummy CHANGELOG.md
brentam 843be49
adding information about the real PR to CHANGELOG.md
brentam f3412c6
ran ./gradlew :java-client:spotlessApply
brentam 4b8abd2
Merge remote-tracking branch 'upstream/main' into analyzers-for-extra…
brentam 6cb8ea5
Reverting created language *Analyzers, and Analyzer.java changes.
brentam aee4632
draft changes to language analyser and analyzer kindd
brentam 5154ee6
removing obsolete test class
brentam a38b9ba
temporary commenting this test until we decide if we keep the CjkAnal…
brentam 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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -33,6 +33,8 @@ | |||||
package org.opensearch.client.opensearch._types.analysis; | ||||||
|
||||||
import jakarta.json.stream.JsonGenerator; | ||||||
|
||||||
import java.util.Arrays; | ||||||
import java.util.function.Function; | ||||||
import org.opensearch.client.json.JsonEnum; | ||||||
import org.opensearch.client.json.JsonpDeserializable; | ||||||
|
@@ -62,8 +64,6 @@ public class Analyzer implements TaggedUnion<Analyzer.Kind, AnalyzerVariant>, Js | |||||
public enum Kind implements JsonEnum { | ||||||
Custom("custom"), | ||||||
|
||||||
Dutch("dutch"), | ||||||
|
||||||
Fingerprint("fingerprint"), | ||||||
|
||||||
IcuAnalyzer("icu_analyzer"), | ||||||
|
@@ -72,8 +72,6 @@ public enum Kind implements JsonEnum { | |||||
|
||||||
Kuromoji("kuromoji"), | ||||||
|
||||||
Language("language"), | ||||||
|
||||||
Nori("nori"), | ||||||
|
||||||
Pattern("pattern"), | ||||||
|
@@ -92,6 +90,74 @@ public enum Kind implements JsonEnum { | |||||
|
||||||
Cjk("cjk"), | ||||||
|
||||||
Arabic("arabic"), | ||||||
|
||||||
Armenian("armenian"), | ||||||
|
||||||
Basque("basque"), | ||||||
|
||||||
Bengali("bengali"), | ||||||
|
||||||
Brazilian("brazilian"), | ||||||
|
||||||
Bulgarian("bulgarian"), | ||||||
|
||||||
Catalan("catalan"), | ||||||
|
||||||
Czech("czech"), | ||||||
|
||||||
Danish("danish"), | ||||||
|
||||||
Dutch("dutch"), | ||||||
|
||||||
English("english"), | ||||||
|
||||||
Estonian("estonian"), | ||||||
|
||||||
Finnish("finnish"), | ||||||
|
||||||
French("french"), | ||||||
|
||||||
Galician("galician"), | ||||||
|
||||||
German("german"), | ||||||
|
||||||
Greek("greek"), | ||||||
|
||||||
Hindi("hindi"), | ||||||
|
||||||
Hungarian("hungarian"), | ||||||
|
||||||
Indonesian("indonesian"), | ||||||
|
||||||
Irish("irish"), | ||||||
|
||||||
Italian("italian"), | ||||||
|
||||||
Latvian("latvian"), | ||||||
|
||||||
Lithuanian("lithuanian"), | ||||||
|
||||||
Norwegian("norwegian"), | ||||||
|
||||||
Persian("persian"), | ||||||
|
||||||
Portuguese("portuguese"), | ||||||
|
||||||
Romanian("romanian"), | ||||||
|
||||||
Russian("russian"), | ||||||
|
||||||
Sorani("sorani"), | ||||||
|
||||||
Spanish("spanish"), | ||||||
|
||||||
Swedish("swedish"), | ||||||
|
||||||
Turkish("turkish"), | ||||||
|
||||||
Thai("thai"), | ||||||
|
||||||
; | ||||||
|
||||||
private final String jsonValue; | ||||||
|
@@ -154,23 +220,6 @@ public CustomAnalyzer custom() { | |||||
return TaggedUnionUtils.get(this, Kind.Custom); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Is this variant instance of kind {@code dutch}? | ||||||
*/ | ||||||
public boolean isDutch() { | ||||||
return _kind == Kind.Dutch; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Get the {@code dutch} variant value. | ||||||
* | ||||||
* @throws IllegalStateException | ||||||
* if the current variant is not of the {@code dutch} kind. | ||||||
*/ | ||||||
public DutchAnalyzer dutch() { | ||||||
return TaggedUnionUtils.get(this, Kind.Dutch); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Is this variant instance of kind {@code fingerprint}? | ||||||
*/ | ||||||
|
@@ -239,22 +288,6 @@ public KuromojiAnalyzer kuromoji() { | |||||
return TaggedUnionUtils.get(this, Kind.Kuromoji); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Is this variant instance of kind {@code language}? | ||||||
*/ | ||||||
public boolean isLanguage() { | ||||||
return _kind == Kind.Language; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Get the {@code language} variant value. | ||||||
* | ||||||
* @throws IllegalStateException | ||||||
* if the current variant is not of the {@code language} kind. | ||||||
*/ | ||||||
public LanguageAnalyzer language() { | ||||||
return TaggedUnionUtils.get(this, Kind.Language); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Is this variant instance of kind {@code nori}? | ||||||
|
@@ -399,16 +432,6 @@ public boolean isCjk() { | |||||
return _kind == Kind.Cjk; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Get the {@code cjk} variant value. | ||||||
* | ||||||
* @throws IllegalStateException | ||||||
* if the current variant is not of the {@code cjk} kind. | ||||||
*/ | ||||||
public CjkAnalyzer cjk() { | ||||||
return TaggedUnionUtils.get(this, Kind.Cjk); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public void serialize(JsonGenerator generator, JsonpMapper mapper) { | ||||||
|
||||||
|
@@ -430,16 +453,6 @@ public ObjectBuilder<Analyzer> custom(Function<CustomAnalyzer.Builder, ObjectBui | |||||
return this.custom(fn.apply(new CustomAnalyzer.Builder()).build()); | ||||||
} | ||||||
|
||||||
public ObjectBuilder<Analyzer> dutch(DutchAnalyzer v) { | ||||||
this._kind = Kind.Dutch; | ||||||
this._value = v; | ||||||
return this; | ||||||
} | ||||||
|
||||||
public ObjectBuilder<Analyzer> dutch(Function<DutchAnalyzer.Builder, ObjectBuilder<DutchAnalyzer>> fn) { | ||||||
return this.dutch(fn.apply(new DutchAnalyzer.Builder()).build()); | ||||||
} | ||||||
|
||||||
public ObjectBuilder<Analyzer> fingerprint(FingerprintAnalyzer v) { | ||||||
this._kind = Kind.Fingerprint; | ||||||
this._value = v; | ||||||
|
@@ -481,7 +494,7 @@ public ObjectBuilder<Analyzer> kuromoji(Function<KuromojiAnalyzer.Builder, Objec | |||||
} | ||||||
|
||||||
public ObjectBuilder<Analyzer> language(LanguageAnalyzer v) { | ||||||
this._kind = Kind.Language; | ||||||
this._kind = Kind.valueOf(v.language().name()); | ||||||
this._value = v; | ||||||
return this; | ||||||
} | ||||||
|
@@ -570,16 +583,6 @@ public ObjectBuilder<Analyzer> smartcn() { | |||||
return this.smartcn(new SmartcnAnalyzer.Builder().build()); | ||||||
} | ||||||
|
||||||
public ObjectBuilder<Analyzer> cjk(CjkAnalyzer v) { | ||||||
this._kind = Kind.Cjk; | ||||||
this._value = v; | ||||||
return this; | ||||||
} | ||||||
|
||||||
public ObjectBuilder<Analyzer> cjk(Function<CjkAnalyzer.Builder, ObjectBuilder<CjkAnalyzer>> fn) { | ||||||
return this.cjk(fn.apply(new CjkAnalyzer.Builder()).build()); | ||||||
} | ||||||
|
||||||
public Analyzer build() { | ||||||
_checkSingleUse(); | ||||||
return new Analyzer(this); | ||||||
|
@@ -589,8 +592,11 @@ public Analyzer build() { | |||||
|
||||||
protected static void setupAnalyzerDeserializer(ObjectDeserializer<Builder> op) { | ||||||
|
||||||
for (Language value : Language.values()) { | ||||||
op.add(Builder::language, LanguageAnalyzer._DESERIALIZER, value.jsonValue().toLowerCase()); | ||||||
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. You already did that, right?
Suggested change
|
||||||
//TODO should we lowercase in the Language Enum? | ||||||
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. Language jsonValue has to match the Kind jsonValue |
||||||
} | ||||||
op.add(Builder::custom, CustomAnalyzer._DESERIALIZER, "custom"); | ||||||
op.add(Builder::dutch, DutchAnalyzer._DESERIALIZER, "dutch"); | ||||||
op.add(Builder::fingerprint, FingerprintAnalyzer._DESERIALIZER, "fingerprint"); | ||||||
op.add(Builder::icuAnalyzer, IcuAnalyzer._DESERIALIZER, "icu_analyzer"); | ||||||
op.add(Builder::keyword, KeywordAnalyzer._DESERIALIZER, "keyword"); | ||||||
|
@@ -604,7 +610,6 @@ protected static void setupAnalyzerDeserializer(ObjectDeserializer<Builder> op) | |||||
op.add(Builder::stop, StopAnalyzer._DESERIALIZER, "stop"); | ||||||
op.add(Builder::whitespace, WhitespaceAnalyzer._DESERIALIZER, "whitespace"); | ||||||
op.add(Builder::smartcn, SmartcnAnalyzer._DESERIALIZER, Kind.Smartcn.jsonValue()); | ||||||
op.add(Builder::cjk, CjkAnalyzer._DESERIALIZER, Kind.Cjk.jsonValue()); | ||||||
|
||||||
op.setTypeProperty("type", null); | ||||||
|
||||||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
Curious why do we need to mirror
Language
enumeration here?