Search in sources :

Example 1 with SentenceAnalysisProto

use of zemberek.proto.morphology.SentenceAnalysisProto in project zemberek-nlp by ahmetaa.

the class TestClient method main.

public static void main(String[] args) {
    ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", ZemberekGrpcServer.DEFAULT_PORT).usePlaintext().build();
    MorphologyServiceBlockingStub analysisService = MorphologyServiceGrpc.newBlockingStub(channel);
    LanguageIdServiceBlockingStub languageIdServiceBlockingStub = LanguageIdServiceGrpc.newBlockingStub(channel);
    PreprocessingServiceBlockingStub preprocessingServiceBlockingStub = PreprocessingServiceGrpc.newBlockingStub(channel);
    NormalizationServiceBlockingStub normalizationServiceBlockingStub = NormalizationServiceGrpc.newBlockingStub(channel);
    Log.info("----- Word Morphological Analysis ------------ ");
    String input = "tapirler";
    WordAnalysisProto response = analysisService.analyzeWord(WordAnalysisRequest.newBuilder().setInput(input).build());
    Log.info("Input: " + input);
    Log.info("Response: " + response);
    Log.info("----- Sentence Morphological Analysis ------------ ");
    String sentence = "Ali Kaan okula gitti mi?";
    SentenceAnalysisProto sResponse = analysisService.analyzeSentence(SentenceAnalysisRequest.newBuilder().setInput(sentence).build());
    Log.info("Input: " + sentence);
    Log.info("Response: " + sResponse);
    Log.info("----- Language Identification ------------ ");
    String langIdInput = "Merhaba dünya";
    LanguageIdResponse langIdResponse = languageIdServiceBlockingStub.detect(LanguageIdRequest.newBuilder().setInput(langIdInput).build());
    Log.info("Input: " + langIdInput);
    Log.info("Response: " + langIdResponse.getLangId());
    Log.info("----- Tokenization ------------ ");
    String tokenizationInput = "Saat, 12:00.";
    TokenizationResponse tokenizationResponse = preprocessingServiceBlockingStub.tokenize(TokenizationRequest.newBuilder().setInput(tokenizationInput).setIncludeTokenBoundaries(true).build());
    Log.info("Input: " + tokenizationInput);
    Log.info(tokenizationResponse);
    Log.info("----- Sentence Extraction ------------ ");
    String sentenceExtractionInput = "Merhaba! Bugün 2. köprü Fsm.'de trafik vardı.değil mi?";
    SentenceExtractionResponse sentenceExtractionResponse = preprocessingServiceBlockingStub.extractSentences(SentenceExtractionRequest.newBuilder().setDocument(sentenceExtractionInput).build());
    Log.info("Input: " + sentenceExtractionInput);
    sentenceExtractionResponse.getSentencesList().forEach(Log::info);
    Log.info("----- Normalization ------------ ");
    String normalizationiInput = "Merhab ben Zemberk.";
    NormalizationResponse normalizationResponse = normalizationServiceBlockingStub.normalize(NormalizationRequest.newBuilder().setInput(normalizationiInput).build());
    Log.info("Input: " + normalizationiInput);
    Log.info("Response: " + normalizationResponse.getNormalizedInput());
}
Also used : LanguageIdResponse(zemberek.proto.LanguageIdResponse) NormalizationResponse(zemberek.proto.NormalizationResponse) Log(zemberek.core.logging.Log) SentenceExtractionResponse(zemberek.proto.SentenceExtractionResponse) LanguageIdServiceBlockingStub(zemberek.proto.LanguageIdServiceGrpc.LanguageIdServiceBlockingStub) WordAnalysisProto(zemberek.proto.morphology.WordAnalysisProto) TokenizationResponse(zemberek.proto.TokenizationResponse) NormalizationServiceBlockingStub(zemberek.proto.NormalizationServiceGrpc.NormalizationServiceBlockingStub) ManagedChannel(io.grpc.ManagedChannel) SentenceAnalysisProto(zemberek.proto.morphology.SentenceAnalysisProto) PreprocessingServiceBlockingStub(zemberek.proto.PreprocessingServiceGrpc.PreprocessingServiceBlockingStub) MorphologyServiceBlockingStub(zemberek.proto.morphology.MorphologyServiceGrpc.MorphologyServiceBlockingStub)

Aggregations

ManagedChannel (io.grpc.ManagedChannel)1 Log (zemberek.core.logging.Log)1 LanguageIdResponse (zemberek.proto.LanguageIdResponse)1 LanguageIdServiceBlockingStub (zemberek.proto.LanguageIdServiceGrpc.LanguageIdServiceBlockingStub)1 NormalizationResponse (zemberek.proto.NormalizationResponse)1 NormalizationServiceBlockingStub (zemberek.proto.NormalizationServiceGrpc.NormalizationServiceBlockingStub)1 PreprocessingServiceBlockingStub (zemberek.proto.PreprocessingServiceGrpc.PreprocessingServiceBlockingStub)1 SentenceExtractionResponse (zemberek.proto.SentenceExtractionResponse)1 TokenizationResponse (zemberek.proto.TokenizationResponse)1 MorphologyServiceBlockingStub (zemberek.proto.morphology.MorphologyServiceGrpc.MorphologyServiceBlockingStub)1 SentenceAnalysisProto (zemberek.proto.morphology.SentenceAnalysisProto)1 WordAnalysisProto (zemberek.proto.morphology.WordAnalysisProto)1