<commit_before>// Copyright 2014 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Mathspeak rules.
 * @author <EMAIL> (<NAME>)
 */

goog.provide('sre.MathspeakSpanish');

goog.require('sre.MathStore');
goog.require('sre.MathmlStoreUtil');
goog.require('sre.MathspeakSpanishUtil');
goog.require('sre.MathspeakUtil');
goog.require('sre.SystemExternal');



/**
 * Rule initialization.
 * @constructor
 * @extends {sre.MathStore}
 */
sre.MathspeakSpanish = function() {
  sre.MathspeakSpanish.base(this, 'constructor');

  this.locale = 'es';
};
goog.inherits(sre.MathspeakSpanish, sre.MathStore);
goog.addSingletonGetter(sre.MathspeakSpanish);


/**
 * @type {sre.MathStore}
 */
sre.MathspeakSpanish.mathStore = sre.MathspeakSpanish.getInstance();


/** @private */
sre.MathspeakSpanish.defineRule_ = goog.bind(
    sre.MathspeakSpanish.mathStore.defineRule,
    sre.MathspeakSpanish.mathStore);


/** @private */
sre.MathspeakSpanish.defineRuleAlias_ = goog.bind(
    sre.MathspeakSpanish.mathStore.defineRulesAlias,
    sre.MathspeakSpanish.mathStore);


/** @private */
sre.MathspeakSpanish.defineSpecialisedRule_ = goog.bind(
    sre.MathspeakSpanish.mathStore.defineSpecialisedRule,
    sre.MathspeakSpanish.mathStore);


/** @private */
sre.MathspeakSpanish.addContextFunction_ = goog.bind(
    sre.MathspeakSpanish.mathStore.contextFunctions.add,
    sre.MathspeakSpanish.mathStore.contextFunctions);


/** @private */
sre.MathspeakSpanish.addCustomQuery_ = goog.bind(
    sre.MathspeakSpanish.mathStore.customQueries.add,
    sre.MathspeakSpanish.mathStore.customQueries);


/** @private */
sre.MathspeakSpanish.addCustomString_ = goog.bind(
    sre.MathspeakSpanish.mathStore.customStrings.add,
    sre.MathspeakSpanish.mathStore.customStrings);


