1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Semantic attributes of Math symbols and expressions.
8 * This file contains the basic functionality to lookup and assign semantic
9 * attributes for mathematical expressions. Since there is no such thing as a
10 * well-defined semantics for all of mathematics we compute a default semantics
11 * that closely models mathematical expressions found in K-12 mathematics as
12 * well as in general undergraduate curriculum (i.e., calculus, linear algebra,
15 * Currently semantic attributes of symbols consist of the following two parts:
17 * type -- An unmutable property of an expression, regardless of its position in
18 * the math expression. For example, the letter 'f' will always have the
19 * type identifier, regardless of its use in context, e.g. as function
22 * role -- A mutable description of the role an expression plays in the context
23 * of the overall mathematical expression. For instance, the symbol '|'
24 * is of type punctuation, but depending on context it has the role of a
25 * neutral fence or of a single vertical bar.
27 * In addition for some symbols we record the font as a further attribute.
29 * When a semantically interpreted expression is transformed into a XML
30 * representation, types become tag names, while role, font, etc. are added as
33 * This file is part of the content script as we do not want to call out to the
34 * background page every time we need to look up the semantic of a symbol.
36 * TODO (sorge) Move semantic tree translation into the background page
41 goog.provide('cvox.SemanticAttr');
43 goog.require('cvox.SemanticUtil');
47 * Contains the basic mappings of characters/symbols and functions to semantic
50 * Observe that all characters are given as hex code number in order to ease the
51 * comparison with those in the JSON files that define speech rules per
55 cvox.SemanticAttr = function() {
56 // Punctuation Characters.
58 * @type {Array<string>}
60 this.generalPunctuations =
62 '!', '"', '#', '%', '&', '\'', '*', ',', ':', ';', '?', '@', '\\',
63 '¡', '§', '¶', '·', '¿', '‗', '†', '‡', '•', '‣', '․', '‥', '‧',
64 '‰', '‱', '‸', '※', '‼', '‽', '‾', '⁁', '⁂', '⁃', '⁇', '⁈', '⁉',
65 '⁋', '⁌', '⁍', '⁎', '⁏', '⁐', '⁑', '⁓', '⁕', '⁖', '⁘', '⁙', '⁚',
66 '⁛', '⁜', '⁝', '⁞', '︐', '︓', '︔', '︕', '︖', '︰', '﹅', '﹆',
67 '﹉', '﹊', '﹋', '﹌', '﹐', '﹔', '﹕', '﹖', '﹗', '﹟', '﹠', '﹡', '﹨',
68 '﹪', '﹫', '!', '"', '#', '%', '&', ''', '*', ',', '/', ':',
75 this.invisibleComma_ = cvox.SemanticUtil.numberToUnicode(0x2063);
76 this.generalPunctuations.push(this.invisibleComma_);
78 * @type {Array<string>}
82 '…', '⋮', '⋯', '⋰', '⋱', '︙'
85 * @type {Array<string>}
92 * @type {Array<string>}
96 '‒', '–', '—', '―', '〜', '︱', '︲', '﹘'
99 * @type {Array<string>}
103 '′', '″', '‴', '‵', '‶', '‷', '⁗'
107 // Fences are treated slightly differently from other symbols as we want to
108 // record pairs of opening/closing and top/bottom fences.
110 * Mapping opening to closing fences.
111 * @type {Object<string>}
113 this.openClosePairs =
115 // Unicode categories Ps and Pe.
116 // Observe that left quotation 301D could also be matched to 301F,
117 // but is currently matched to 301E.
118 '(': ')', '[': ']', '{': '}', '⁅': '⁆', '〈': '〉', '❨': '❩',
119 '❪': '❫', '❬': '❭', '❮': '❯', '❰': '❱', '❲': '❳', '❴': '❵',
120 '⟅': '⟆', '⟦': '⟧', '⟨': '⟩', '⟪': '⟫', '⟬': '⟭', '⟮': '⟯',
121 '⦃': '⦄', '⦅': '⦆', '⦇': '⦈', '⦉': '⦊', '⦋': '⦌', '⦍': '⦎',
122 '⦏': '⦐', '⦑': '⦒', '⦓': '⦔', '⦕': '⦖', '⦗': '⦘', '⧘': '⧙',
123 '⧚': '⧛', '⧼': '⧽', '⸢': '⸣', '⸤': '⸥', '⸦': '⸧', '⸨': '⸩',
124 '〈': '〉', '《': '》', '「': '」', '『': '』', '【': '】',
125 '〔': '〕', '〖': '〗', '〘': '〙', '〚': '〛', '〝': '〞',
126 '﴾': '﴿', '︗': '︘', '﹙': '﹚', '﹛': '﹜', '﹝': '﹞', '(': ')',
127 '[': ']', '{': '}', '⦅': '⦆', '「': '」',
128 // Unicode categories Sm and So.
129 '⌈': '⌉', '⌊': '⌋', '⌌': '⌍', '⌎': '⌏', '⌜': '⌝', '⌞': '⌟',
132 '⎛': '⎞', '⎜': '⎟', '⎝': '⎠',
134 '⎡': '⎤', '⎢': '⎥', '⎣': '⎦',
136 '⎧': '⎫', '⎨': '⎬', '⎩': '⎭', '⎰': '⎱', '⎸': '⎹'
139 * Mapping top to bottom fences.
140 * @type {Object<string>}
142 this.topBottomPairs =
144 '⎴': '⎵', '⏜': '⏝', '⏞': '⏟', '⏠': '⏡', '︵': '︶', '︷': '︸',
145 '︹': '︺', '︻': '︼', '︽': '︾', '︿': '﹀', '﹁': '﹂',
149 * @type {Array<string>}
151 this.leftFences = cvox.SemanticUtil.objectsToKeys(this.openClosePairs);
153 * @type {Array<string>}
155 this.rightFences = cvox.SemanticUtil.objectsToValues(this.openClosePairs);
156 this.rightFences.push('〟');
158 * @type {Array<string>}
160 this.topFences = cvox.SemanticUtil.objectsToKeys(this.topBottomPairs);
162 * @type {Array<string>}
164 this.bottomFences = cvox.SemanticUtil.objectsToValues(this.topBottomPairs);
166 * @type {Array<string>}
170 '|', '¦', '‖', '❘', '⦀', '⫴', '¦', '|'
172 /** Array of all fences.
173 * @type {Array<string>}
175 this.fences = this.neutralFences.concat(
176 this.leftFences, this.rightFences, this.topFences, this.bottomFences);
181 * @type {Array<string>}
185 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
186 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
189 * @type {Array<string>}
193 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
194 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
199 * @type {Array<string>}
201 this.capitalLatinFullWidth =
203 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
204 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
207 * @type {Array<string>}
209 this.smallLatinFullWidth =
211 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
212 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
215 * @type {Array<string>}
217 this.capitalLatinBold =
219 '𝐀', '𝐁', '𝐂', '𝐃', '𝐄', '𝐅', '𝐆', '𝐇', '𝐈', '𝐉', '𝐊', '𝐋', '𝐌',
220 '𝐍', '𝐎', '𝐏', '𝐐', '𝐑', '𝐒', '𝐓', '𝐔', '𝐕', '𝐖', '𝐗', '𝐘', '𝐙'
223 * @type {Array<string>}
225 this.smallLatinBold =
227 '𝐚', '𝐛', '𝐜', '𝐝', '𝐞', '𝐟', '𝐠', '𝐡', '𝐢', '𝐣', '𝐤', '𝐥', '𝐦',
228 '𝐧', '𝐨', '𝐩', '𝐪', '𝐫', '𝐬', '𝐭', '𝐮', '𝐯', '𝐰', '𝐱', '𝐲', '𝐳'
231 * @type {Array<string>}
233 this.capitalLatinItalic =
235 '𝐴', '𝐵', '𝐶', '𝐷', '𝐸', '𝐹', '𝐺', '𝐻', '𝐼', '𝐽', '𝐾', '𝐿', '𝑀',
236 '𝑁', '𝑂', '𝑃', '𝑄', '𝑅', '𝑆', '𝑇', '𝑈', '𝑉', '𝑊', '𝑋', '𝑌', '𝑍'
239 * @type {Array<string>}
241 this.smallLatinItalic =
243 '𝑎', '𝑏', '𝑐', '𝑑', '𝑒', '𝑓', '𝑔', 'ℎ', '𝑖', '𝑗', '𝑘', '𝑙', '𝑚',
244 '𝑛', '𝑜', '𝑝', '𝑞', '𝑟', '𝑠', '𝑡', '𝑢', '𝑣', '𝑤', '𝑥', '𝑦', '𝑧',
249 * @type {Array<string>}
251 this.capitalLatinScript =
253 '𝒜', 'ℬ', '𝒞', '𝒟', 'ℰ', 'ℱ', '𝒢', 'ℋ', 'ℐ', '𝒥', '𝒦', 'ℒ', 'ℳ',
254 '𝒩', '𝒪', '𝒫', '𝒬', 'ℛ', '𝒮', '𝒯', '𝒰', '𝒱', '𝒲', '𝒳', '𝒴', '𝒵',
259 * @type {Array<string>}
261 this.smallLatinScript =
263 '𝒶', '𝒷', '𝒸', '𝒹', 'ℯ', '𝒻', 'ℊ', '𝒽', '𝒾', '𝒿', '𝓀', '𝓁', '𝓂',
264 '𝓃', 'ℴ', '𝓅', '𝓆', '𝓇', '𝓈', '𝓉', '𝓊', '𝓋', '𝓌', '𝓍', '𝓎', '𝓏',
269 * @type {Array<string>}
271 this.capitalLatinBoldScript =
273 '𝓐', '𝓑', '𝓒', '𝓓', '𝓔', '𝓕', '𝓖', '𝓗', '𝓘', '𝓙', '𝓚', '𝓛', '𝓜',
274 '𝓝', '𝓞', '𝓟', '𝓠', '𝓡', '𝓢', '𝓣', '𝓤', '𝓥', '𝓦', '𝓧', '𝓨', '𝓩'
277 * @type {Array<string>}
279 this.smallLatinBoldScript =
281 '𝓪', '𝓫', '𝓬', '𝓭', '𝓮', '𝓯', '𝓰', '𝓱', '𝓲', '𝓳', '𝓴', '𝓵', '𝓶',
282 '𝓷', '𝓸', '𝓹', '𝓺', '𝓻', '𝓼', '𝓽', '𝓾', '𝓿', '𝔀', '𝔁', '𝔂', '𝔃'
285 * @type {Array<string>}
287 this.capitalLatinFraktur =
289 '𝔄', '𝔅', 'ℭ', '𝔇', '𝔈', '𝔉', '𝔊', 'ℌ', 'ℑ', '𝔍', '𝔎', '𝔏', '𝔐',
290 '𝔑', '𝔒', '𝔓', '𝔔', 'ℜ', '𝔖', '𝔗', '𝔘', '𝔙', '𝔚', '𝔛', '𝔜', 'ℨ'
293 * @type {Array<string>}
295 this.smallLatinFraktur =
297 '𝔞', '𝔟', '𝔠', '𝔡', '𝔢', '𝔣', '𝔤', '𝔥', '𝔦', '𝔧', '𝔨', '𝔩', '𝔪',
298 '𝔫', '𝔬', '𝔭', '𝔮', '𝔯', '𝔰', '𝔱', '𝔲', '𝔳', '𝔴', '𝔵', '𝔶', '𝔷'
301 * @type {Array<string>}
303 this.capitalLatinDoubleStruck =
305 '𝔸', '𝔹', 'ℂ', '𝔻', '𝔼', '𝔽', '𝔾', 'ℍ', '𝕀', '𝕁', '𝕂', '𝕃', '𝕄',
306 'ℕ', '𝕆', 'ℙ', 'ℚ', 'ℝ', '𝕊', '𝕋', '𝕌', '𝕍', '𝕎', '𝕏', '𝕐', 'ℤ'
309 * @type {Array<string>}
311 this.smallLatinDoubleStruck =
313 '𝕒', '𝕓', '𝕔', '𝕕', '𝕖', '𝕗', '𝕘', '𝕙', '𝕚', '𝕛', '𝕜', '𝕝', '𝕞',
314 '𝕟', '𝕠', '𝕡', '𝕢', '𝕣', '𝕤', '𝕥', '𝕦', '𝕧', '𝕨', '𝕩', '𝕪', '𝕫'
317 * @type {Array<string>}
319 this.capitalLatinBoldFraktur =
321 '𝕬', '𝕭', '𝕮', '𝕯', '𝕰', '𝕱', '𝕲', '𝕳', '𝕴', '𝕵', '𝕶', '𝕷', '𝕸',
322 '𝕹', '𝕺', '𝕻', '𝕼', '𝕽', '𝕾', '𝕿', '𝖀', '𝖁', '𝖂', '𝖃', '𝖄', '𝖅'
325 * @type {Array<string>}
327 this.smallLatinBoldFraktur =
329 '𝖆', '𝖇', '𝖈', '𝖉', '𝖊', '𝖋', '𝖌', '𝖍', '𝖎', '𝖏', '𝖐', '𝖑', '𝖒',
330 '𝖓', '𝖔', '𝖕', '𝖖', '𝖗', '𝖘', '𝖙', '𝖚', '𝖛', '𝖜', '𝖝', '𝖞', '𝖟'
333 * @type {Array<string>}
335 this.capitalLatinSansSerif =
337 '𝖠', '𝖡', '𝖢', '𝖣', '𝖤', '𝖥', '𝖦', '𝖧', '𝖨', '𝖩', '𝖪', '𝖫', '𝖬',
338 '𝖭', '𝖮', '𝖯', '𝖰', '𝖱', '𝖲', '𝖳', '𝖴', '𝖵', '𝖶', '𝖷', '𝖸', '𝖹'
341 * @type {Array<string>}
343 this.smallLatinSansSerif =
345 '𝖺', '𝖻', '𝖼', '𝖽', '𝖾', '𝖿', '𝗀', '𝗁', '𝗂', '𝗃', '𝗄', '𝗅', '𝗆',
346 '𝗇', '𝗈', '𝗉', '𝗊', '𝗋', '𝗌', '𝗍', '𝗎', '𝗏', '𝗐', '𝗑', '𝗒', '𝗓'
349 * @type {Array<string>}
351 this.capitalLatinSansSerifBold =
353 '𝗔', '𝗕', '𝗖', '𝗗', '𝗘', '𝗙', '𝗚', '𝗛', '𝗜', '𝗝', '𝗞', '𝗟', '𝗠',
354 '𝗡', '𝗢', '𝗣', '𝗤', '𝗥', '𝗦', '𝗧', '𝗨', '𝗩', '𝗪', '𝗫', '𝗬', '𝗭'
357 * @type {Array<string>}
359 this.smallLatinSansSerifBold =
361 '𝗮', '𝗯', '𝗰', '𝗱', '𝗲', '𝗳', '𝗴', '𝗵', '𝗶', '𝗷', '𝗸', '𝗹', '𝗺',
362 '𝗻', '𝗼', '𝗽', '𝗾', '𝗿', '𝘀', '𝘁', '𝘂', '𝘃', '𝘄', '𝘅', '𝘆', '𝘇'
365 * @type {Array<string>}
367 this.capitalLatinSansSerifItalic =
369 '𝘈', '𝘉', '𝘊', '𝘋', '𝘌', '𝘍', '𝘎', '𝘏', '𝘐', '𝘑', '𝘒', '𝘓', '𝘔',
370 '𝘕', '𝘖', '𝘗', '𝘘', '𝘙', '𝘚', '𝘛', '𝘜', '𝘝', '𝘞', '𝘟', '𝘠', '𝘡'
373 * @type {Array<string>}
375 this.smallLatinSansSerifItalic =
377 '𝘢', '𝘣', '𝘤', '𝘥', '𝘦', '𝘧', '𝘨', '𝘩', '𝘪', '𝘫', '𝘬', '𝘭', '𝘮',
378 '𝘯', '𝘰', '𝘱', '𝘲', '𝘳', '𝘴', '𝘵', '𝘶', '𝘷', '𝘸', '𝘹', '𝘺', '𝘻'
381 * @type {Array<string>}
383 this.capitalLatinMonospace =
385 '𝙰', '𝙱', '𝙲', '𝙳', '𝙴', '𝙵', '𝙶', '𝙷', '𝙸', '𝙹', '𝙺', '𝙻', '𝙼',
386 '𝙽', '𝙾', '𝙿', '𝚀', '𝚁', '𝚂', '𝚃', '𝚄', '𝚅', '𝚆', '𝚇', '𝚈', '𝚉'
389 * @type {Array<string>}
391 this.smallLatinMonospace =
393 '𝚊', '𝚋', '𝚌', '𝚍', '𝚎', '𝚏', '𝚐', '𝚑', '𝚒', '𝚓', '𝚔', '𝚕', '𝚖',
394 '𝚗', '𝚘', '𝚙', '𝚚', '𝚛', '𝚜', '𝚝', '𝚞', '𝚟', '𝚠', '𝚡', '𝚢', '𝚣'
397 * @type {Array<string>}
399 this.latinDoubleStruckItalic =
401 'ⅅ', 'ⅆ', 'ⅇ', 'ⅈ', 'ⅉ'
406 * @type {Array<string>}
410 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν',
411 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω'
414 * @type {Array<string>}
418 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν',
419 'ξ', 'ο', 'π', 'ρ', 'ς', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω'
422 * @type {Array<string>}
424 this.capitalGreekBold =
426 '𝚨', '𝚩', '𝚪', '𝚫', '𝚬', '𝚭', '𝚮', '𝚯', '𝚰', '𝚱', '𝚲', '𝚳', '𝚴',
427 '𝚵', '𝚶', '𝚷', '𝚸', '𝚺', '𝚻', '𝚼', '𝚽', '𝚾', '𝚿', '𝛀'
430 * @type {Array<string>}
432 this.smallGreekBold =
434 '𝛂', '𝛃', '𝛄', '𝛅', '𝛆', '𝛇', '𝛈', '𝛉', '𝛊', '𝛋', '𝛌', '𝛍', '𝛎',
435 '𝛏', '𝛐', '𝛑', '𝛒', '𝛓', '𝛔', '𝛕', '𝛖', '𝛗', '𝛘', '𝛙', '𝛚'
438 * @type {Array<string>}
440 this.capitalGreekItalic =
442 '𝛢', '𝛣', '𝛤', '𝛥', '𝛦', '𝛧', '𝛨', '𝛩', '𝛪', '𝛫', '𝛬', '𝛭', '𝛮',
443 '𝛯', '𝛰', '𝛱', '𝛲', '𝛴', '𝛵', '𝛶', '𝛷', '𝛸', '𝛹', '𝛺'
446 * @type {Array<string>}
448 this.smallGreekItalic =
450 '𝛼', '𝛽', '𝛾', '𝛿', '𝜀', '𝜁', '𝜂', '𝜃', '𝜄', '𝜅', '𝜆', '𝜇', '𝜈',
451 '𝜉', '𝜊', '𝜋', '𝜌', '𝜍', '𝜎', '𝜏', '𝜐', '𝜑', '𝜒', '𝜓', '𝜔'
454 * @type {Array<string>}
456 this.capitalGreekSansSerifBold =
458 '𝝖', '𝝗', '𝝘', '𝝙', '𝝚', '𝝛', '𝝜', '𝝝', '𝝞', '𝝟', '𝝠', '𝝡', '𝝢',
459 '𝝣', '𝝤', '𝝥', '𝝦', '𝝨', '𝝩', '𝝪', '𝝫', '𝝬', '𝝭', '𝝮'
462 * @type {Array<string>}
464 this.smallGreekSansSerifBold =
466 '𝝰', '𝝱', '𝝲', '𝝳', '𝝴', '𝝵', '𝝶', '𝝷', '𝝸', '𝝹', '𝝺', '𝝻', '𝝼',
467 '𝝽', '𝝾', '𝝿', '𝞀', '𝞁', '𝞂', '𝞃', '𝞄', '𝞅', '𝞆', '𝞇', '𝞈'
470 * @type {Array<string>}
472 this.greekDoubleStruck =
479 * @type {Array<string>}
488 * @type {Array<string>}
492 '+', '±', '∓', '∔', '∧', '∨', '∩', '∪', '⊌', '⊓', '⊔', '⊝', '⊞',
493 '⊤', '⊥', '⊺', '⊻', '⊼', '⋄', '⋎', '⋏', '⋒', '⋓', '△', '▷', '▽',
497 * @type {Array<string>}
500 * Invisible operator for plus.
504 this.invisiblePlus_ = cvox.SemanticUtil.numberToUnicode(0x2064);
505 this.additions.push(this.invisiblePlus_);
507 * @type {Array<string>}
509 this.multiplications =
511 '†', '‡', '∐', '∗', '∘', '∙', '≀', '⊚', '⊛', '⊠', '⊡', '⋅', '⋆', '⋇',
512 '⋉', '⋊', '⋋', '⋌', '○'
515 * Invisible operator for multiplication.
519 this.invisibleTimes_ = cvox.SemanticUtil.numberToUnicode(0x2062);
520 this.multiplications.push(this.invisibleTimes_);
522 * @type {Array<string>}
526 '-', '⁒', '⁻', '₋', '−', '∖', '∸', '≂', '⊖', '⊟', '➖', '⨩', '⨪',
527 '⨫', '⨬', '⨺', '⩁', '⩬', '﹣', '-', '‐', '‑'
530 * @type {Array<string>}
534 '/', '÷', '⁄', '∕', '⊘', '⟌', '⦼', '⨸'
537 * Invisible operator for function application.
541 this.functionApplication_ = cvox.SemanticUtil.numberToUnicode(0x2061);
545 * @type {Array<string>}
549 '=', '~', '⁼', '₌', '∼', '∽', '≃', '≅', '≈', '≊', '≋', '≌', '≍',
550 '≎', '≑', '≒', '≓', '≔', '≕', '≖', '≗', '≘', '≙', '≚', '≛', '≜',
551 '≝', '≞', '≟', '≡', '≣', '⧤', '⩦', '⩮', '⩯', '⩰', '⩱', '⩲', '⩳',
552 '⩴', '⩵', '⩶', '⩷', '⩸', '⋕', '⩭', '⩪', '⩫', '⩬', '﹦', '='
555 * @type {Array<string>}
559 '<', '>', '≁', '≂', '≄', '≆', '≇', '≉', '≏', '≐', '≠', '≢', '≤',
560 '≥', '≦', '≧', '≨', '≩', '≪', '≫', '≬', '≭', '≮', '≯', '≰', '≱',
561 '≲', '≳', '≴', '≵', '≶', '≷', '≸', '≹', '≺', '≻', '≼', '≽', '≾',
562 '≿', '⊀', '⊁', '⋖', '⋗', '⋘', '⋙', '⋚', '⋛', '⋜', '⋝', '⋞', '⋟',
563 '⋠', '⋡', '⋢', '⋣', '⋤', '⋥', '⋦', '⋧', '⋨', '⋩', '⩹', '⩺', '⩻',
564 '⩼', '⩽', '⩾', '⩿', '⪀', '⪁', '⪂', '⪃', '⪄', '⪅', '⪆', '⪇', '⪈',
565 '⪉', '⪊', '⪋', '⪌', '⪍', '⪎', '⪏', '⪐', '⪑', '⪒', '⪓', '⪔', '⪕',
566 '⪖', '⪗', '⪘', '⪙', '⪚', '⪛', '⪜', '⪝', '⪞', '⪟', '⪠', '⪡', '⪢',
567 '⪣', '⪤', '⪥', '⪦', '⪧', '⪨', '⪩', '⪪', '⪫', '⪬', '⪭', '⪮', '⪯',
568 '⪰', '⪱', '⪲', '⪳', '⪴', '⪵', '⪶', '⪷', '⪸', '⪹', '⪺', '⪻', '⪼',
569 '⫷', '⫸', '⫹', '⫺', '⧀', '⧁', '﹤', '﹥', '<', '>'
572 * @type {Array<string>}
576 // TODO (sorge): Add all the other relations.
579 * @type {Array<string>}
583 '←', '↑', '→', '↓', '↔', '↕', '↖', '↗', '↘', '↙', '↚', '↛', '↜',
584 '↝', '↞', '↟', '↠', '↡', '↢', '↣', '↤', '↥', '↦', '↧', '↨', '↩',
585 '↪', '↫', '↬', '↭', '↮', '↯', '↰', '↱', '↲', '↳', '↴', '↵', '↶',
586 '↷', '↸', '↹', '↺', '↻', '⇄', '⇅', '⇆', '⇇', '⇈', '⇉', '⇊', '⇍',
587 '⇎', '⇏', '⇐', '⇑', '⇒', '⇓', '⇔', '⇕', '⇖', '⇗', '⇘', '⇙', '⇚',
588 '⇛', '⇜', '⇝', '⇞', '⇟', '⇠', '⇡', '⇢', '⇣', '⇤', '⇥', '⇦', '⇧',
589 '⇨', '⇩', '⇪', '⇫', '⇬', '⇭', '⇮', '⇯', '⇰', '⇱', '⇲', '⇳', '⇴',
590 '⇵', '⇶', '⇷', '⇸', '⇹', '⇺', '⇻', '⇼', '⇽', '⇾', '⇿', '⌁', '⌃',
591 '⌄', '⌤', '⎋', '➔', '➘', '➙', '➚', '➛', '➜', '➝', '➞', '➟', '➠',
592 '➡', '➢', '➣', '➤', '➥', '➦', '➧', '➨', '➩', '➪', '➫', '➬', '➭',
593 '➮', '➯', '➱', '➲', '➳', '➴', '➵', '➶', '➷', '➸', '➹', '➺', '➻',
594 '➼', '➽', '➾', '⟰', '⟱', '⟲', '⟳', '⟴', '⟵', '⟶', '⟷', '⟸', '⟹',
595 '⟺', '⟻', '⟼', '⟽', '⟾', '⟿', '⤀', '⤁', '⤂', '⤃', '⤄', '⤅', '⤆',
596 '⤇', '⤈', '⤉', '⤊', '⤋', '⤌', '⤍', '⤎', '⤏', '⤐', '⤑', '⤒', '⤓',
597 '⤔', '⤕', '⤖', '⤗', '⤘', '⤙', '⤚', '⤛', '⤜', '⤝', '⤞', '⤟', '⤠',
598 '⤡', '⤢', '⤣', '⤤', '⤥', '⤦', '⤧', '⤨', '⤩', '⤪', '⤭', '⤮', '⤯',
599 '⤰', '⤱', '⤲', '⤳', '⤴', '⤵', '⤶', '⤷', '⤸', '⤹', '⤺', '⤻', '⤼',
600 '⤽', '⤾', '⤿', '⥀', '⥁', '⥂', '⥃', '⥄', '⥅', '⥆', '⥇', '⥈', '⥉',
601 '⥰', '⥱', '⥲', '⥳', '⥴', '⥵', '⥶', '⥷', '⥸', '⥹', '⥺', '⥻', '⦳',
602 '⦴', '⦽', '⧪', '⧬', '⧭', '⨗', '⬀', '⬁', '⬂', '⬃', '⬄', '⬅', '⬆',
603 '⬇', '⬈', '⬉', '⬊', '⬋', '⬌', '⬍', '⬎', '⬏', '⬐', '⬑', '⬰', '⬱',
604 '⬲', '⬳', '⬴', '⬵', '⬶', '⬷', '⬸', '⬹', '⬺', '⬻', '⬼', '⬽', '⬾',
605 '⬿', '⭀', '⭁', '⭂', '⭃', '⭄', '⭅', '⭆', '⭇', '⭈', '⭉', '⭊', '⭋',
606 '⭌', '←', '↑', '→', '↓',
608 '↼', '↽', '↾', '↿', '⇀', '⇁', '⇂', '⇃', '⇋', '⇌', '⥊', '⥋', '⥌',
609 '⥍', '⥎', '⥏', '⥐', '⥑', '⥒', '⥓', '⥔', '⥕', '⥖', '⥗', '⥘', '⥙',
610 '⥚', '⥛', '⥜', '⥝', '⥞', '⥟', '⥠', '⥡', '⥢', '⥣', '⥤', '⥥', '⥦',
611 '⥧', '⥨', '⥩', '⥪', '⥫', '⥬', '⥭', '⥮', '⥯', '⥼', '⥽', '⥾', '⥿'
614 //Big operation symbols
616 * @type {Array<string>}
620 '⅀', // double struck
621 '∏', '∐', '∑', '⋀', '⋁', '⋂', '⋃', '⨀', '⨁', '⨂', '⨃', '⨄', '⨅',
622 '⨆', '⨇', '⨈', '⨉', '⨊', '⨋', '⫼', '⫿'
625 * @type {Array<string>}
629 '∫', '∬', '∭', '∮', '∯', '∰', '∱', '∲', '∳', '⨌', '⨍', '⨎', '⨏',
630 '⨐', '⨑', '⨒', '⨓', '⨔', '⨕', '⨖', '⨗', '⨘', '⨙', '⨚', '⨛', '⨜'
633 * @type {Array<string>}
636 // TODO (sorge) Insert nabla, differential operators etc.
641 * @type {Array<string>}
644 // TODO (sorge) What to do if single glyphs of big ops occur on their own.
646 '⌠', '⌡', '⎶', '⎪', '⎮', '⎯', '⎲', '⎳', '⎷'
650 // TODO (sorge) Add accented characters.
655 * @type {Array<string>}
659 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
662 * @type {Array<string>}
664 this.digitsFullWidth =
666 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
669 * @type {Array<string>}
673 '𝟎', '𝟏', '𝟐', '𝟑', '𝟒', '𝟓', '𝟔', '𝟕', '𝟖', '𝟗'
676 * @type {Array<string>}
678 this.digitsDoubleStruck =
680 '𝟘', '𝟙', '𝟚', '𝟛', '𝟜', '𝟝', '𝟞', '𝟟', '𝟠', '𝟡'
683 * @type {Array<string>}
685 this.digitsSansSerif =
687 '𝟢', '𝟣', '𝟤', '𝟥', '𝟦', '𝟧', '𝟨', '𝟩', '𝟪', '𝟫'
690 * @type {Array<string>}
692 this.digitsSansSerifBold =
694 '𝟬', '𝟭', '𝟮', '𝟯', '𝟰', '𝟱', '𝟲', '𝟳', '𝟴', '𝟵'
697 * @type {Array<string>}
699 this.digitsMonospace =
701 '𝟶', '𝟷', '𝟸', '𝟹', '𝟺', '𝟻', '𝟼', '𝟽', '𝟾', '𝟿'
704 * @type {Array<string>}
706 this.digitsSuperscript =
708 '²', '³', '¹', '⁰', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹'
711 * @type {Array<string>}
713 this.digitsSubscript =
715 '₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉'
718 * @type {Array<string>}
722 '¼', '½', '¾', '⅐', '⅑', '⅒', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙',
723 '⅚', '⅛', '⅜', '⅝', '⅞', '⅟', '↉'
726 * @type {Array<string>}
728 this.enclosedNumbers =
729 // Encircled numbers.
731 '①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⑪', '⑫', '⑬',
732 '⑭', '⑮', '⑯', '⑰', '⑱', '⑲', '⑳', '⓪', '⓫', '⓬', '⓭', '⓮', '⓯',
733 '⓰', '⓱', '⓲', '⓳', '⓴', '⓵', '⓶', '⓷', '⓸', '⓹', '⓺', '⓻', '⓼',
734 '⓽', '⓾', '⓿', '❶', '❷', '❸', '❹', '❺', '❻', '❼', '❽', '❾', '❿',
735 '➀', '➁', '➂', '➃', '➄', '➅', '➆', '➇', '➈', '➉', '➊', '➋', '➌',
736 '➍', '➎', '➏', '➐', '➑', '➒', '➓', '㉈', '㉉', '㉊', '㉋', '㉌',
737 '㉍', '㉎', '㉏', '㉑', '㉒', '㉓', '㉔', '㉕', '㉖', '㉗', '㉘',
738 '㉙', '㉚', '㉛', '㉜', '㉝', '㉞', '㉟', '㊱', '㊲', '㊳', '㊴',
739 '㊵', '㊶', '㊷', '㊸', '㊹', '㊺', '㊻', '㊼', '㊽', '㊾', '㊿'];
741 * @type {Array<string>}
744 // Numbers in Parenthesis.
746 '⑴', '⑵', '⑶', '⑷', '⑸', '⑹', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀',
747 '⒁', '⒂', '⒃', '⒄', '⒅', '⒆', '⒇'
750 * @type {Array<string>}
752 this.punctuatedNumbers =
753 // Numbers with other punctuation.
754 ['⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', '⒑', '⒒', '⒓', '⒔',
755 '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', // full stop.
756 '🄀', '🄁', '🄂', '🄃', '🄄', '🄅', '🄆', '🄇', '🄈', '🄉', '🄊' // comma.
758 /** Array of all single digits.
759 * @type {Array<string>}
761 this.digits = this.digitsNormal.concat(
762 this.digitsFullWidth, this.digitsBold, this.digitsDoubleStruck,
763 this.digitsSansSerif, this.digitsSansSerifBold, this.digitsMonospace);
764 /** Array of all non-digit number symbols.
765 * @type {Array<string>}
767 this.numbers = this.fractions.concat(
768 this.digitsSuperscript, this.digitsSubscript,
769 this.enclosedNumbers, this.fencedNumbers, this.punctuatedNumbers);
770 /** Array of all number symbols.
771 * @type {Array<string>}
773 this.allNumbers = this.digits.concat(this.numbers);
777 * @type {Array<string>}
779 this.trigonometricFunctions =
781 'cos', 'cot', 'csc', 'sec', 'sin', 'tan', 'arccos', 'arccot',
782 'arccsc', 'arcsec', 'arcsin', 'arctan'
785 * @type {Array<string>}
787 this.hyperbolicFunctions =
789 'cosh', 'coth', 'csch', 'sech', 'sinh', 'tanh',
790 'arcosh', 'arcoth', 'arcsch', 'arsech', 'arsinh', 'artanh',
791 'arccosh', 'arccoth', 'arccsch', 'arcsech', 'arcsinh', 'arctanh'
794 * @type {Array<string>}
796 this.algebraicFunctions =
798 'deg', 'det', 'dim', 'hom', 'ker', 'Tr', 'tr'
801 * @type {Array<string>}
803 this.elementaryFunctions =
805 'log', 'ln', 'lg', 'exp', 'expt', 'gcd', 'gcd', 'arg', 'im', 're', 'Pr'
807 /** All predefined prefix functions.
808 * @type {Array<string>}
810 this.prefixFunctions = this.trigonometricFunctions.concat(
811 this.hyperbolicFunctions,
812 this.algebraicFunctions,
813 this.elementaryFunctions
815 /** Limit functions are handled separately as they can have lower (and upper)
816 * limiting expressions.
817 * @type {Array<string>}
819 this.limitFunctions =
821 'inf', 'lim', 'liminf', 'limsup', 'max', 'min', 'sup', 'injlim',
825 * @type {Array<string>}
827 this.infixFunctions =
832 * Default assignments of semantic attributes.
833 * @type {Array<{set: Array<string>,
834 * role: cvox.SemanticAttr.Role,
835 * type: cvox.SemanticAttr.Type,
836 * font: cvox.SemanticAttr.Font}>} The semantic meaning of the symbol.
839 this.symbolSetToSemantic_ = [
841 {set: this.generalPunctuations,
842 type: cvox.SemanticAttr.Type.PUNCTUATION,
843 role: cvox.SemanticAttr.Role.UNKNOWN
846 type: cvox.SemanticAttr.Type.PUNCTUATION,
847 role: cvox.SemanticAttr.Role.ELLIPSIS
849 {set: this.fullStops,
850 type: cvox.SemanticAttr.Type.PUNCTUATION,
851 role: cvox.SemanticAttr.Role.FULLSTOP
854 type: cvox.SemanticAttr.Type.PUNCTUATION,
855 role: cvox.SemanticAttr.Role.DASH
858 type: cvox.SemanticAttr.Type.PUNCTUATION,
859 role: cvox.SemanticAttr.Role.PRIME
862 {set: this.leftFences,
863 type: cvox.SemanticAttr.Type.FENCE,
864 role: cvox.SemanticAttr.Role.OPEN
866 {set: this.rightFences,
867 type: cvox.SemanticAttr.Type.FENCE,
868 role: cvox.SemanticAttr.Role.CLOSE
870 {set: this.topFences,
871 type: cvox.SemanticAttr.Type.FENCE,
872 role: cvox.SemanticAttr.Role.TOP
874 {set: this.bottomFences,
875 type: cvox.SemanticAttr.Type.FENCE,
876 role: cvox.SemanticAttr.Role.BOTTOM
878 {set: this.neutralFences,
879 type: cvox.SemanticAttr.Type.FENCE,
880 role: cvox.SemanticAttr.Role.NEUTRAL
882 // Single characters.
884 {set: this.smallLatin,
885 type: cvox.SemanticAttr.Type.IDENTIFIER,
886 role: cvox.SemanticAttr.Role.LATINLETTER,
887 font: cvox.SemanticAttr.Font.NORMAL
889 {set: this.capitalLatin,
890 type: cvox.SemanticAttr.Type.IDENTIFIER,
891 role: cvox.SemanticAttr.Role.LATINLETTER,
892 font: cvox.SemanticAttr.Font.NORMAL
894 {set: this.smallLatinFullWidth,
895 type: cvox.SemanticAttr.Type.IDENTIFIER,
896 role: cvox.SemanticAttr.Role.LATINLETTER,
897 font: cvox.SemanticAttr.Font.NORMAL
899 {set: this.capitalLatinFullWidth,
900 type: cvox.SemanticAttr.Type.IDENTIFIER,
901 role: cvox.SemanticAttr.Role.LATINLETTER,
902 font: cvox.SemanticAttr.Font.NORMAL
904 {set: this.smallLatinBold,
905 type: cvox.SemanticAttr.Type.IDENTIFIER,
906 role: cvox.SemanticAttr.Role.LATINLETTER,
907 font: cvox.SemanticAttr.Font.BOLD
909 {set: this.capitalLatinBold,
910 type: cvox.SemanticAttr.Type.IDENTIFIER,
911 role: cvox.SemanticAttr.Role.LATINLETTER,
912 font: cvox.SemanticAttr.Font.BOLD
914 {set: this.smallLatinItalic,
915 type: cvox.SemanticAttr.Type.IDENTIFIER,
916 role: cvox.SemanticAttr.Role.LATINLETTER,
917 font: cvox.SemanticAttr.Font.ITALIC
919 {set: this.capitalLatinItalic,
920 type: cvox.SemanticAttr.Type.IDENTIFIER,
921 role: cvox.SemanticAttr.Role.LATINLETTER,
922 font: cvox.SemanticAttr.Font.ITALIC
924 {set: this.smallLatinScript,
925 type: cvox.SemanticAttr.Type.IDENTIFIER,
926 role: cvox.SemanticAttr.Role.LATINLETTER,
927 font: cvox.SemanticAttr.Font.SCRIPT
929 {set: this.capitalLatinScript,
930 type: cvox.SemanticAttr.Type.IDENTIFIER,
931 role: cvox.SemanticAttr.Role.LATINLETTER,
932 font: cvox.SemanticAttr.Font.SCRIPT
934 {set: this.smallLatinBoldScript,
935 type: cvox.SemanticAttr.Type.IDENTIFIER,
936 role: cvox.SemanticAttr.Role.LATINLETTER,
937 font: cvox.SemanticAttr.Font.BOLDSCRIPT
939 {set: this.capitalLatinBoldScript,
940 type: cvox.SemanticAttr.Type.IDENTIFIER,
941 role: cvox.SemanticAttr.Role.LATINLETTER,
942 font: cvox.SemanticAttr.Font.BOLDSCRIPT
944 {set: this.smallLatinFraktur,
945 type: cvox.SemanticAttr.Type.IDENTIFIER,
946 role: cvox.SemanticAttr.Role.LATINLETTER,
947 font: cvox.SemanticAttr.Font.FRAKTUR
949 {set: this.capitalLatinFraktur,
950 type: cvox.SemanticAttr.Type.IDENTIFIER,
951 role: cvox.SemanticAttr.Role.LATINLETTER,
952 font: cvox.SemanticAttr.Font.FRAKTUR
954 {set: this.smallLatinDoubleStruck,
955 type: cvox.SemanticAttr.Type.IDENTIFIER,
956 role: cvox.SemanticAttr.Role.LATINLETTER,
957 font: cvox.SemanticAttr.Font.DOUBLESTRUCK
959 {set: this.capitalLatinDoubleStruck,
960 type: cvox.SemanticAttr.Type.IDENTIFIER,
961 role: cvox.SemanticAttr.Role.LATINLETTER,
962 font: cvox.SemanticAttr.Font.DOUBLESTRUCK
964 {set: this.smallLatinBoldFraktur,
965 type: cvox.SemanticAttr.Type.IDENTIFIER,
966 role: cvox.SemanticAttr.Role.LATINLETTER,
967 font: cvox.SemanticAttr.Font.BOLDFRAKTUR
969 {set: this.capitalLatinBoldFraktur,
970 type: cvox.SemanticAttr.Type.IDENTIFIER,
971 role: cvox.SemanticAttr.Role.LATINLETTER,
972 font: cvox.SemanticAttr.Font.BOLDFRAKTUR
974 {set: this.smallLatinSansSerif,
975 type: cvox.SemanticAttr.Type.IDENTIFIER,
976 role: cvox.SemanticAttr.Role.LATINLETTER,
977 font: cvox.SemanticAttr.Font.SANSSERIF
979 {set: this.capitalLatinSansSerif,
980 type: cvox.SemanticAttr.Type.IDENTIFIER,
981 role: cvox.SemanticAttr.Role.LATINLETTER,
982 font: cvox.SemanticAttr.Font.SANSSERIF
984 {set: this.smallLatinSansSerifBold,
985 type: cvox.SemanticAttr.Type.IDENTIFIER,
986 role: cvox.SemanticAttr.Role.LATINLETTER,
987 font: cvox.SemanticAttr.Font.SANSSERIFBOLD
989 {set: this.capitalLatinSansSerifBold,
990 type: cvox.SemanticAttr.Type.IDENTIFIER,
991 role: cvox.SemanticAttr.Role.LATINLETTER,
992 font: cvox.SemanticAttr.Font.SANSSERIFBOLD
994 {set: this.smallLatinSansSerifItalic,
995 type: cvox.SemanticAttr.Type.IDENTIFIER,
996 role: cvox.SemanticAttr.Role.LATINLETTER,
997 font: cvox.SemanticAttr.Font.SANSSERIFITALIC
999 {set: this.capitalLatinSansSerifItalic,
1000 type: cvox.SemanticAttr.Type.IDENTIFIER,
1001 role: cvox.SemanticAttr.Role.LATINLETTER,
1002 font: cvox.SemanticAttr.Font.SANSSERIFITALIC
1004 {set: this.smallLatinMonospace,
1005 type: cvox.SemanticAttr.Type.IDENTIFIER,
1006 role: cvox.SemanticAttr.Role.LATINLETTER,
1007 font: cvox.SemanticAttr.Font.MONOSPACE
1009 {set: this.capitalLatinMonospace,
1010 type: cvox.SemanticAttr.Type.IDENTIFIER,
1011 role: cvox.SemanticAttr.Role.LATINLETTER,
1012 font: cvox.SemanticAttr.Font.MONOSPACE
1014 {set: this.latinDoubleStruckItalic,
1015 type: cvox.SemanticAttr.Type.IDENTIFIER,
1016 role: cvox.SemanticAttr.Role.LATINLETTER,
1017 font: cvox.SemanticAttr.Font.DOUBLESTRUCKITALIC
1020 {set: this.smallGreek,
1021 type: cvox.SemanticAttr.Type.IDENTIFIER,
1022 role: cvox.SemanticAttr.Role.GREEKLETTER,
1023 font: cvox.SemanticAttr.Font.NORMAL
1025 {set: this.capitalGreek,
1026 type: cvox.SemanticAttr.Type.IDENTIFIER,
1027 role: cvox.SemanticAttr.Role.GREEKLETTER,
1028 font: cvox.SemanticAttr.Font.NORMAL
1030 {set: this.smallGreekBold,
1031 type: cvox.SemanticAttr.Type.IDENTIFIER,
1032 role: cvox.SemanticAttr.Role.GREEKLETTER,
1033 font: cvox.SemanticAttr.Font.BOLD
1035 {set: this.capitalGreekBold,
1036 type: cvox.SemanticAttr.Type.IDENTIFIER,
1037 role: cvox.SemanticAttr.Role.GREEKLETTER,
1038 font: cvox.SemanticAttr.Font.BOLD
1040 {set: this.smallGreekItalic,
1041 type: cvox.SemanticAttr.Type.IDENTIFIER,
1042 role: cvox.SemanticAttr.Role.GREEKLETTER,
1043 font: cvox.SemanticAttr.Font.ITALIC
1045 {set: this.capitalGreekItalic,
1046 type: cvox.SemanticAttr.Type.IDENTIFIER,
1047 role: cvox.SemanticAttr.Role.GREEKLETTER,
1048 font: cvox.SemanticAttr.Font.ITALIC
1050 {set: this.smallGreekSansSerifBold,
1051 type: cvox.SemanticAttr.Type.IDENTIFIER,
1052 role: cvox.SemanticAttr.Role.GREEKLETTER,
1053 font: cvox.SemanticAttr.Font.SANSSERIFBOLD
1055 {set: this.capitalGreekSansSerifBold,
1056 type: cvox.SemanticAttr.Type.IDENTIFIER,
1057 role: cvox.SemanticAttr.Role.GREEKLETTER,
1058 font: cvox.SemanticAttr.Font.SANSSERIFBOLD
1060 {set: this.greekDoubleStruck,
1061 type: cvox.SemanticAttr.Type.IDENTIFIER,
1062 role: cvox.SemanticAttr.Role.GREEKLETTER,
1063 font: cvox.SemanticAttr.Font.DOUBLESTRUCK
1066 {set: this.hebrewLetters,
1067 type: cvox.SemanticAttr.Type.IDENTIFIER,
1068 role: cvox.SemanticAttr.Role.OTHERLETTER,
1069 font: cvox.SemanticAttr.Font.NORMAL
1072 {set: this.digitsNormal,
1073 type: cvox.SemanticAttr.Type.NUMBER,
1074 role: cvox.SemanticAttr.Role.INTEGER,
1075 font: cvox.SemanticAttr.Font.NORMAL
1077 {set: this.digitsFullWidth,
1078 type: cvox.SemanticAttr.Type.NUMBER,
1079 role: cvox.SemanticAttr.Role.INTEGER,
1080 font: cvox.SemanticAttr.Font.NORMAL
1082 {set: this.digitsBold,
1083 type: cvox.SemanticAttr.Type.NUMBER,
1084 role: cvox.SemanticAttr.Role.INTEGER,
1085 font: cvox.SemanticAttr.Font.BOLD
1087 {set: this.digitsDoubleStruck,
1088 type: cvox.SemanticAttr.Type.NUMBER,
1089 role: cvox.SemanticAttr.Role.INTEGER,
1090 font: cvox.SemanticAttr.Font.DOUBLESTRUCK
1092 {set: this.digitsSansSerif,
1093 type: cvox.SemanticAttr.Type.NUMBER,
1094 role: cvox.SemanticAttr.Role.INTEGER,
1095 font: cvox.SemanticAttr.Font.SANSSERIF
1097 {set: this.digitsSansSerifBold,
1098 type: cvox.SemanticAttr.Type.NUMBER,
1099 role: cvox.SemanticAttr.Role.INTEGER,
1100 font: cvox.SemanticAttr.Font.SANSSERIFBOLD
1102 {set: this.digitsMonospace,
1103 type: cvox.SemanticAttr.Type.NUMBER,
1104 role: cvox.SemanticAttr.Role.INTEGER,
1105 font: cvox.SemanticAttr.Font.MONOSPACE
1108 type: cvox.SemanticAttr.Type.NUMBER,
1109 role: cvox.SemanticAttr.Role.INTEGER
1112 {set: this.additions,
1113 type: cvox.SemanticAttr.Type.OPERATOR,
1114 role: cvox.SemanticAttr.Role.ADDITION
1116 {set: this.multiplications,
1117 type: cvox.SemanticAttr.Type.OPERATOR,
1118 role: cvox.SemanticAttr.Role.MULTIPLICATION
1120 {set: this.subtractions,
1121 type: cvox.SemanticAttr.Type.OPERATOR,
1122 role: cvox.SemanticAttr.Role.SUBTRACTION
1124 {set: this.divisions,
1125 type: cvox.SemanticAttr.Type.OPERATOR,
1126 role: cvox.SemanticAttr.Role.DIVISION
1128 {set: this.prefixOps,
1129 type: cvox.SemanticAttr.Type.PREFIXOP,
1130 role: cvox.SemanticAttr.Role.PREFIXFUNC
1133 {set: this.equalities,
1134 type: cvox.SemanticAttr.Type.RELATION,
1135 role: cvox.SemanticAttr.Role.EQUALITY
1137 {set: this.inequalities,
1138 type: cvox.SemanticAttr.Type.RELATION,
1139 role: cvox.SemanticAttr.Role.INEQUALITY
1141 {set: this.relations,
1142 type: cvox.SemanticAttr.Type.RELATION,
1143 role: cvox.SemanticAttr.Role.UNKNOWN
1146 type: cvox.SemanticAttr.Type.RELATION,
1147 role: cvox.SemanticAttr.Role.ARROW
1151 type: cvox.SemanticAttr.Type.LARGEOP,
1152 role: cvox.SemanticAttr.Role.SUM},
1154 type: cvox.SemanticAttr.Type.LARGEOP,
1155 role: cvox.SemanticAttr.Role.INTEGRAL},
1157 {set: this.limitFunctions,
1158 type: cvox.SemanticAttr.Type.FUNCTION,
1159 role: cvox.SemanticAttr.Role.LIMFUNC},
1160 {set: this.prefixFunctions,
1161 type: cvox.SemanticAttr.Type.FUNCTION,
1162 role: cvox.SemanticAttr.Role.PREFIXFUNC},
1163 {set: this.infixFunctions,
1164 type: cvox.SemanticAttr.Type.OPERATOR,
1165 role: cvox.SemanticAttr.Role.MULTIPLICATION
1167 // TODO (sorge) Add some of the remaining elements.
1170 goog.addSingletonGetter(cvox.SemanticAttr);
1174 * Union type of semantic attributes.
1175 * @typedef {cvox.SemanticAttr.Type|cvox.SemanticAttr.Role}
1177 cvox.SemanticAttr.Attr;
1181 * Mapping for types of elements.
1184 cvox.SemanticAttr.Type = {
1186 // Punctuation like comma, dot, ellipses.
1187 PUNCTUATION: 'punctuation',
1190 // One or several digits, plus some punctuation.
1192 // Single or multiple letters.
1193 IDENTIFIER: 'identifier',
1194 // Regular text in a math expression.
1197 OPERATOR: 'operator',
1198 // Relation symbol, e.g. equals.
1199 RELATION: 'relation',
1200 // e.g. Sum, product, integral.
1202 // Some named function.
1203 FUNCTION: 'function',
1206 // Compound Symbols.
1209 FRACTION: 'fraction',
1210 PUNCTUATED: 'punctuated',
1213 // Relation sequence of a single relation.
1215 // Relation sequence containing at least two different relations.
1216 MULTIREL: 'multirel',
1219 PREFIXOP: 'prefixop',
1220 POSTFIXOP: 'postfixop',
1222 // Function and Bigop Application.
1224 INTEGRAL: 'integral',
1229 // These are bigops or functions with limits.
1230 LIMUPPER: 'limupper',
1231 LIMLOWER: 'limlower',
1233 SUBSCRIPT: 'subscript',
1234 SUPERSCRIPT: 'superscript',
1235 UNDERSCORE: 'underscore',
1236 OVERSCORE: 'overscore',
1238 // Tables and their elements.
1240 MULTILINE: 'multiline',
1245 // Lines are effectively single cell rows.
1256 * Mapping for roles of nodes.
1257 * Roles are more specific than types.
1260 cvox.SemanticAttr.Role = {
1262 ELLIPSIS: 'ellipsis',
1263 FULLSTOP: 'fullstop',
1265 PRIME: 'prime', // Superscript.
1266 VBAR: 'vbar', // A vertical bar.
1267 OPENFENCE: 'openfence',
1268 CLOSEFENCE: 'closefence',
1269 APPLICATION: 'application', // Function Application.
1279 LATINLETTER: 'latinletter',
1280 GREEKLETTER: 'greekletter',
1281 OTHERLETTER: 'otherletter',
1286 OTHERNUMBER: 'othernumber',
1289 MULTIACCENT: 'multiaccent',
1290 OVERACCENT: 'overaccent',
1291 UNDERACCENT: 'underaccent',
1294 LEFTRIGHT: 'leftright',
1295 ABOVEBELOW: 'abovebelow',
1297 // Punctuated elements.
1298 SEQUENCE: 'sequence',
1299 ENDPUNCT: 'endpunct',
1300 STARTPUNCT: 'startpunct',
1303 NEGATIVE: 'negative',
1304 NEGATION: 'negation',
1308 LIMFUNC: 'limit function',
1309 INFIXFUNC: 'infix function',
1310 PREFIXFUNC: 'prefix function',
1311 POSTFIXFUNC: 'postfix function',
1315 INTEGRAL: 'integral',
1317 // Binary operations.
1318 ADDITION: 'addition',
1319 MULTIPLICATION: 'multiplication',
1320 DIVISION: 'division',
1321 SUBTRACTION: 'subtraction',
1322 IMPLICIT: 'implicit',
1325 EQUALITY: 'equality',
1326 INEQUALITY: 'inequality',
1331 // Roles of rows, lines, cells.
1332 // They mirror the different types for tables.
1333 MULTILINE: 'multiline',
1345 * Mapping for font annotations. (Taken from MathML2 section 3.2.2, with the
1346 * exception of double-struck-italic.)
1349 cvox.SemanticAttr.Font = {
1351 BOLDFRAKTUR: 'bold-fraktur',
1352 BOLDITALIC: 'bold-italic',
1353 BOLDSCRIPT: 'bold-script',
1354 DOUBLESTRUCK: 'double-struck',
1355 DOUBLESTRUCKITALIC: 'double-struck-italic',
1358 MONOSPACE: 'monospace',
1361 SANSSERIF: 'sans-serif',
1362 SANSSERIFITALIC: 'sans-serif-italic',
1363 SANSSERIFBOLD: 'sans-serif-bold',
1364 SANSSERIFBOLDITALIC: 'sans-serif-bold-italic',
1370 * Lookup the semantic type of a symbol.
1371 * @param {string} symbol The symbol to which we want to determine the type.
1372 * @return {cvox.SemanticAttr.Type} The semantic type of the symbol.
1374 cvox.SemanticAttr.prototype.lookupType = function(symbol) {
1375 return cvox.SemanticAttr.Type.UNKNOWN;
1380 * Lookup the semantic role of a symbol.
1381 * @param {string} symbol The symbol to which we want to determine the role.
1382 * @return {cvox.SemanticAttr.Role} The semantic role of the symbol.
1384 cvox.SemanticAttr.prototype.lookupRole = function(symbol) {
1385 return cvox.SemanticAttr.Role.UNKNOWN;
1390 * Lookup the semantic meaning of a symbol in terms of type and role.
1391 * @param {string} symbol The symbol to which we want to determine the meaning.
1392 * @return {{role: cvox.SemanticAttr.Role,
1393 * type: cvox.SemanticAttr.Type}} The semantic meaning of the symbol.
1395 cvox.SemanticAttr.lookupMeaning = function(symbol) {
1396 return cvox.SemanticAttr.getInstance().lookupMeaning_(symbol);
1401 * String representation of the invisible times unicode character.
1402 * @return {string} The invisible times character.
1404 cvox.SemanticAttr.invisibleTimes = function() {
1405 return cvox.SemanticAttr.getInstance().invisibleTimes_;
1410 * String representation of the invisible comma unicode character.
1411 * @return {string} The invisible comma character.
1413 cvox.SemanticAttr.invisibleComma = function() {
1414 return cvox.SemanticAttr.getInstance().invisibleComma_;
1419 * String representation of the function application character.
1420 * @return {string} The invisible function application character.
1422 cvox.SemanticAttr.functionApplication = function() {
1423 return cvox.SemanticAttr.getInstance().functionApplication_;
1428 * Decide when two fences match. Currently we match any right to left
1429 * or bottom to top fence and neutral to neutral.
1430 * @param {cvox.SemanticAttr.Role} open Opening fence.
1431 * @param {cvox.SemanticAttr.Role} close Closing fence.
1432 * @return {boolean} True if the fences are matching.
1434 cvox.SemanticAttr.isMatchingFenceRole = function(open, close) {
1435 return (open == cvox.SemanticAttr.Role.OPEN &&
1436 close == cvox.SemanticAttr.Role.CLOSE) ||
1437 (open == cvox.SemanticAttr.Role.NEUTRAL &&
1438 close == cvox.SemanticAttr.Role.NEUTRAL) ||
1439 (open == cvox.SemanticAttr.Role.TOP &&
1440 close == cvox.SemanticAttr.Role.BOTTOM);
1445 * Decide when opening and closing fences match. For neutral fences they have to
1447 * @param {string} open Opening fence.
1448 * @param {string} close Closing fence.
1449 * @return {boolean} True if the fences are matching.
1451 cvox.SemanticAttr.isMatchingFence = function(open, close) {
1452 return cvox.SemanticAttr.getInstance().isMatchingFence_(open, close);
1457 * Determines if a fence is an opening fence.
1458 * @param {cvox.SemanticAttr.Role} fence Opening fence.
1459 * @return {boolean} True if the fence is open or neutral.
1461 cvox.SemanticAttr.isOpeningFence = function(fence) {
1462 return (fence == cvox.SemanticAttr.Role.OPEN ||
1463 fence == cvox.SemanticAttr.Role.NEUTRAL);
1468 * Determines if a fence is a closing fence.
1469 * @param {cvox.SemanticAttr.Role} fence Closing fence.
1470 * @return {boolean} True if the fence is close or neutral.
1472 cvox.SemanticAttr.isClosingFence = function(fence) {
1473 return (fence == cvox.SemanticAttr.Role.CLOSE ||
1474 fence == cvox.SemanticAttr.Role.NEUTRAL);
1478 // TODO (sorge) Make this depended on position in the alphabets.
1480 * Check if a character is a small 'd' in some font.
1481 * @param {!string} chr The character string.
1482 * @return {boolean} True if the character is indeed a single small d.
1484 cvox.SemanticAttr.isCharacterD = function(chr) {
1485 var Ds = ['d', 'ⅆ', 'd', '𝐝', '𝑑', '𝒹', '𝓭', '𝔡',
1486 '𝕕', '𝖉', '𝖽', '𝗱', '𝘥', '𝚍'];
1487 return Ds.indexOf(chr) != -1;
1492 * Decide when opening and closing fences match. For neutral fences they have to
1494 * @param {!string} open Opening fence.
1495 * @param {!string} close Closing fence.
1496 * @return {boolean} True if the fences are matching.
1499 cvox.SemanticAttr.prototype.isMatchingFence_ = function(open, close) {
1500 if (this.neutralFences.indexOf(open) != -1) {
1501 return open == close;
1503 return this.openClosePairs[open] == close ||
1504 this.topBottomPairs[open] == close;
1509 * Lookup the semantic meaning of a symbol in terms of type and role.
1510 * @param {!string} symbol The symbol to which we want to determine the meaning.
1511 * @return {{role: cvox.SemanticAttr.Role,
1512 * type: cvox.SemanticAttr.Type,
1513 * font: cvox.SemanticAttr.Font}} The semantic meaning of the symbol.
1516 cvox.SemanticAttr.prototype.lookupMeaning_ = function(symbol) {
1517 for (var i = 0, set; set = this.symbolSetToSemantic_[i]; i++) {
1518 if (set.set.indexOf(symbol) != -1) {
1519 return {role: set.role || cvox.SemanticAttr.Role.UNKNOWN,
1520 type: set.type || cvox.SemanticAttr.Type.UNKNOWN,
1521 font: set.font || cvox.SemanticAttr.Font.UNKNOWN
1525 return {role: cvox.SemanticAttr.Role.UNKNOWN,
1526 type: cvox.SemanticAttr.Type.UNKNOWN,
1527 font: cvox.SemanticAttr.Font.UNKNOWN