1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
14 goog.provide('i18n.input.chrome.inputview.Covariance');
16 goog.require('i18n.input.chrome.inputview.elements.ElementType');
19 goog.scope(function() {
20 var ElementType = i18n.input.chrome.inputview.elements.ElementType;
25 * The covariance used for gaussian model.
29 i18n.input.chrome.inputview.Covariance = function() {
30 /** @private {number} */
33 var Covariance = i18n.input.chrome.inputview.Covariance;
37 * The break-down for covariance.
41 Covariance.BreakDown = {
51 * @type {!Object.<ElementType, number>}
53 Covariance.ElementTypeMap = goog.object.create(
54 ElementType.CHARACTER_KEY, 0,
55 ElementType.COMPACT_KEY, 1
61 * Key: the break down value.
62 * Value: A list - first is the covariance for full keyboard, second is for
65 * @private {!Object.<!Array.<number>>}
80 * Updates the covariance.
82 * @param {boolean} isWideScreen .
83 * @param {boolean} isHorizontal .
84 * @param {boolean} isA11y .
86 Covariance.prototype.update = function(isWideScreen, isHorizontal, isA11y) {
89 this.breakDown_ |= Covariance.BreakDown.WIDE_SCREEN;
92 this.breakDown_ |= Covariance.BreakDown.HORIZONTAL;
95 this.breakDown_ |= Covariance.BreakDown.A11Y;
101 * Gets the covariance value.
103 * @param {ElementType} type .
105 Covariance.prototype.getValue = function(type) {
106 var index = Covariance.ElementTypeMap[type];
107 return Covariance.VALUE_[this.breakDown_][index];