From 3fc3c1498ec8ceff47ac933d4617d1bb8d5b2188 Mon Sep 17 00:00:00 2001 From: Fabian Richter Date: Wed, 15 Nov 2023 18:18:13 +0100 Subject: [PATCH] feat: add language code to MatchRequest in GRPCRule --- .../grpc/SynthesizeServerGrpc.java | 51 +- .../languagemodel/bert/grpc/BertLmGrpc.java | 67 ++- .../java/org/languagetool/rules/GRPCRule.java | 2 + .../languagetool/rules/ml/MLServerGrpc.java | 67 ++- .../languagetool/rules/ml/MLServerProto.java | 489 +++++++++++++++--- .../rules/ml/PostProcessingServerGrpc.java | 54 +- .../rules/ml/ProcessingServerGrpc.java | 67 ++- .../src/main/proto/ml_server.proto | 2 + 8 files changed, 632 insertions(+), 167 deletions(-) diff --git a/languagetool-core/src/main/java/org/languagetool/grpc/SynthesizeServerGrpc.java b/languagetool-core/src/main/java/org/languagetool/grpc/SynthesizeServerGrpc.java index 325d42b591e7..366a1eab4980 100644 --- a/languagetool-core/src/main/java/org/languagetool/grpc/SynthesizeServerGrpc.java +++ b/languagetool-core/src/main/java/org/languagetool/grpc/SynthesizeServerGrpc.java @@ -5,7 +5,7 @@ /** */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.50.2)", + value = "by gRPC proto compiler (version 1.56.1)", comments = "Source: synthesizer.proto") @io.grpc.stub.annotations.GrpcGenerated public final class SynthesizeServerGrpc { @@ -92,31 +92,32 @@ public SynthesizeServerFutureStub newStub(io.grpc.Channel channel, io.grpc.CallO /** */ - public static abstract class SynthesizeServerImplBase implements io.grpc.BindableService { + public interface AsyncService { /** */ - public void synthesize(org.languagetool.grpc.Synthesizer.SynthesizeRequest request, + default void synthesize(org.languagetool.grpc.Synthesizer.SynthesizeRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSynthesizeMethod(), responseObserver); } + } + + /** + * Base class for the server implementation of the service SynthesizeServer. + */ + public static abstract class SynthesizeServerImplBase + implements io.grpc.BindableService, AsyncService { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getSynthesizeMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.grpc.Synthesizer.SynthesizeRequest, - org.languagetool.grpc.Synthesizer.SynthesizeResponse>( - this, METHODID_SYNTHESIZE))) - .build(); + return SynthesizeServerGrpc.bindService(this); } } /** + * A stub to allow clients to do asynchronous rpc calls to service SynthesizeServer. */ - public static final class SynthesizeServerStub extends io.grpc.stub.AbstractAsyncStub { + public static final class SynthesizeServerStub + extends io.grpc.stub.AbstractAsyncStub { private SynthesizeServerStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -138,8 +139,10 @@ public void synthesize(org.languagetool.grpc.Synthesizer.SynthesizeRequest reque } /** + * A stub to allow clients to do synchronous rpc calls to service SynthesizeServer. */ - public static final class SynthesizeServerBlockingStub extends io.grpc.stub.AbstractBlockingStub { + public static final class SynthesizeServerBlockingStub + extends io.grpc.stub.AbstractBlockingStub { private SynthesizeServerBlockingStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -160,8 +163,10 @@ public org.languagetool.grpc.Synthesizer.SynthesizeResponse synthesize(org.langu } /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service SynthesizeServer. */ - public static final class SynthesizeServerFutureStub extends io.grpc.stub.AbstractFutureStub { + public static final class SynthesizeServerFutureStub + extends io.grpc.stub.AbstractFutureStub { private SynthesizeServerFutureStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -189,10 +194,10 @@ private static final class MethodHandlers implements io.grpc.stub.ServerCalls.ServerStreamingMethod, io.grpc.stub.ServerCalls.ClientStreamingMethod, io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final SynthesizeServerImplBase serviceImpl; + private final AsyncService serviceImpl; private final int methodId; - MethodHandlers(SynthesizeServerImplBase serviceImpl, int methodId) { + MethodHandlers(AsyncService serviceImpl, int methodId) { this.serviceImpl = serviceImpl; this.methodId = methodId; } @@ -221,6 +226,18 @@ public io.grpc.stub.StreamObserver invoke( } } + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSynthesizeMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.grpc.Synthesizer.SynthesizeRequest, + org.languagetool.grpc.Synthesizer.SynthesizeResponse>( + service, METHODID_SYNTHESIZE))) + .build(); + } + private static abstract class SynthesizeServerBaseDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { SynthesizeServerBaseDescriptorSupplier() {} diff --git a/languagetool-core/src/main/java/org/languagetool/languagemodel/bert/grpc/BertLmGrpc.java b/languagetool-core/src/main/java/org/languagetool/languagemodel/bert/grpc/BertLmGrpc.java index ba0a093e39fe..812ff5225749 100644 --- a/languagetool-core/src/main/java/org/languagetool/languagemodel/bert/grpc/BertLmGrpc.java +++ b/languagetool-core/src/main/java/org/languagetool/languagemodel/bert/grpc/BertLmGrpc.java @@ -5,7 +5,7 @@ /** */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.50.2)", + value = "by gRPC proto compiler (version 1.56.1)", comments = "Source: bert-lm.proto") @io.grpc.stub.annotations.GrpcGenerated public final class BertLmGrpc { @@ -123,45 +123,39 @@ public BertLmFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions cal /** */ - public static abstract class BertLmImplBase implements io.grpc.BindableService { + public interface AsyncService { /** */ - public void score(org.languagetool.languagemodel.bert.grpc.BertLmProto.ScoreRequest request, + default void score(org.languagetool.languagemodel.bert.grpc.BertLmProto.ScoreRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getScoreMethod(), responseObserver); } /** */ - public void batchScore(org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchScoreRequest request, + default void batchScore(org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchScoreRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getBatchScoreMethod(), responseObserver); } + } + + /** + * Base class for the server implementation of the service BertLm. + */ + public static abstract class BertLmImplBase + implements io.grpc.BindableService, AsyncService { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getScoreMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.languagemodel.bert.grpc.BertLmProto.ScoreRequest, - org.languagetool.languagemodel.bert.grpc.BertLmProto.BertLmResponse>( - this, METHODID_SCORE))) - .addMethod( - getBatchScoreMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchScoreRequest, - org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchBertLmResponse>( - this, METHODID_BATCH_SCORE))) - .build(); + return BertLmGrpc.bindService(this); } } /** + * A stub to allow clients to do asynchronous rpc calls to service BertLm. */ - public static final class BertLmStub extends io.grpc.stub.AbstractAsyncStub { + public static final class BertLmStub + extends io.grpc.stub.AbstractAsyncStub { private BertLmStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -191,8 +185,10 @@ public void batchScore(org.languagetool.languagemodel.bert.grpc.BertLmProto.Batc } /** + * A stub to allow clients to do synchronous rpc calls to service BertLm. */ - public static final class BertLmBlockingStub extends io.grpc.stub.AbstractBlockingStub { + public static final class BertLmBlockingStub + extends io.grpc.stub.AbstractBlockingStub { private BertLmBlockingStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -220,8 +216,10 @@ public org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchBertLmResponse } /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service BertLm. */ - public static final class BertLmFutureStub extends io.grpc.stub.AbstractFutureStub { + public static final class BertLmFutureStub + extends io.grpc.stub.AbstractFutureStub { private BertLmFutureStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -258,10 +256,10 @@ private static final class MethodHandlers implements io.grpc.stub.ServerCalls.ServerStreamingMethod, io.grpc.stub.ServerCalls.ClientStreamingMethod, io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final BertLmImplBase serviceImpl; + private final AsyncService serviceImpl; private final int methodId; - MethodHandlers(BertLmImplBase serviceImpl, int methodId) { + MethodHandlers(AsyncService serviceImpl, int methodId) { this.serviceImpl = serviceImpl; this.methodId = methodId; } @@ -294,6 +292,25 @@ public io.grpc.stub.StreamObserver invoke( } } + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getScoreMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.languagemodel.bert.grpc.BertLmProto.ScoreRequest, + org.languagetool.languagemodel.bert.grpc.BertLmProto.BertLmResponse>( + service, METHODID_SCORE))) + .addMethod( + getBatchScoreMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchScoreRequest, + org.languagetool.languagemodel.bert.grpc.BertLmProto.BatchBertLmResponse>( + service, METHODID_BATCH_SCORE))) + .build(); + } + private static abstract class BertLmBaseDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { BertLmBaseDescriptorSupplier() {} diff --git a/languagetool-core/src/main/java/org/languagetool/rules/GRPCRule.java b/languagetool-core/src/main/java/org/languagetool/rules/GRPCRule.java index 89efe0d3afc0..07a8d8ba4594 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/GRPCRule.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/GRPCRule.java @@ -262,6 +262,7 @@ protected RemoteRule.RemoteRequest prepareRequest(List sentenc .subList(offset, Math.min(filteredSentences.size(), offset + batchSize)) .stream().map(GRPCUtils::toGRPC).collect(Collectors.toList())) .setInputLogging(inputLogging) + .setLanguage(ruleLanguage.getShortCodeWithCountryAndVariant()) .addAllTextSessionID(textSessionId != null ? ids.subList(offset, Math.min(filteredSentences.size(), offset + batchSize)) : Collections.emptyList()) @@ -284,6 +285,7 @@ protected RemoteRule.RemoteRequest prepareRequest(List sentenc MLServerProto.MatchRequest req = MLServerProto.MatchRequest.newBuilder() .addAllSentences(text.subList(offset, Math.min(text.size(), offset + batchSize))) .setInputLogging(inputLogging) + .setLanguage(ruleLanguage.getShortCodeWithCountryAndVariant()) .addAllTextSessionID(textSessionId != null ? ids.subList(offset, Math.min(text.size(), offset + batchSize)) : Collections.emptyList()) diff --git a/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerGrpc.java b/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerGrpc.java index 0a91cc3cefdf..bb25da462064 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerGrpc.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerGrpc.java @@ -5,7 +5,7 @@ /** */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.50.2)", + value = "by gRPC proto compiler (version 1.56.1)", comments = "Source: ml_server.proto") @io.grpc.stub.annotations.GrpcGenerated public final class MLServerGrpc { @@ -123,45 +123,39 @@ public MLServerFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions c /** */ - public static abstract class MLServerImplBase implements io.grpc.BindableService { + public interface AsyncService { /** */ - public void match(org.languagetool.rules.ml.MLServerProto.MatchRequest request, + default void match(org.languagetool.rules.ml.MLServerProto.MatchRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getMatchMethod(), responseObserver); } /** */ - public void matchAnalyzed(org.languagetool.rules.ml.MLServerProto.AnalyzedMatchRequest request, + default void matchAnalyzed(org.languagetool.rules.ml.MLServerProto.AnalyzedMatchRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getMatchAnalyzedMethod(), responseObserver); } + } + + /** + * Base class for the server implementation of the service MLServer. + */ + public static abstract class MLServerImplBase + implements io.grpc.BindableService, AsyncService { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getMatchMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.rules.ml.MLServerProto.MatchRequest, - org.languagetool.rules.ml.MLServerProto.MatchResponse>( - this, METHODID_MATCH))) - .addMethod( - getMatchAnalyzedMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.rules.ml.MLServerProto.AnalyzedMatchRequest, - org.languagetool.rules.ml.MLServerProto.MatchResponse>( - this, METHODID_MATCH_ANALYZED))) - .build(); + return MLServerGrpc.bindService(this); } } /** + * A stub to allow clients to do asynchronous rpc calls to service MLServer. */ - public static final class MLServerStub extends io.grpc.stub.AbstractAsyncStub { + public static final class MLServerStub + extends io.grpc.stub.AbstractAsyncStub { private MLServerStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -191,8 +185,10 @@ public void matchAnalyzed(org.languagetool.rules.ml.MLServerProto.AnalyzedMatchR } /** + * A stub to allow clients to do synchronous rpc calls to service MLServer. */ - public static final class MLServerBlockingStub extends io.grpc.stub.AbstractBlockingStub { + public static final class MLServerBlockingStub + extends io.grpc.stub.AbstractBlockingStub { private MLServerBlockingStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -220,8 +216,10 @@ public org.languagetool.rules.ml.MLServerProto.MatchResponse matchAnalyzed(org.l } /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service MLServer. */ - public static final class MLServerFutureStub extends io.grpc.stub.AbstractFutureStub { + public static final class MLServerFutureStub + extends io.grpc.stub.AbstractFutureStub { private MLServerFutureStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -258,10 +256,10 @@ private static final class MethodHandlers implements io.grpc.stub.ServerCalls.ServerStreamingMethod, io.grpc.stub.ServerCalls.ClientStreamingMethod, io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final MLServerImplBase serviceImpl; + private final AsyncService serviceImpl; private final int methodId; - MethodHandlers(MLServerImplBase serviceImpl, int methodId) { + MethodHandlers(AsyncService serviceImpl, int methodId) { this.serviceImpl = serviceImpl; this.methodId = methodId; } @@ -294,6 +292,25 @@ public io.grpc.stub.StreamObserver invoke( } } + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getMatchMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.rules.ml.MLServerProto.MatchRequest, + org.languagetool.rules.ml.MLServerProto.MatchResponse>( + service, METHODID_MATCH))) + .addMethod( + getMatchAnalyzedMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.rules.ml.MLServerProto.AnalyzedMatchRequest, + org.languagetool.rules.ml.MLServerProto.MatchResponse>( + service, METHODID_MATCH_ANALYZED))) + .build(); + } + private static abstract class MLServerBaseDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { MLServerBaseDescriptorSupplier() {} diff --git a/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerProto.java b/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerProto.java index a17de71c9a03..058b847c17df 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerProto.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/ml/MLServerProto.java @@ -5318,6 +5318,26 @@ org.languagetool.rules.ml.MLServerProto.AnalyzedSentenceOrBuilder getSentencesOr * @return The textSessionID at the given index. */ long getTextSessionID(int index); + + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The language. + */ + java.lang.String getLanguage(); + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The bytes for language. + */ + com.google.protobuf.ByteString + getLanguageBytes(); } /** * Protobuf type {@code lt_ml_server.AnalyzedMatchRequest} @@ -5334,6 +5354,7 @@ private AnalyzedMatchRequest(com.google.protobuf.GeneratedMessageV3.Builder b private AnalyzedMatchRequest() { sentences_ = java.util.Collections.emptyList(); textSessionID_ = emptyLongList(); + language_ = ""; } @java.lang.Override @@ -5402,6 +5423,12 @@ private AnalyzedMatchRequest( input.popLimit(limit); break; } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + language_ = s; + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -5535,6 +5562,52 @@ public long getTextSessionID(int index) { } private int textSessionIDMemoizedSerializedSize = -1; + public static final int LANGUAGE_FIELD_NUMBER = 4; + private volatile java.lang.Object language_; + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The language. + */ + @java.lang.Override + public java.lang.String getLanguage() { + java.lang.Object ref = language_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + language_ = s; + return s; + } + } + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The bytes for language. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getLanguageBytes() { + java.lang.Object ref = language_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -5563,6 +5636,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < textSessionID_.size(); i++) { output.writeInt64NoTag(textSessionID_.getLong(i)); } + if (!getLanguageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, language_); + } unknownFields.writeTo(output); } @@ -5594,6 +5670,9 @@ public int getSerializedSize() { } textSessionIDMemoizedSerializedSize = dataSize; } + if (!getLanguageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, language_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -5615,6 +5694,8 @@ public boolean equals(final java.lang.Object obj) { != other.getInputLogging()) return false; if (!getTextSessionIDList() .equals(other.getTextSessionIDList())) return false; + if (!getLanguage() + .equals(other.getLanguage())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -5637,6 +5718,8 @@ public int hashCode() { hash = (37 * hash) + TEXTSESSIONID_FIELD_NUMBER; hash = (53 * hash) + getTextSessionIDList().hashCode(); } + hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; + hash = (53 * hash) + getLanguage().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -5781,6 +5864,8 @@ public Builder clear() { textSessionID_ = emptyLongList(); bitField0_ = (bitField0_ & ~0x00000002); + language_ = ""; + return this; } @@ -5823,6 +5908,7 @@ public org.languagetool.rules.ml.MLServerProto.AnalyzedMatchRequest buildPartial bitField0_ = (bitField0_ & ~0x00000002); } result.textSessionID_ = textSessionID_; + result.language_ = language_; onBuilt(); return result; } @@ -5910,6 +5996,10 @@ public Builder mergeFrom(org.languagetool.rules.ml.MLServerProto.AnalyzedMatchRe } onChanged(); } + if (!other.getLanguage().isEmpty()) { + language_ = other.language_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -6329,6 +6419,102 @@ public Builder clearTextSessionID() { onChanged(); return this; } + + private java.lang.Object language_ = ""; + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @return The language. + */ + public java.lang.String getLanguage() { + java.lang.Object ref = language_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + language_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @return The bytes for language. + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + java.lang.Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @param value The language to set. + * @return This builder for chaining. + */ + public Builder setLanguage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + language_ = value; + onChanged(); + return this; + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @return This builder for chaining. + */ + public Builder clearLanguage() { + + language_ = getDefaultInstance().getLanguage(); + onChanged(); + return this; + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @param value The bytes for language to set. + * @return This builder for chaining. + */ + public Builder setLanguageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + language_ = value; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -10883,6 +11069,26 @@ public interface MatchRequestOrBuilder extends * @return The textSessionID at the given index. */ long getTextSessionID(int index); + + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The language. + */ + java.lang.String getLanguage(); + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The bytes for language. + */ + com.google.protobuf.ByteString + getLanguageBytes(); } /** * Protobuf type {@code lt_ml_server.MatchRequest} @@ -10899,6 +11105,7 @@ private MatchRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) private MatchRequest() { sentences_ = com.google.protobuf.LazyStringArrayList.EMPTY; textSessionID_ = emptyLongList(); + language_ = ""; } @java.lang.Override @@ -10967,6 +11174,12 @@ private MatchRequest( input.popLimit(limit); break; } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + language_ = s; + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -11111,6 +11324,52 @@ public long getTextSessionID(int index) { } private int textSessionIDMemoizedSerializedSize = -1; + public static final int LANGUAGE_FIELD_NUMBER = 4; + private volatile java.lang.Object language_; + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The language. + */ + @java.lang.Override + public java.lang.String getLanguage() { + java.lang.Object ref = language_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + language_ = s; + return s; + } + } + /** + *
+     * language code (with region/country) of text being handled
+     * 
+ * + * string language = 4; + * @return The bytes for language. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getLanguageBytes() { + java.lang.Object ref = language_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -11139,6 +11398,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < textSessionID_.size(); i++) { output.writeInt64NoTag(textSessionID_.getLong(i)); } + if (!getLanguageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, language_); + } unknownFields.writeTo(output); } @@ -11174,6 +11436,9 @@ public int getSerializedSize() { } textSessionIDMemoizedSerializedSize = dataSize; } + if (!getLanguageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, language_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -11195,6 +11460,8 @@ public boolean equals(final java.lang.Object obj) { != other.getInputLogging()) return false; if (!getTextSessionIDList() .equals(other.getTextSessionIDList())) return false; + if (!getLanguage() + .equals(other.getLanguage())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -11217,6 +11484,8 @@ public int hashCode() { hash = (37 * hash) + TEXTSESSIONID_FIELD_NUMBER; hash = (53 * hash) + getTextSessionIDList().hashCode(); } + hash = (37 * hash) + LANGUAGE_FIELD_NUMBER; + hash = (53 * hash) + getLanguage().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -11356,6 +11625,8 @@ public Builder clear() { textSessionID_ = emptyLongList(); bitField0_ = (bitField0_ & ~0x00000002); + language_ = ""; + return this; } @@ -11394,6 +11665,7 @@ public org.languagetool.rules.ml.MLServerProto.MatchRequest buildPartial() { bitField0_ = (bitField0_ & ~0x00000002); } result.textSessionID_ = textSessionID_; + result.language_ = language_; onBuilt(); return result; } @@ -11465,6 +11737,10 @@ public Builder mergeFrom(org.languagetool.rules.ml.MLServerProto.MatchRequest ot } onChanged(); } + if (!other.getLanguage().isEmpty()) { + language_ = other.language_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -11790,6 +12066,102 @@ public Builder clearTextSessionID() { onChanged(); return this; } + + private java.lang.Object language_ = ""; + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @return The language. + */ + public java.lang.String getLanguage() { + java.lang.Object ref = language_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + language_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @return The bytes for language. + */ + public com.google.protobuf.ByteString + getLanguageBytes() { + java.lang.Object ref = language_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + language_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @param value The language to set. + * @return This builder for chaining. + */ + public Builder setLanguage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + language_ = value; + onChanged(); + return this; + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @return This builder for chaining. + */ + public Builder clearLanguage() { + + language_ = getDefaultInstance().getLanguage(); + onChanged(); + return this; + } + /** + *
+       * language code (with region/country) of text being handled
+       * 
+ * + * string language = 4; + * @param value The bytes for language to set. + * @return This builder for chaining. + */ + public Builder setLanguageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + language_ = value; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -20406,62 +20778,63 @@ public org.languagetool.rules.ml.MLServerProto.SuggestedReplacement getDefaultIn "\n\007options\030\002 \001(\0132\037.lt_ml_server.Processin" + "gOptions\"`\n\017ProcessResponse\022\'\n\nrawMatche" + "s\030\001 \003(\0132\023.lt_ml_server.Match\022$\n\007matches\030" + - "\002 \003(\0132\023.lt_ml_server.Match\"v\n\024AnalyzedMa" + - "tchRequest\0221\n\tsentences\030\001 \003(\0132\036.lt_ml_se" + - "rver.AnalyzedSentence\022\024\n\014inputLogging\030\002 " + - "\001(\010\022\025\n\rtextSessionID\030\003 \003(\003\"U\n\020AnalyzedSe" + - "ntence\022\014\n\004text\030\001 \001(\t\0223\n\006tokens\030\002 \003(\0132#.l" + - "t_ml_server.AnalyzedTokenReadings\"k\n\025Ana" + - "lyzedTokenReadings\022-\n\010readings\030\001 \003(\0132\033.l" + - "t_ml_server.AnalyzedToken\022\021\n\tchunkTags\030\002" + - " \003(\t\022\020\n\010startPos\030\003 \001(\005\"=\n\rAnalyzedToken\022" + - "\r\n\005token\030\001 \001(\t\022\016\n\006posTag\030\002 \001(\t\022\r\n\005lemma\030" + - "\003 \001(\t\"\201\001\n\025PostProcessingRequest\022\021\n\tsente" + - "nces\030\001 \003(\t\022(\n\007matches\030\002 \003(\0132\027.lt_ml_serv" + - "er.MatchList\022\024\n\014inputLogging\030\003 \001(\010\022\025\n\rte" + - "xtSessionID\030\004 \003(\003\"N\n\014MatchRequest\022\021\n\tsen" + - "tences\030\001 \003(\t\022\024\n\014inputLogging\030\002 \001(\010\022\025\n\rte" + - "xtSessionID\030\003 \003(\003\"A\n\rMatchResponse\0220\n\017se" + - "ntenceMatches\030\001 \003(\0132\027.lt_ml_server.Match" + - "List\"1\n\tMatchList\022$\n\007matches\030\001 \003(\0132\023.lt_" + - "ml_server.Match\"\256\003\n\005Match\022\016\n\006offset\030\001 \001(" + - "\r\022\016\n\006length\030\002 \001(\r\022\n\n\002id\030\003 \001(\t\022\016\n\006sub_id\030" + - "\004 \001(\t\022\023\n\013suggestions\030\005 \003(\t\022\027\n\017ruleDescri" + - "ption\030\006 \001(\t\022\030\n\020matchDescription\030\007 \001(\t\022\035\n" + - "\025matchShortDescription\030\010 \001(\t\022\013\n\003url\030\t \001(" + - "\t\022A\n\025suggestedReplacements\030\n \003(\0132\".lt_ml" + - "_server.SuggestedReplacement\022\023\n\013autoCorr" + - "ect\030\013 \001(\010\022+\n\004type\030\014 \001(\0162\035.lt_ml_server.M" + - "atch.MatchType\022\033\n\023contextForSureMatch\030\r " + - "\001(\021\022 \n\004rule\030\016 \001(\0132\022.lt_ml_server.Rule\"1\n" + - "\tMatchType\022\017\n\013UnknownWord\020\000\022\010\n\004Hint\020\001\022\t\n" + - "\005Other\020\002\"\251\002\n\004Rule\022\022\n\nsourceFile\030\001 \001(\t\022\021\n" + - "\tissueType\030\002 \001(\t\022\017\n\007tempOff\030\003 \001(\010\022,\n\010cat" + - "egory\030\004 \001(\0132\032.lt_ml_server.RuleCategory\022" + - "\021\n\tisPremium\030\005 \001(\010\022$\n\004tags\030\006 \003(\0162\026.lt_ml" + - "_server.Rule.Tag\"\201\001\n\003Tag\022\t\n\005picky\020\000\022\014\n\010a" + - "cademic\020\001\022\013\n\007clarity\020\002\022\020\n\014professional\020\003" + - "\022\014\n\010creative\020\004\022\014\n\010customer\020\005\022\n\n\006jobapp\020\006" + - "\022\r\n\tobjective\020\007\022\013\n\007elegant\020\010\"(\n\014RuleCate" + - "gory\022\n\n\002id\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\"\342\001\n\024Sugge" + - "stedReplacement\022\023\n\013replacement\030\001 \001(\t\022\023\n\013" + - "description\030\002 \001(\t\022\016\n\006suffix\030\003 \001(\t\022\022\n\ncon" + - "fidence\030\004 \001(\002\022?\n\004type\030\005 \001(\01621.lt_ml_serv" + - "er.SuggestedReplacement.SuggestionType\";" + - "\n\016SuggestionType\022\013\n\007Default\020\000\022\017\n\013Transla" + - "tion\020\001\022\013\n\007Curated\020\0022\246\001\n\020ProcessingServer" + - "\022H\n\007Analyze\022\034.lt_ml_server.AnalyzeReques" + - "t\032\035.lt_ml_server.AnalyzeResponse\"\000\022H\n\007Pr" + - "ocess\022\034.lt_ml_server.ProcessRequest\032\035.lt" + - "_ml_server.ProcessResponse\"\0002\242\001\n\010MLServe" + - "r\022B\n\005Match\022\032.lt_ml_server.MatchRequest\032\033" + - ".lt_ml_server.MatchResponse\"\000\022R\n\rMatchAn" + - "alyzed\022\".lt_ml_server.AnalyzedMatchReque" + - "st\032\033.lt_ml_server.MatchResponse\"\0002e\n\024Pos" + - "tProcessingServer\022M\n\007Process\022#.lt_ml_ser" + - "ver.PostProcessingRequest\032\033.lt_ml_server" + - ".MatchResponse\"\000B*\n\031org.languagetool.rul" + - "es.mlB\rMLServerProtob\006proto3" + "\002 \003(\0132\023.lt_ml_server.Match\"\210\001\n\024AnalyzedM" + + "atchRequest\0221\n\tsentences\030\001 \003(\0132\036.lt_ml_s" + + "erver.AnalyzedSentence\022\024\n\014inputLogging\030\002" + + " \001(\010\022\025\n\rtextSessionID\030\003 \003(\003\022\020\n\010language\030" + + "\004 \001(\t\"U\n\020AnalyzedSentence\022\014\n\004text\030\001 \001(\t\022" + + "3\n\006tokens\030\002 \003(\0132#.lt_ml_server.AnalyzedT" + + "okenReadings\"k\n\025AnalyzedTokenReadings\022-\n" + + "\010readings\030\001 \003(\0132\033.lt_ml_server.AnalyzedT" + + "oken\022\021\n\tchunkTags\030\002 \003(\t\022\020\n\010startPos\030\003 \001(" + + "\005\"=\n\rAnalyzedToken\022\r\n\005token\030\001 \001(\t\022\016\n\006pos" + + "Tag\030\002 \001(\t\022\r\n\005lemma\030\003 \001(\t\"\201\001\n\025PostProcess" + + "ingRequest\022\021\n\tsentences\030\001 \003(\t\022(\n\007matches" + + "\030\002 \003(\0132\027.lt_ml_server.MatchList\022\024\n\014input" + + "Logging\030\003 \001(\010\022\025\n\rtextSessionID\030\004 \003(\003\"`\n\014" + + "MatchRequest\022\021\n\tsentences\030\001 \003(\t\022\024\n\014input" + + "Logging\030\002 \001(\010\022\025\n\rtextSessionID\030\003 \003(\003\022\020\n\010" + + "language\030\004 \001(\t\"A\n\rMatchResponse\0220\n\017sente" + + "nceMatches\030\001 \003(\0132\027.lt_ml_server.MatchLis" + + "t\"1\n\tMatchList\022$\n\007matches\030\001 \003(\0132\023.lt_ml_" + + "server.Match\"\256\003\n\005Match\022\016\n\006offset\030\001 \001(\r\022\016" + + "\n\006length\030\002 \001(\r\022\n\n\002id\030\003 \001(\t\022\016\n\006sub_id\030\004 \001" + + "(\t\022\023\n\013suggestions\030\005 \003(\t\022\027\n\017ruleDescripti" + + "on\030\006 \001(\t\022\030\n\020matchDescription\030\007 \001(\t\022\035\n\025ma" + + "tchShortDescription\030\010 \001(\t\022\013\n\003url\030\t \001(\t\022A" + + "\n\025suggestedReplacements\030\n \003(\0132\".lt_ml_se" + + "rver.SuggestedReplacement\022\023\n\013autoCorrect" + + "\030\013 \001(\010\022+\n\004type\030\014 \001(\0162\035.lt_ml_server.Matc" + + "h.MatchType\022\033\n\023contextForSureMatch\030\r \001(\021" + + "\022 \n\004rule\030\016 \001(\0132\022.lt_ml_server.Rule\"1\n\tMa" + + "tchType\022\017\n\013UnknownWord\020\000\022\010\n\004Hint\020\001\022\t\n\005Ot" + + "her\020\002\"\251\002\n\004Rule\022\022\n\nsourceFile\030\001 \001(\t\022\021\n\tis" + + "sueType\030\002 \001(\t\022\017\n\007tempOff\030\003 \001(\010\022,\n\010catego" + + "ry\030\004 \001(\0132\032.lt_ml_server.RuleCategory\022\021\n\t" + + "isPremium\030\005 \001(\010\022$\n\004tags\030\006 \003(\0162\026.lt_ml_se" + + "rver.Rule.Tag\"\201\001\n\003Tag\022\t\n\005picky\020\000\022\014\n\010acad" + + "emic\020\001\022\013\n\007clarity\020\002\022\020\n\014professional\020\003\022\014\n" + + "\010creative\020\004\022\014\n\010customer\020\005\022\n\n\006jobapp\020\006\022\r\n" + + "\tobjective\020\007\022\013\n\007elegant\020\010\"(\n\014RuleCategor" + + "y\022\n\n\002id\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\"\342\001\n\024Suggeste" + + "dReplacement\022\023\n\013replacement\030\001 \001(\t\022\023\n\013des" + + "cription\030\002 \001(\t\022\016\n\006suffix\030\003 \001(\t\022\022\n\nconfid" + + "ence\030\004 \001(\002\022?\n\004type\030\005 \001(\01621.lt_ml_server." + + "SuggestedReplacement.SuggestionType\";\n\016S" + + "uggestionType\022\013\n\007Default\020\000\022\017\n\013Translatio" + + "n\020\001\022\013\n\007Curated\020\0022\246\001\n\020ProcessingServer\022H\n" + + "\007Analyze\022\034.lt_ml_server.AnalyzeRequest\032\035" + + ".lt_ml_server.AnalyzeResponse\"\000\022H\n\007Proce" + + "ss\022\034.lt_ml_server.ProcessRequest\032\035.lt_ml" + + "_server.ProcessResponse\"\0002\242\001\n\010MLServer\022B" + + "\n\005Match\022\032.lt_ml_server.MatchRequest\032\033.lt" + + "_ml_server.MatchResponse\"\000\022R\n\rMatchAnaly" + + "zed\022\".lt_ml_server.AnalyzedMatchRequest\032" + + "\033.lt_ml_server.MatchResponse\"\0002e\n\024PostPr" + + "ocessingServer\022M\n\007Process\022#.lt_ml_server" + + ".PostProcessingRequest\032\033.lt_ml_server.Ma" + + "tchResponse\"\000B*\n\031org.languagetool.rules." + + "mlB\rMLServerProtob\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -20502,7 +20875,7 @@ public org.languagetool.rules.ml.MLServerProto.SuggestedReplacement getDefaultIn internal_static_lt_ml_server_AnalyzedMatchRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_lt_ml_server_AnalyzedMatchRequest_descriptor, - new java.lang.String[] { "Sentences", "InputLogging", "TextSessionID", }); + new java.lang.String[] { "Sentences", "InputLogging", "TextSessionID", "Language", }); internal_static_lt_ml_server_AnalyzedSentence_descriptor = getDescriptor().getMessageTypes().get(6); internal_static_lt_ml_server_AnalyzedSentence_fieldAccessorTable = new @@ -20532,7 +20905,7 @@ public org.languagetool.rules.ml.MLServerProto.SuggestedReplacement getDefaultIn internal_static_lt_ml_server_MatchRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_lt_ml_server_MatchRequest_descriptor, - new java.lang.String[] { "Sentences", "InputLogging", "TextSessionID", }); + new java.lang.String[] { "Sentences", "InputLogging", "TextSessionID", "Language", }); internal_static_lt_ml_server_MatchResponse_descriptor = getDescriptor().getMessageTypes().get(11); internal_static_lt_ml_server_MatchResponse_fieldAccessorTable = new diff --git a/languagetool-core/src/main/java/org/languagetool/rules/ml/PostProcessingServerGrpc.java b/languagetool-core/src/main/java/org/languagetool/rules/ml/PostProcessingServerGrpc.java index 735fec6bcd69..29656355fcba 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/ml/PostProcessingServerGrpc.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/ml/PostProcessingServerGrpc.java @@ -8,7 +8,7 @@ * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.50.2)", + value = "by gRPC proto compiler (version 1.56.1)", comments = "Source: ml_server.proto") @io.grpc.stub.annotations.GrpcGenerated public final class PostProcessingServerGrpc { @@ -98,34 +98,38 @@ public PostProcessingServerFutureStub newStub(io.grpc.Channel channel, io.grpc.C * for e.g. resorting suggestions * */ - public static abstract class PostProcessingServerImplBase implements io.grpc.BindableService { + public interface AsyncService { /** */ - public void process(org.languagetool.rules.ml.MLServerProto.PostProcessingRequest request, + default void process(org.languagetool.rules.ml.MLServerProto.PostProcessingRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getProcessMethod(), responseObserver); } + } + + /** + * Base class for the server implementation of the service PostProcessingServer. + *
+   * for e.g. resorting suggestions
+   * 
+ */ + public static abstract class PostProcessingServerImplBase + implements io.grpc.BindableService, AsyncService { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getProcessMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.rules.ml.MLServerProto.PostProcessingRequest, - org.languagetool.rules.ml.MLServerProto.MatchResponse>( - this, METHODID_PROCESS))) - .build(); + return PostProcessingServerGrpc.bindService(this); } } /** + * A stub to allow clients to do asynchronous rpc calls to service PostProcessingServer. *
    * for e.g. resorting suggestions
    * 
*/ - public static final class PostProcessingServerStub extends io.grpc.stub.AbstractAsyncStub { + public static final class PostProcessingServerStub + extends io.grpc.stub.AbstractAsyncStub { private PostProcessingServerStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -147,11 +151,13 @@ public void process(org.languagetool.rules.ml.MLServerProto.PostProcessingReques } /** + * A stub to allow clients to do synchronous rpc calls to service PostProcessingServer. *
    * for e.g. resorting suggestions
    * 
*/ - public static final class PostProcessingServerBlockingStub extends io.grpc.stub.AbstractBlockingStub { + public static final class PostProcessingServerBlockingStub + extends io.grpc.stub.AbstractBlockingStub { private PostProcessingServerBlockingStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -172,11 +178,13 @@ public org.languagetool.rules.ml.MLServerProto.MatchResponse process(org.languag } /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service PostProcessingServer. *
    * for e.g. resorting suggestions
    * 
*/ - public static final class PostProcessingServerFutureStub extends io.grpc.stub.AbstractFutureStub { + public static final class PostProcessingServerFutureStub + extends io.grpc.stub.AbstractFutureStub { private PostProcessingServerFutureStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -204,10 +212,10 @@ private static final class MethodHandlers implements io.grpc.stub.ServerCalls.ServerStreamingMethod, io.grpc.stub.ServerCalls.ClientStreamingMethod, io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final PostProcessingServerImplBase serviceImpl; + private final AsyncService serviceImpl; private final int methodId; - MethodHandlers(PostProcessingServerImplBase serviceImpl, int methodId) { + MethodHandlers(AsyncService serviceImpl, int methodId) { this.serviceImpl = serviceImpl; this.methodId = methodId; } @@ -236,6 +244,18 @@ public io.grpc.stub.StreamObserver invoke( } } + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getProcessMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.rules.ml.MLServerProto.PostProcessingRequest, + org.languagetool.rules.ml.MLServerProto.MatchResponse>( + service, METHODID_PROCESS))) + .build(); + } + private static abstract class PostProcessingServerBaseDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { PostProcessingServerBaseDescriptorSupplier() {} diff --git a/languagetool-core/src/main/java/org/languagetool/rules/ml/ProcessingServerGrpc.java b/languagetool-core/src/main/java/org/languagetool/rules/ml/ProcessingServerGrpc.java index 3572cb260cac..5697fb95a197 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/ml/ProcessingServerGrpc.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/ml/ProcessingServerGrpc.java @@ -5,7 +5,7 @@ /** */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.50.2)", + value = "by gRPC proto compiler (version 1.56.1)", comments = "Source: ml_server.proto") @io.grpc.stub.annotations.GrpcGenerated public final class ProcessingServerGrpc { @@ -123,45 +123,39 @@ public ProcessingServerFutureStub newStub(io.grpc.Channel channel, io.grpc.CallO /** */ - public static abstract class ProcessingServerImplBase implements io.grpc.BindableService { + public interface AsyncService { /** */ - public void analyze(org.languagetool.rules.ml.MLServerProto.AnalyzeRequest request, + default void analyze(org.languagetool.rules.ml.MLServerProto.AnalyzeRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getAnalyzeMethod(), responseObserver); } /** */ - public void process(org.languagetool.rules.ml.MLServerProto.ProcessRequest request, + default void process(org.languagetool.rules.ml.MLServerProto.ProcessRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getProcessMethod(), responseObserver); } + } + + /** + * Base class for the server implementation of the service ProcessingServer. + */ + public static abstract class ProcessingServerImplBase + implements io.grpc.BindableService, AsyncService { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getAnalyzeMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.rules.ml.MLServerProto.AnalyzeRequest, - org.languagetool.rules.ml.MLServerProto.AnalyzeResponse>( - this, METHODID_ANALYZE))) - .addMethod( - getProcessMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - org.languagetool.rules.ml.MLServerProto.ProcessRequest, - org.languagetool.rules.ml.MLServerProto.ProcessResponse>( - this, METHODID_PROCESS))) - .build(); + return ProcessingServerGrpc.bindService(this); } } /** + * A stub to allow clients to do asynchronous rpc calls to service ProcessingServer. */ - public static final class ProcessingServerStub extends io.grpc.stub.AbstractAsyncStub { + public static final class ProcessingServerStub + extends io.grpc.stub.AbstractAsyncStub { private ProcessingServerStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -191,8 +185,10 @@ public void process(org.languagetool.rules.ml.MLServerProto.ProcessRequest reque } /** + * A stub to allow clients to do synchronous rpc calls to service ProcessingServer. */ - public static final class ProcessingServerBlockingStub extends io.grpc.stub.AbstractBlockingStub { + public static final class ProcessingServerBlockingStub + extends io.grpc.stub.AbstractBlockingStub { private ProcessingServerBlockingStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -220,8 +216,10 @@ public org.languagetool.rules.ml.MLServerProto.ProcessResponse process(org.langu } /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service ProcessingServer. */ - public static final class ProcessingServerFutureStub extends io.grpc.stub.AbstractFutureStub { + public static final class ProcessingServerFutureStub + extends io.grpc.stub.AbstractFutureStub { private ProcessingServerFutureStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); @@ -258,10 +256,10 @@ private static final class MethodHandlers implements io.grpc.stub.ServerCalls.ServerStreamingMethod, io.grpc.stub.ServerCalls.ClientStreamingMethod, io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final ProcessingServerImplBase serviceImpl; + private final AsyncService serviceImpl; private final int methodId; - MethodHandlers(ProcessingServerImplBase serviceImpl, int methodId) { + MethodHandlers(AsyncService serviceImpl, int methodId) { this.serviceImpl = serviceImpl; this.methodId = methodId; } @@ -294,6 +292,25 @@ public io.grpc.stub.StreamObserver invoke( } } + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getAnalyzeMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.rules.ml.MLServerProto.AnalyzeRequest, + org.languagetool.rules.ml.MLServerProto.AnalyzeResponse>( + service, METHODID_ANALYZE))) + .addMethod( + getProcessMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.languagetool.rules.ml.MLServerProto.ProcessRequest, + org.languagetool.rules.ml.MLServerProto.ProcessResponse>( + service, METHODID_PROCESS))) + .build(); + } + private static abstract class ProcessingServerBaseDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { ProcessingServerBaseDescriptorSupplier() {} diff --git a/languagetool-core/src/main/proto/ml_server.proto b/languagetool-core/src/main/proto/ml_server.proto index 8c5d51d685b4..9ac2670257ed 100644 --- a/languagetool-core/src/main/proto/ml_server.proto +++ b/languagetool-core/src/main/proto/ml_server.proto @@ -59,6 +59,7 @@ message AnalyzedMatchRequest { repeated AnalyzedSentence sentences = 1; bool inputLogging = 2; // allow logging of input on error repeated int64 textSessionID = 3; // session ID, for partial rollout & A/B tests + string language = 4; // language code (with region/country) of text being handled } message AnalyzedSentence { @@ -94,6 +95,7 @@ message MatchRequest { repeated string sentences = 1; // input text to be analyzed bool inputLogging = 2; // allow logging of input on error repeated int64 textSessionID = 3; // session ID, for partial rollout & A/B tests + string language = 4; // language code (with region/country) of text being handled } message MatchResponse {