syntax = "proto3";

option java_package = "zemberek.proto.morphology";
option java_multiple_files = true;

package zemberek.morphology;

// Morphological analysis request for a single word.
message WordAnalysisRequest {
  string input = 1;
}

// A dictionary item. Lemma and pos values are provided.
// TODO: POS values should be enums.
message DictionaryItemProto {
  string lemma = 1;
  string primaryPos = 2;
  string secondaryPos = 3;
}

// represents a single morphological analysis result.
message SingleAnalysisProto {
  // Defines the POS of the whole word.
  string pos = 1;
  // root word's dictionary information (contains lemma and pos values.)
  DictionaryItemProto dictionaryItem = 2;
  // This is the long formatted analysis string.
  string analysis = 3;
  // [true] if this analysis contain informal morphemes.
  bool informal = 4;
  // [true] if this root form of the input does not exist in dictionary.
  bool runtime = 5;
  // all lemma values. Such as for input "kapattırdım" -> ["kapat","kapattır"]
  repeated string lemmas = 6;
  // all morpheme information.
  repeated MorphemeDataProto morphemes = 7;
}

// Contains surface form and id of the morpheme.
// Like surface = "acak", morpheme = Fut
message MorphemeDataProto {
  string surface = 1;
  string morpheme = 2;
}

// Contains all analyses of a word.
message WordAnalysisProto {
  // input word.
  string input = 1;
  repeated SingleAnalysisProto analyses = 2;
}

// Sentence analysis request.
message SentenceAnalysisRequest {
  // sentence string
  string input = 1;
  // if [true], all analyses of all tokens will be included in the response
  // else, only the best analysis will be used.
  bool containAllAnalyses =2;
}

message SentenceAnalysisProto {
  // input sentence
  string input = 1;
  // for each token, result best morphological analysis and if requested, all
  // analyses.
  repeated SentenceWordAnalysisProto results = 2;
}

// After disambiguation, a SentenceWordAnalysis_P object per use is used.
message SentenceWordAnalysisProto {
  string token = 1;
  SingleAnalysisProto best = 2;
  WordAnalysisProto all = 3;
}

service MorphologyService {
  rpc AnalyzeSentence (SentenceAnalysisRequest) returns (SentenceAnalysisProto);
  rpc AnalyzeWord (WordAnalysisRequest) returns (WordAnalysisProto);
}