goog.scope(function() {
var defineRule = sre.MathspeakSpanish.defineRule_;
var defineRuleAlias = sre.MathspeakSpanish.defineRuleAlias_;
var defineSpecialisedRule = sre.MathspeakSpanish.defineSpecialisedRule_;

var addCQF = sre.MathspeakSpanish.addCustomQuery_;
var addCSF = sre.MathspeakSpanish.addCustomString_;
var addCTXF = sre.MathspeakSpanish.addContextFunction_;


/**
 * Initialize the custom functions.
 * @private
 */
sre.MathspeakSpanish.initCustomFunctions_ = function() {
  addCQF('CQFspaceoutNumber', sre.MathspeakUtil.spaceoutNumber);
  addCQF('CQFspaceoutIdentifier', sre.MathspeakUtil.spaceoutIdentifier);

  addCSF('CSFspaceoutText', sre.MathspeakUtil.spaceoutText);
  // Fraction function.
  addCSF('CSFopenFracVerbose', sre.MathspeakUtil.openingFractionVerbose);
  addCSF('CSFcloseFracVerbose', sre.MathspeakUtil.closingFractionVerbose);
  addCSF('CSFoverFracVerbose', sre.MathspeakUtil.overFractionVerbose);
  addCSF('CSFopenFracBrief', sre.MathspeakUtil.openingFractionBrief);
  addCSF('CSFcloseFracBrief', sre.MathspeakUtil.closingFractionBrief);
  addCSF('CSFopenFracSbrief', sre.MathspeakUtil.openingFractionSbrief);
  addCSF('CSFcloseFracSbrief', sre.MathspeakUtil.closingFractionSbrief);
  addCSF('CSFoverFracSbrief', sre.MathspeakUtil.overFractionSbrief);

  // Radical function.
  addCSF('CSFopenRadicalVerbose', sre.MathspeakUtil.openingRadicalVerbose);
  addCSF('CSFcloseRadicalVerbose', sre.MathspeakUtil.closingRadicalVerbose);
  addCSF('CSFindexRadicalVerbose', sre.MathspeakUtil.indexRadicalVerbose);
  addCSF('CSFopenRadicalBrief', sre.MathspeakUtil.openingRadicalBrief);
  addCSF('CSFcloseRadicalBrief', sre.MathspeakUtil.closingRadicalBrief);
  addCSF('CSFindexRadicalBrief', sre.MathspeakUtil.indexRadicalBrief);
  addCSF('CSFopenRadicalSbrief', sre.MathspeakUtil.openingRadicalSbrief);
  addCSF('CSFindexRadicalSbrief', sre.MathspeakUtil.indexRadicalSbrief);
  addCQF('CQFisSmallRoot', sre.MathspeakSpanishUtil.smallRoot);

  // Sub- Superscript.
  addCSF('CSFsuperscriptVerbose', sre.MathspeakUtil.superscriptVerbose);
  addCSF('CSFsuperscriptBrief', sre.MathspeakUtil.superscriptBrief);
  addCSF('CSFsubscriptVerbose', sre.MathspeakUtil.subscriptVerbose);
  addCSF('CSFsubscriptBrief', sre.MathspeakUtil.subscriptBrief);
  addCSF('CSFbaselineVerbose', sre.MathspeakUtil.baselineVerbose);
  addCSF('CSFbaselineBrief', sre.MathspeakUtil.baselineBrief);
  // Tensor specific.
  addCSF('CSFleftsuperscriptVerbose', sre.MathspeakUtil.superscriptVerbose);
  addCSF('CSFleftsubscriptVerbose', sre.MathspeakUtil.subscriptVerbose);
  addCSF('CSFrightsuperscriptVerbose', sre.MathspeakUtil.superscriptVerbose);
  addCSF('CSFrightsubscriptVerbose', sre.MathspeakUtil.subscriptVerbose);
  addCSF('CSFleftsuperscriptBrief', sre.MathspeakUtil.superscriptBrief);
  addCSF('CSFleftsubscriptBrief', sre.MathspeakUtil.subscriptBrief);
  addCSF('CSFrightsuperscriptBrief', sre.MathspeakUtil.superscriptBrief);
  addCSF('CSFrightsubscriptBrief', sre.MathspeakUtil.subscriptBrief);

  // Over- Underscore.
  addCSF('CSFunderscript', sre.MathspeakUtil.nestedUnderscore);
  addCSF('CSFoverscript', sre.MathspeakUtil.nestedOverscore);

  addCTXF('CTXFordinalCounter', sre.MathspeakSpanishUtil.ordinalCounter);
  addCTXF('CTXFcontentIterator', sre.MathmlStoreUtil.contentIterator);
  addCTXF('CTXFunitMultipliers', sre.MathspeakSpanishUtil.unitMultipliers);

  // Layout related.
  addCQF('CQFdetIsSimple', sre.MathspeakUtil.determinantIsSimple);
  addCSF('CSFRemoveParens', sre.MathspeakUtil.removeParens);

  addCQF('CQFoneLeft', sre.MathspeakSpanishUtil.oneLeft);

  // Dummy.
  addCQF('CQFresetNesting', sre.MathspeakUtil.resetNestingDepth);

};


/**
 * Mathspeak rules.
 * @private
*/
sre.MathspeakSpanish.initMathspeakSpanish_ = function() {
  defineRule(
      'collapsed', 'mathspeak.default',
      '[t] "collapsed"; [n] . (engine:modality=summary,grammar:collapsed)',
      'self::*', '@alternative', 'not(contains(@grammar, "collapsed"))',
      'self::*', 'self::*', 'self::*', 'self::*', 'self::*'<commit_msg>Correction of Spanish collapsed rule.<commit_after>// Copyright 2014 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Mathspeak rules.
 * @author <EMAIL> (<NAME>)
 */

goog.provide('sre.MathspeakSpanish');

goog.require('sre.MathStore');
goog.require('sre.MathmlStoreUtil');
goog.require('sre.MathspeakSpanishUtil');
goog.require('sre.MathspeakUtil');
goog.require('sre.SystemExternal');



/**
 * Rule initialization.
 * @constructor
 * @extends {sre.MathStore}
 */
sre.MathspeakSpanish = function() {
  sre.MathspeakSpanish.base(this, 'constructor');

  this.locale = 'es';
};
goog.inherits(sre.MathspeakSpanish, sre.MathStore);
goog.addSingletonGetter(sre.MathspeakSpanish);


/**
 * @type {sre.MathStore}
 */
sre.MathspeakSpanish.mathStore = sre.MathspeakSpanish.getInstance();


/** @private */
sre.MathspeakSpanish.defineRule_ = goog.bind(
    sre.MathspeakSpanish.mathStore.defineRule,
    sre.MathspeakSpanish.mathStore);


/** @private */
sre.MathspeakSpanish.defineRuleAlias_ = goog.bind(
    sre.MathspeakSpanish.mathStore.defineRulesAlias,
    sre.MathspeakSpanish.mathStore);


/** @private */
sre.MathspeakSpanish.defineSpecialisedRule_ = goog.bind(
    sre.MathspeakSpanish.mathStore.defineSpecialisedRule,
    sre.MathspeakSpanish.mathStore);


/** @private */
sre.MathspeakSpanish.addContextFunction_ = goog.bind(
    sre.MathspeakSpanish.mathStore.contextFunctions.add,
    sre.MathspeakSpanish.mathStore.contextFunctions);


/** @private */
sre.MathspeakSpanish.addCustomQuery_ = goog.bind(
    sre.MathspeakSpanish.mathStore.customQueries.add,
    sre.MathspeakSpanish.mathStore.customQueries);


/** @private */
sre.MathspeakSpanish.addCustomString_ = goog.bind(
    sre.MathspeakSpanish.mathStore.customStrings.add,
    sre.MathspeakSpanish.mathStore.customStrings);


goog.scope(function() {
var defineRule = sre.MathspeakSpanish.defineRule_;
var defineRuleAlias = sre.MathspeakSpanish.defineRuleAlias_;
var defineSpecialisedRule = sre.MathspeakSpanish.defineSpecialisedRule_;

var addCQF = sre.MathspeakSpanish.addCustomQuery_;
var addCSF = sre.MathspeakSpanish.addCustomString_;
var addCTXF = sre.MathspeakSpanish.addContextFunction_;


/**
 * Initialize the custom functions.
 * @private
 */
sre.MathspeakSpanish.initCustomFunctions_ = function() {
  addCQF('CQFspaceoutNumber', sre.MathspeakUtil.spaceoutNumber);
  addCQF('CQFspaceoutIdentifier', sre.MathspeakUtil.spaceoutIdentifier);

  addCSF('CSFspaceoutText', sre.MathspeakUtil.spaceoutText);
  // Fraction function.
  addCSF('CSFopenFracVerbose', sre.MathspeakUtil.openingFractionVerbose);
  addCSF('CSFcloseFracVerbose', sre.MathspeakUtil.closingFractionVerbose);
  addCSF('CSFoverFracVerbose', sre.MathspeakUtil.overFractionVerbose);
  addCSF('CSFopenFracBrief', sre.MathspeakUtil.openingFractionBrief);
  addCSF('CSFcloseFracBrief', sre.MathspeakUtil.closingFractionBrief);
  addCSF('CSFopenFracSbrief', sre.MathspeakUtil.openingFractionSbrief);
  addCSF('CSFcloseFracSbrief', sre.MathspeakUtil.closingFractionSbrief);
  addCSF('CSFoverFracSbrief', sre.MathspeakUtil.overFractionSbrief);

  // Radical function.
  addCSF('CSFopenRadicalVerbose', sre.MathspeakUtil.openingRadicalVerbose);
  addCSF('CSFcloseRadicalVerbose', sre.MathspeakUtil.closingRadicalVerbose);
  addCSF('CSFindexRadicalVerbose', sre.MathspeakUtil.indexRadicalVerbose);
  addCSF('CSFopenRadicalBrief', sre.MathspeakUtil.openingRadicalBrief);
  addCSF('CSFcloseRadicalBrief', sre.MathspeakUtil.closingRadicalBrief);
  addCSF('CSFindexRadicalBrief', sre.MathspeakUtil.indexRadicalBrief);
  addCSF('CSFopenRadicalSbrief', sre.MathspeakUtil.openingRadicalSbrief);
  addCSF('CSFindexRadicalSbrief', sre.MathspeakUtil.indexRadicalSbrief);
  addCQF('CQFisSmallRoot', sre.MathspeakSpanishUtil.smallRoot);

  // Sub- Superscript.
  addCSF('CSFsuperscriptVerbose', sre.MathspeakUtil.superscriptVerbose);
  addCSF('CSFsuperscriptBrief', sre.MathspeakUtil.superscriptBrief);
  addCSF('CSFsubscriptVerbose', sre.MathspeakUtil.subscriptVerbose);
  addCSF('CSFsubscriptBrief', sre.MathspeakUtil.subscriptBrief);
  addCSF('CSFbaselineVerbose', sre.MathspeakUtil.baselineVerbose);
  addCSF('CSFbaselineBrief', sre.MathspeakUtil.baselineBrief);
  // Tensor specific.
  addCSF('CSFleftsuperscriptVerbose', sre.MathspeakUtil.superscriptVerbose);
  addCSF('CSFleftsubscriptVerbose', sre.MathspeakUtil.subscriptVerbose);
  addCSF('CSFrightsuperscriptVerbose', sre.MathspeakUtil.superscriptVerbose);
  addCSF('CSFrightsubscriptVerbose', sre.MathspeakUtil.subscriptVerbose);
  addCSF('CSFleftsuperscriptBrief', sre.MathspeakUtil.superscriptBrief);
  addCSF('CSFleftsubscriptBrief', sre.MathspeakUtil.subscriptBrief);
  addCSF('CSFrightsuperscriptBrief', sre.MathspeakUtil.superscriptBrief);
  addCSF('CSFrightsubscriptBrief', sre.MathspeakUtil.subscriptBrief);

  // Over- Underscore.
  addCSF('CSFunderscript', sre.MathspeakUtil.nestedUnderscore);
  addCSF('CSFoverscript', sre.MathspeakUtil.nestedOverscore);

  addCTXF('CTXFordinalCounter', sre.MathspeakSpanishUtil.ordinalCounter);
  addCTXF('CTXFcontentIterator', sre.MathmlStoreUtil.contentIterator);
  addCTXF('CTXFunitMultipliers', sre.MathspeakSpanishUtil.unitMultipliers);

  // Layout related.
  addCQF('CQFdetIsSimple', sre.MathspeakUtil.determinantIsSimple);
  addCSF('CSFRemoveParens', sre.MathspeakUtil.removeParens);

  addCQF('CQFoneLeft', sre.MathspeakSpanishUtil.oneLeft);

  // Dummy.
  addCQF('CQFresetNesting', sre.MathspeakUtil.resetNestingDepth);

};


/**
 * Mathspeak rules.
 * @private
*/
sre.MathspeakSpanish.initMathspeakSpanish_ = function() {
  defineRule(
      'collapsed', 'mathspeak.default',
      '[n] . (engine:modality=summary,grammar:collapsed); [t] "plegado";',
      'self::*', '@alternative', 'not(contains(@grammar, "collapsed"))',
      'self::*', 'self::*', 'self::*', 'self::*', 'self::*'
{'fraction_non_alphanumeric': 0.12625108361573015, 'fraction_numerical': 0.0012609346678225234, 'mean_word_length': 6.276376146788991, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5309317', 'n_tokens_mistral': 4690, 'n_tokens_neox': 4368, 'n_words': 579}