// Copyright 2010-2021, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto2";

package mozc.user_dictionary;

option java_outer_classname = "ProtoUserDictionaryStorage";
option java_package = "org.mozc.android.inputmethod.japanese.protobuf";

message UserDictionary {
  // LINT.IfChange
  enum PosType {
    // Use this when the POS tag is not provided or unknown.
    NO_POS = 0;  // "品詞なし"

    NOUN = 1;                            // "名詞"
    ABBREVIATION = 2;                    // "短縮よみ"
    SUGGESTION_ONLY = 3;                 // "サジェストのみ"
    PROPER_NOUN = 4;                     // "固有名詞"
    PERSONAL_NAME = 5;                   // "人名"
    FAMILY_NAME = 6;                     // "姓"
    FIRST_NAME = 7;                      // "名"
    ORGANIZATION_NAME = 8;               // "組織"
    PLACE_NAME = 9;                      // "地名"
    SA_IRREGULAR_CONJUGATION_NOUN = 10;  // "名詞サ変"
    ADJECTIVE_VERBAL_NOUN = 11;          // "名詞形動"
    NUMBER = 12;                         // "数"
    ALPHABET = 13;                       // "アルファベット"
    SYMBOL = 14;                         // "記号"
    EMOTICON = 15;                       // "顔文字"

    ADVERB = 16;              // "副詞"
    PRENOUN_ADJECTIVAL = 17;  // "連体詞"
    CONJUNCTION = 18;         // "接続詞"
    INTERJECTION = 19;        // "感動詞"

    PREFIX = 20;              // "接頭語"
    COUNTER_SUFFIX = 21;      // "助数詞"
    GENERIC_SUFFIX = 22;      // "接尾一般"
    PERSON_NAME_SUFFIX = 23;  // "接尾人名"
    PLACE_NAME_SUFFIX = 24;   // "接尾地名"

    WA_GROUP1_VERB = 25;    // "動詞ワ行五段"
    KA_GROUP1_VERB = 26;    // "動詞カ行五段"
    SA_GROUP1_VERB = 27;    // "動詞サ行五段"
    TA_GROUP1_VERB = 28;    // "動詞タ行五段"
    NA_GROUP1_VERB = 29;    // "動詞ナ行五段"
    MA_GROUP1_VERB = 30;    // "動詞マ行五段"
    RA_GROUP1_VERB = 31;    // "動詞ラ行五段"
    GA_GROUP1_VERB = 32;    // "動詞ガ行五段"
    BA_GROUP1_VERB = 33;    // "動詞バ行五段"
    HA_GROUP1_VERB = 34;    // "動詞ハ行四段"
    GROUP2_VERB = 35;       // "動詞一段"
    KURU_GROUP3_VERB = 36;  // "動詞カ変"
    SURU_GROUP3_VERB = 37;  // "動詞サ変"
    ZURU_GROUP3_VERB = 38;  // "動詞ザ変"
    RU_GROUP3_VERB = 39;    // "動詞ラ変"

    ADJECTIVE = 40;                 // "形容詞"
    SENTENCE_ENDING_PARTICLE = 41;  // "終助詞"
    PUNCTUATION = 42;               // "句読点"
    FREE_STANDING_WORD = 43;        // "独立語"

    SUPPRESSION_WORD = 44;  // "抑制単語"
  }
  // LINT.ThenChange(
  //     dictionary/user_dictionary_util.cc
  // )
  // ID of this dictionary
  optional uint64 id = 1 [default = 0, jstype = JS_STRING];

  reserved 2;  // deprecated enabled

  // name of dictionary
  optional string name = 3 [default = ""];

  // entry of each word
  message Entry {
    optional string key = 1 [default = ""];
    optional string value = 2 [default = ""];
    // Do NOT use tag number '3' in this proto. Please see below.
    reserved 3;  // Deprecated pos
    optional string comment = 4 [default = ""];

    // Historically we used to use tag number '3' for POS in string format.
    // In order to switch it to enum based POS, we removed (deprecated) the
    // tag number '3' field and created another field numbered '5'.
    // Historically the default POS tag was NOUN, and "NO_POS" is added later.
    // In order to preserve the original default behavior, default POS tag is
    // explicitly specified as NOUN. However, this can be changed if there is no
    // problem with "NO_POS".
    optional PosType pos = 5 [default = NOUN];

    // In multilingual settings, Gboard's personal dictionary will feed entries
    // with locale information. We can change the behavior (filter or demote)
    // The locale is usually formatted in BCP47.
    // In TSV format, the locale is encoded in the POS field as `pos:locale`
    // "名詞:ja".
    optional string locale = 12 [default = ""];

    reserved 10;  // deprecated removed
    reserved 11;  // deprecated auto_registered
  }

  repeated Entry entries = 4;

  reserved 5;  // deprecated removed
  reserved 6;  // deprecated syncable
}

message UserDictionaryStorage {
  // version of user dictionary
  optional int32 version = 1 [default = 0];

  // dictionary body
  repeated UserDictionary dictionaries = 2;

  reserved 10;  // deprecated storage_type
}

message UserDictionaryImportData {
  optional string dictionary_name = 1;
  optional string data = 2;  // TSV data.
}
