// Copyright 2010-2020, 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_history_predictor;

message UserHistory {
  message NextEntry {
    // Just store the Fingerprint32(key + "\t" + value)
    // |entry| is used as the key of LRU cache
    optional uint32 entry_fp = 1 [default = 0];
  }

  message Entry {
    optional string key = 1 [default = ""];
    optional string value = 2 [default = ""];
    optional string description = 6 [default = ""];

    // how many times the candidate is selected via suggestion
    optional uint32 suggestion_freq = 3 [default = 0];

    // how many times the candidate is selected via conversion
    optional uint32 conversion_freq = 5 [default = 0];

    optional uint64 last_access_time = 4 [default = 0];

    // list entries which were input just after this entry.
    repeated NextEntry next_entries = 7;

    // internally used in UserHistoryPredictor.
    optional bool bigram_boost = 20 [default = false];

    // internally used in UserHistoryPredictor.
    optional bool spelling_correction = 21 [default = false];

    // This entry is removed.
    optional bool removed = 8 [default = false];

    enum EntryType {
      DEFAULT_ENTRY = 0;
      CLEAN_ALL_EVENT = 1;
      CLEAN_UNUSED_EVENT = 2;
    }

    optional EntryType entry_type = 9 [default = DEFAULT_ENTRY];
  }

  repeated Entry entries = 6;
}
