1
0

add initial marp implementation with sample content and build configuration

This commit is contained in:
2025-09-13 18:13:22 +02:00
parent dcacc9b409
commit e5f219507f
10319 changed files with 1402023 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
let ones = exports.NUMBERS.ones[Math.floor(n / 100)];
str += ones ? ones + exports.NUMBERS.numSep + 'honderd' : '';
n = n % 100;
if (n) {
str += str ? exports.NUMBERS.numSep : '';
ones = exports.NUMBERS.ones[n];
if (ones) {
str += ones;
}
else {
const tens = exports.NUMBERS.tens[Math.floor(n / 10)];
ones = exports.NUMBERS.ones[n % 10];
str += ones ? ones + '-en-' + tens : tens;
}
}
return str;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
const hund = hundredsToWords_(num % 1000);
if (pos) {
const large = exports.NUMBERS.large[pos];
str = hund + exports.NUMBERS.numSep + large + (str ? exports.NUMBERS.numSep + str : '');
}
else {
str = hund + (str ? exports.NUMBERS.numSep + str : '');
}
}
num = Math.floor(num / 1000);
pos++;
}
return str;
}
function numberToOrdinal(num, plural) {
if (num === 1) {
return 'enkel';
}
if (num === 2) {
return plural ? 'helftes' : 'helfte';
}
if (num === 4) {
return plural ? 'kwarte' : 'kwart';
}
return wordOrdinal(num) + (plural ? 's' : '');
}
function wordOrdinal(num) {
if (num === 1) {
return 'eerste';
}
if (num === 3) {
return 'derde';
}
if (num === 8) {
return 'agste';
}
if (num === 9) {
return 'negende';
}
const ordinal = numberToWords(num);
return ordinal + (num < 19 ? 'de' : 'ste');
}
function numericOrdinal(num) {
return num.toString() + '.';
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const grammar_js_1 = require("../../rule_engine/grammar.js");
const messages_js_1 = require("../messages.js");
function tensToWords_(num) {
const n = num % 100;
if (n < 20) {
return exports.NUMBERS.ones[n];
}
const ten = Math.floor(n / 10);
const tens = exports.NUMBERS.tens[ten];
const ones = exports.NUMBERS.ones[n % 10];
return tens && ones ? tens + (ten === 2 ? '-i-' : '-') + ones : tens || ones;
}
function hundredsToWords_(num) {
const n = num % 1000;
const hundred = Math.floor(n / 100);
const hundreds = hundred
? hundred === 1
? 'cent'
: exports.NUMBERS.ones[hundred] + '-cents'
: '';
const tens = tensToWords_(n % 100);
return hundreds && tens ? hundreds + exports.NUMBERS.numSep + tens : hundreds || tens;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % (pos > 1 ? 1000000 : 1000);
if (hundreds) {
let large = exports.NUMBERS.large[pos];
if (!pos) {
str = hundredsToWords_(hundreds);
}
else if (pos === 1) {
str =
(hundreds === 1 ? '' : hundredsToWords_(hundreds) + exports.NUMBERS.numSep) +
large +
(str ? exports.NUMBERS.numSep + str : '');
}
else {
const thousands = numberToWords(hundreds);
large = hundreds === 1 ? large : large.replace(/\u00f3$/, 'ons');
str =
thousands +
exports.NUMBERS.numSep +
large +
(str ? exports.NUMBERS.numSep + str : '');
}
}
num = Math.floor(num / (pos > 1 ? 1000000 : 1000));
pos++;
}
return str;
}
function numberToOrdinal(num, _plural) {
if (num > 1999) {
return numericOrdinal(num);
}
if (num <= 10) {
return exports.NUMBERS.special.onesOrdinals[num - 1];
}
const result = numberToWords(num);
if (result.match(/mil$/)) {
return result.replace(/mil$/, 'mil·lèsima');
}
if (result.match(/u$/)) {
return result.replace(/u$/, 'vena');
}
if (result.match(/a$/)) {
return result.replace(/a$/, 'ena');
}
return result + (result.match(/e$/) ? 'na' : 'ena');
}
function numericOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
return num.toString() + (gender === 'f' ? 'a' : 'n');
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function onePrefix_(num, mill = false) {
return num === exports.NUMBERS.ones[1] ? (mill ? 'et' : 'en') : num;
}
function hundredsToWords_(num, ordinal = false) {
let n = num % 1000;
let str = '';
let ones = exports.NUMBERS.ones[Math.floor(n / 100)];
str += ones ? onePrefix_(ones, true) + ' hundrede' : '';
n = n % 100;
if (n) {
str += str ? ' og ' : '';
ones = ordinal ? exports.NUMBERS.special.smallOrdinals[n] : exports.NUMBERS.ones[n];
if (ones) {
str += ones;
}
else {
const tens = ordinal
? exports.NUMBERS.special.tensOrdinals[Math.floor(n / 10)]
: exports.NUMBERS.tens[Math.floor(n / 10)];
ones = exports.NUMBERS.ones[n % 10];
str += ones ? onePrefix_(ones) + 'og' + tens : tens;
}
}
return str;
}
function numberToWords(num, ordinal = false) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
const hund = hundredsToWords_(hundreds, ordinal && !pos);
if (pos) {
const large = exports.NUMBERS.large[pos];
const plural = hundreds > 1 ? 'er' : '';
str =
onePrefix_(hund, pos <= 1) +
' ' +
large +
plural +
(str ? ' og ' : '') +
str;
}
else {
str = onePrefix_(hund) + str;
}
}
num = Math.floor(num / 1000);
pos++;
}
return str;
}
function numberToOrdinal(num, plural) {
if (num === 1) {
return plural ? 'hel' : 'hele';
}
if (num === 2) {
return plural ? 'halv' : 'halve';
}
return wordOrdinal(num) + (plural ? 'dele' : 'del');
}
function wordOrdinal(num) {
if (num % 100) {
return numberToWords(num, true);
}
const ordinal = numberToWords(num);
return ordinal.match(/e$/) ? ordinal : ordinal + 'e';
}
function numericOrdinal(num) {
return num.toString() + '.';
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function onePrefix_(num, mill = false) {
return num === exports.NUMBERS.ones[1] ? (mill ? 'eine' : 'ein') : num;
}
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
let ones = exports.NUMBERS.ones[Math.floor(n / 100)];
str += ones ? onePrefix_(ones) + 'hundert' : '';
n = n % 100;
if (n) {
str += str ? exports.NUMBERS.numSep : '';
ones = exports.NUMBERS.ones[n];
if (ones) {
str += ones;
}
else {
const tens = exports.NUMBERS.tens[Math.floor(n / 10)];
ones = exports.NUMBERS.ones[n % 10];
str += ones ? onePrefix_(ones) + 'und' + tens : tens;
}
}
return str;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
const hund = hundredsToWords_(num % 1000);
if (pos) {
const large = exports.NUMBERS.large[pos];
const plural = pos > 1 && hundreds > 1 ? (large.match(/e$/) ? 'n' : 'en') : '';
str = onePrefix_(hund, pos > 1) + large + plural + str;
}
else {
str = onePrefix_(hund, pos > 1) + str;
}
}
num = Math.floor(num / 1000);
pos++;
}
return str.replace(/ein$/, 'eins');
}
function numberToOrdinal(num, plural) {
if (num === 1) {
return 'eintel';
}
if (num === 2) {
return plural ? 'halbe' : 'halb';
}
return wordOrdinal(num) + 'l';
}
function wordOrdinal(num) {
if (num === 1) {
return 'erste';
}
if (num === 3) {
return 'dritte';
}
if (num === 7) {
return 'siebte';
}
if (num === 8) {
return 'achte';
}
const ordinal = numberToWords(num);
return ordinal + (num < 19 ? 'te' : 'ste');
}
function numericOrdinal(num) {
return num.toString() + '.';
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,106 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
str += exports.NUMBERS.ones[Math.floor(n / 100)]
? exports.NUMBERS.ones[Math.floor(n / 100)] + exports.NUMBERS.numSep + 'hundred'
: '';
n = n % 100;
if (n) {
str += str ? exports.NUMBERS.numSep : '';
str +=
exports.NUMBERS.ones[n] ||
exports.NUMBERS.tens[Math.floor(n / 10)] +
(n % 10 ? exports.NUMBERS.numSep + exports.NUMBERS.ones[n % 10] : '');
}
return str;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
str =
hundredsToWords_(num % 1000) +
(pos ? '-' + exports.NUMBERS.large[pos] + '-' : '') +
str;
}
num = Math.floor(num / 1000);
pos++;
}
return str.replace(/-$/, '');
}
function numberToOrdinal(num, plural) {
if (num === 1) {
return plural ? 'oneths' : 'oneth';
}
if (num === 2) {
return plural ? 'halves' : 'half';
}
const ordinal = wordOrdinal(num);
return plural ? ordinal + 's' : ordinal;
}
function wordOrdinal(num) {
let ordinal = numberToWords(num);
if (ordinal.match(/one$/)) {
ordinal = ordinal.slice(0, -3) + 'first';
}
else if (ordinal.match(/two$/)) {
ordinal = ordinal.slice(0, -3) + 'second';
}
else if (ordinal.match(/three$/)) {
ordinal = ordinal.slice(0, -5) + 'third';
}
else if (ordinal.match(/five$/)) {
ordinal = ordinal.slice(0, -4) + 'fifth';
}
else if (ordinal.match(/eight$/)) {
ordinal = ordinal.slice(0, -5) + 'eighth';
}
else if (ordinal.match(/nine$/)) {
ordinal = ordinal.slice(0, -4) + 'ninth';
}
else if (ordinal.match(/twelve$/)) {
ordinal = ordinal.slice(0, -6) + 'twelfth';
}
else if (ordinal.match(/ty$/)) {
ordinal = ordinal.slice(0, -2) + 'tieth';
}
else {
ordinal = ordinal + 'th';
}
return ordinal;
}
function numericOrdinal(num) {
const tens = num % 100;
const numStr = num.toString();
if (tens > 10 && tens < 20) {
return numStr + 'th';
}
switch (num % 10) {
case 1:
return numStr + 'st';
case 2:
return numStr + 'nd';
case 3:
return numStr + 'rd';
default:
return numStr + 'th';
}
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const grammar_js_1 = require("../../rule_engine/grammar.js");
const messages_js_1 = require("../messages.js");
function tensToWords_(num) {
const n = num % 100;
if (n < 30) {
return exports.NUMBERS.ones[n];
}
const tens = exports.NUMBERS.tens[Math.floor(n / 10)];
const ones = exports.NUMBERS.ones[n % 10];
return tens && ones ? tens + ' y ' + ones : tens || ones;
}
function hundredsToWords_(num) {
const n = num % 1000;
const hundred = Math.floor(n / 100);
const hundreds = exports.NUMBERS.special.hundreds[hundred];
const tens = tensToWords_(n % 100);
if (hundred === 1) {
if (!tens) {
return hundreds;
}
return hundreds + 'to' + ' ' + tens;
}
return hundreds && tens ? hundreds + ' ' + tens : hundreds || tens;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
let large = exports.NUMBERS.large[pos];
const huns = hundredsToWords_(hundreds);
if (!pos) {
str = huns;
}
else if (hundreds === 1) {
large = large.match('/^mil( |$)/') ? large : 'un ' + large;
str = large + (str ? ' ' + str : '');
}
else {
large = large.replace(/\u00f3n$/, 'ones');
str = hundredsToWords_(hundreds) + ' ' + large + (str ? ' ' + str : '');
}
}
num = Math.floor(num / 1000);
pos++;
}
return str;
}
function numberToOrdinal(num, _plural) {
if (num > 1999) {
return num.toString() + 'a';
}
if (num <= 12) {
return exports.NUMBERS.special.onesOrdinals[num - 1];
}
const result = [];
if (num >= 1000) {
num = num - 1000;
result.push('milésima');
}
if (!num) {
return result.join(' ');
}
let pos = 0;
pos = Math.floor(num / 100);
if (pos > 0) {
result.push(exports.NUMBERS.special.hundredsOrdinals[pos - 1]);
num = num % 100;
}
if (num <= 12) {
result.push(exports.NUMBERS.special.onesOrdinals[num - 1]);
}
else {
pos = Math.floor(num / 10);
if (pos > 0) {
result.push(exports.NUMBERS.special.tensOrdinals[pos - 1]);
num = num % 10;
}
if (num > 0) {
result.push(exports.NUMBERS.special.onesOrdinals[num - 1]);
}
}
return result.join(' ');
}
function numericOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
return num.toString() + (gender === 'f' ? 'a' : 'o');
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,119 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const engine_js_1 = require("../../common/engine.js");
const grammar_js_1 = require("../../rule_engine/grammar.js");
const messages_js_1 = require("../messages.js");
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
str += exports.NUMBERS.ones[Math.floor(n / 100)]
? exports.NUMBERS.ones[Math.floor(n / 100)] + '-cent'
: '';
n = n % 100;
if (n) {
str += str ? '-' : '';
let ones = exports.NUMBERS.ones[n];
if (ones) {
str += ones;
}
else {
const tens = exports.NUMBERS.tens[Math.floor(n / 10)];
if (tens.match(/-dix$/)) {
ones = exports.NUMBERS.ones[(n % 10) + 10];
str += tens.replace(/-dix$/, '') + '-' + ones;
}
else {
str += tens + (n % 10 ? '-' + exports.NUMBERS.ones[n % 10] : '');
}
}
}
const match = str.match(/s-\w+$/);
return match
? str.replace(/s-\w+$/, match[0].slice(1))
: str.replace(/-un$/, '-et-un');
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
if (exports.NUMBERS.special['tens-' + engine_js_1.Engine.getInstance().subiso]) {
exports.NUMBERS.tens = exports.NUMBERS.special['tens-' + engine_js_1.Engine.getInstance().subiso];
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
let large = exports.NUMBERS.large[pos];
const huns = hundredsToWords_(hundreds);
if (large && large.match(/^mille /)) {
const rest = large.replace(/^mille /, '');
if (str.match(RegExp(rest))) {
str = huns + (pos ? '-mille-' : '') + str;
}
else if (str.match(RegExp(rest.replace(/s$/, '')))) {
str =
huns +
(pos ? '-mille-' : '') +
str.replace(rest.replace(/s$/, ''), rest);
}
else {
str = huns + (pos ? '-' + large + '-' : '') + str;
}
}
else {
large = hundreds === 1 && large ? large.replace(/s$/, '') : large;
str = huns + (pos ? '-' + large + '-' : '') + str;
}
}
num = Math.floor(num / 1000);
pos++;
}
return str.replace(/-$/, '');
}
const SMALL_ORDINAL = {
1: 'unième',
2: 'demi',
3: 'tiers',
4: 'quart'
};
function numberToOrdinal(num, plural) {
const ordinal = SMALL_ORDINAL[num] || wordOrdinal(num);
return num === 3 ? ordinal : plural ? ordinal + 's' : ordinal;
}
function wordOrdinal(num) {
if (num === 1) {
return 'première';
}
let ordinal = numberToWords(num);
if (ordinal.match(/^neuf$/)) {
ordinal = ordinal.slice(0, -1) + 'v';
}
else if (ordinal.match(/cinq$/)) {
ordinal = ordinal + 'u';
}
else if (ordinal.match(/trois$/)) {
ordinal = ordinal + '';
}
else if (ordinal.match(/e$/) || ordinal.match(/s$/)) {
ordinal = ordinal.slice(0, -1);
}
ordinal = ordinal + 'ième';
return ordinal;
}
function numericOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
return num === 1
? num.toString() + (gender === 'm' ? 'er' : 're')
: num.toString() + 'e';
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const grammar_js_1 = require("../../rule_engine/grammar.js");
const messages_js_1 = require("../messages.js");
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
str += exports.NUMBERS.ones[Math.floor(n / 100)]
? exports.NUMBERS.ones[Math.floor(n / 100)] +
exports.NUMBERS.numSep +
exports.NUMBERS.special.hundred
: '';
n = n % 100;
if (n) {
str += str ? exports.NUMBERS.numSep : '';
str += exports.NUMBERS.ones[n];
}
return str;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 32)) {
return num.toString();
}
let pos = 0;
let str = '';
const hundreds = num % 1000;
const hundredsWords = hundredsToWords_(hundreds);
num = Math.floor(num / 1000);
if (!num) {
return hundredsWords;
}
while (num > 0) {
const thousands = num % 100;
if (thousands) {
str =
exports.NUMBERS.ones[thousands] +
exports.NUMBERS.numSep +
exports.NUMBERS.large[pos] +
(str ? exports.NUMBERS.numSep + str : '');
}
num = Math.floor(num / 100);
pos++;
}
return hundredsWords ? str + exports.NUMBERS.numSep + hundredsWords : str;
}
function numberToOrdinal(num, _plural) {
if (num <= 10) {
return exports.NUMBERS.special.smallDenominators[num];
}
return wordOrdinal(num) + ' अंश';
}
function wordOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
if (num <= 0) {
return num.toString();
}
if (num < 10) {
return gender === 'f'
? exports.NUMBERS.special.ordinalsFeminine[num]
: exports.NUMBERS.special.ordinalsMasculine[num];
}
const ordinal = numberToWords(num);
return ordinal + (gender === 'f' ? 'वीं' : 'वाँ');
}
function numericOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
if (num > 0 && num < 10) {
return gender === 'f'
? exports.NUMBERS.special.simpleSmallOrdinalsFeminine[num]
: exports.NUMBERS.special.simpleSmallOrdinalsMasculine[num];
}
const ordinal = num
.toString()
.split('')
.map(function (x) {
const num = parseInt(x, 10);
return isNaN(num) ? '' : exports.NUMBERS.special.simpleNumbers[num];
})
.join('');
return ordinal + (gender === 'f' ? 'वीं' : 'वाँ');
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const grammar_js_1 = require("../../rule_engine/grammar.js");
const messages_js_1 = require("../messages.js");
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
str += exports.NUMBERS.ones[Math.floor(n / 100)]
? exports.NUMBERS.ones[Math.floor(n / 100)] + exports.NUMBERS.numSep + 'cento'
: '';
n = n % 100;
if (n) {
str += str ? exports.NUMBERS.numSep : '';
const ones = exports.NUMBERS.ones[n];
if (ones) {
str += ones;
}
else {
let tens = exports.NUMBERS.tens[Math.floor(n / 10)];
const rest = n % 10;
if (rest === 1 || rest === 8) {
tens = tens.slice(0, -1);
}
str += tens;
str += rest ? exports.NUMBERS.numSep + exports.NUMBERS.ones[n % 10] : '';
}
}
return str;
}
function numberToWords(num) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
if (num === 1 && grammar_js_1.Grammar.getInstance().getParameter('fraction')) {
return 'un';
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
str =
hundredsToWords_(num % 1000) +
(pos ? '-' + exports.NUMBERS.large[pos] + '-' : '') +
str;
}
num = Math.floor(num / 1000);
pos++;
}
return str.replace(/-$/, '');
}
function numberToOrdinal(num, plural) {
if (num === 2) {
return plural ? 'mezzi' : 'mezzo';
}
const ordinal = wordOrdinal(num);
if (!plural) {
return ordinal;
}
const gender = ordinal.match(/o$/) ? 'i' : 'e';
return ordinal.slice(0, -1) + gender;
}
function wordOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
const postfix = gender === 'm' ? 'o' : 'a';
let ordinal = exports.NUMBERS.special.onesOrdinals[num];
if (ordinal) {
return ordinal.slice(0, -1) + postfix;
}
ordinal = numberToWords(num);
return ordinal.slice(0, -1) + 'esim' + postfix;
}
function numericOrdinal(num) {
const gender = grammar_js_1.Grammar.getInstance().getParameter('gender');
return num.toString() + (gender === 'm' ? 'o' : 'a');
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function thousandsToWords_(num) {
let n = num % 10000;
let str = '';
str += exports.NUMBERS.ones[Math.floor(n / 1000)]
? Math.floor(n / 1000) === 1
? '천'
: exports.NUMBERS.ones[Math.floor(n / 1000)] + '천'
: '';
n = n % 1000;
if (n) {
str += exports.NUMBERS.ones[Math.floor(n / 100)]
? Math.floor(n / 100) === 1
? '백'
: exports.NUMBERS.ones[Math.floor(n / 100)] + '백'
: '';
n = n % 100;
str +=
exports.NUMBERS.tens[Math.floor(n / 10)] + (n % 10 ? exports.NUMBERS.ones[n % 10] : '');
}
return str;
}
function numberToWords(num) {
if (num === 0)
return exports.NUMBERS.zero;
if (num >= Math.pow(10, 36))
return num.toString();
let pos = 0;
let str = '';
while (num > 0) {
const thousands = num % 10000;
if (thousands) {
str =
thousandsToWords_(num % 10000) +
(pos ? exports.NUMBERS.large[pos] + exports.NUMBERS.numSep : '') +
str;
}
num = Math.floor(num / 10000);
pos++;
}
return str.replace(/ $/, '');
}
function numberToOrdinal(num, _plural) {
if (num === 1)
return '첫번째';
return wordOrdinal(num) + '번째';
}
function wordOrdinal(num) {
const ordinal = numberToWords(num);
num %= 100;
const label = numberToWords(num);
if (!label || !num)
return ordinal;
const tens = num === 20 ? '스무' : exports.NUMBERS.tens[10 + Math.floor(num / 10)];
const ones = exports.NUMBERS.ones[10 + Math.floor(num % 10)];
return ordinal.slice(0, -label.length) + tens + ones;
}
function numericOrdinal(num) {
return numberToOrdinal(num, false);
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function numberToWords(num) {
const digits = num.toString().split('');
return digits
.map(function (digit) {
return exports.NUMBERS.ones[parseInt(digit, 10)];
})
.join('');
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
numberToWords: numberToWords,
numberToOrdinal: numberToWords
});

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,163 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const engine_js_1 = require("../../common/engine.js");
const messages_js_1 = require("../messages.js");
function hundredsToWordsRo_(num, ordinal = false) {
let n = num % 1000;
let str = '';
const count = Math.floor(n / 100);
const ones = exports.NUMBERS.ones[count];
str += ones ? (count === 1 ? '' : ones) + 'hundre' : '';
n = n % 100;
if (n) {
str += str ? 'og' : '';
if (ordinal) {
const ord = exports.NUMBERS.special.smallOrdinals[n];
if (ord) {
return str + ord;
}
if (n % 10) {
return (str +
exports.NUMBERS.tens[Math.floor(n / 10)] +
exports.NUMBERS.special.smallOrdinals[n % 10]);
}
}
str +=
exports.NUMBERS.ones[n] ||
exports.NUMBERS.tens[Math.floor(n / 10)] + (n % 10 ? exports.NUMBERS.ones[n % 10] : '');
}
return ordinal ? replaceOrdinal(str) : str;
}
function numberToWordsRo(num, ordinal = false) {
if (num === 0) {
return ordinal ? exports.NUMBERS.special.smallOrdinals[0] : exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
const hund = hundredsToWordsRo_(num % 1000, pos ? false : ordinal);
if (!pos && ordinal) {
ordinal = !ordinal;
}
str =
hund +
(pos
? ' ' +
(exports.NUMBERS.large[pos] + (pos > 1 && hundreds > 1 ? 'er' : '')) +
(str ? ' ' : '')
: '') +
str;
}
num = Math.floor(num / 1000);
pos++;
}
return ordinal ? str + (str.match(/tusen$/) ? 'de' : 'te') : str;
}
function numberToOrdinal(num, _plural) {
return wordOrdinal(num);
}
function replaceOrdinal(str) {
const letOne = exports.NUMBERS.special.endOrdinal[0];
if (letOne === 'a' && str.match(/en$/)) {
return str.slice(0, -2) + exports.NUMBERS.special.endOrdinal;
}
if (str.match(/(d|n)$/) || str.match(/hundre$/)) {
return str + 'de';
}
if (str.match(/i$/)) {
return str + exports.NUMBERS.special.endOrdinal;
}
if (letOne === 'a' && str.match(/e$/)) {
return str.slice(0, -1) + exports.NUMBERS.special.endOrdinal;
}
if (str.match(/e$/)) {
return str + 'nde';
}
return str + 'nde';
}
function wordOrdinal(num) {
const ordinal = numberToWords(num, true);
return ordinal;
}
function numericOrdinal(num) {
return num.toString() + '.';
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});
function onePrefix_(num, thd = false) {
const numOne = exports.NUMBERS.ones[1];
return num === numOne ? (num === 'ein' ? 'eitt ' : thd ? 'et' : 'ett') : num;
}
function hundredsToWordsGe_(num, ordinal = false) {
let n = num % 1000;
let str = '';
let ones = exports.NUMBERS.ones[Math.floor(n / 100)];
str += ones ? onePrefix_(ones) + 'hundre' : '';
n = n % 100;
if (n) {
str += str ? 'og' : '';
if (ordinal) {
const ord = exports.NUMBERS.special.smallOrdinals[n];
if (ord) {
return (str += ord);
}
}
ones = exports.NUMBERS.ones[n];
if (ones) {
str += ones;
}
else {
const tens = exports.NUMBERS.tens[Math.floor(n / 10)];
ones = exports.NUMBERS.ones[n % 10];
str += ones ? ones + 'og' + tens : tens;
}
}
return ordinal ? replaceOrdinal(str) : str;
}
function numberToWordsGe(num, ordinal = false) {
if (num === 0) {
return ordinal ? exports.NUMBERS.special.smallOrdinals[0] : exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
const hund = hundredsToWordsGe_(num % 1000, pos ? false : ordinal);
if (!pos && ordinal) {
ordinal = !ordinal;
}
str =
(pos === 1 ? onePrefix_(hund, true) : hund) +
(pos > 1 ? exports.NUMBERS.numSep : '') +
(pos
?
exports.NUMBERS.large[pos] + (pos > 1 && hundreds > 1 ? 'er' : '')
: '') +
(pos > 1 && str ? exports.NUMBERS.numSep : '') +
str;
}
num = Math.floor(num / 1000);
pos++;
}
return ordinal ? str + (str.match(/tusen$/) ? 'de' : 'te') : str;
}
function numberToWords(num, ordinal = false) {
const word = engine_js_1.Engine.getInstance().subiso === 'alt'
? numberToWordsGe(num, ordinal)
: numberToWordsRo(num, ordinal);
return word;
}

View File

@@ -0,0 +1,2 @@
import { Numbers } from '../messages.js';
export declare const NUMBERS: Numbers;

View File

@@ -0,0 +1,124 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBERS = void 0;
const messages_js_1 = require("../messages.js");
function hundredsToWords_(num) {
let n = num % 1000;
let str = '';
const hundreds = Math.floor(n / 100);
str += exports.NUMBERS.ones[hundreds]
? (hundreds === 1 ? '' : exports.NUMBERS.ones[hundreds] + exports.NUMBERS.numSep) + 'hundra'
: '';
n = n % 100;
if (n) {
str += str ? exports.NUMBERS.numSep : '';
str +=
exports.NUMBERS.ones[n] ||
exports.NUMBERS.tens[Math.floor(n / 10)] +
(n % 10 ? exports.NUMBERS.numSep + exports.NUMBERS.ones[n % 10] : '');
}
return str;
}
function numberToWords(num, ordinal = false) {
if (num === 0) {
return exports.NUMBERS.zero;
}
if (num >= Math.pow(10, 36)) {
return num.toString();
}
let pos = 0;
let str = '';
while (num > 0) {
const hundreds = num % 1000;
if (hundreds) {
const large = exports.NUMBERS.large[pos];
const plural = hundreds > 1 && pos > 1 && !ordinal ? 'er' : '';
str =
(pos === 1 && hundreds === 1
? ''
: (pos > 1 && hundreds === 1 ? 'en' : hundredsToWords_(num % 1000)) +
(pos > 1 ? ' ' : '')) +
(pos ? large + plural + (pos > 1 ? ' ' : '') : '') +
str;
}
num = Math.floor(num / 1000);
pos++;
}
return str.replace(/ $/, '');
}
function numberToOrdinal(num, plural) {
if (num === 1) {
return plural ? 'hel' : 'hel';
}
if (num === 2) {
return plural ? 'halva' : 'halv';
}
let ordinal = wordOrdinal(num);
ordinal = ordinal.match(/de$/) ? ordinal.replace(/de$/, '') : ordinal;
return ordinal + (plural ? 'delar' : 'del');
}
function wordOrdinal(num) {
let ordinal = numberToWords(num, true);
if (ordinal.match(/^noll$/)) {
ordinal = 'nollte';
}
else if (ordinal.match(/ett$/)) {
ordinal = ordinal.replace(/ett$/, 'första');
}
else if (ordinal.match(/två$/)) {
ordinal = ordinal.replace(/två$/, 'andra');
}
else if (ordinal.match(/tre$/)) {
ordinal = ordinal.replace(/tre$/, 'tredje');
}
else if (ordinal.match(/fyra$/)) {
ordinal = ordinal.replace(/fyra$/, 'fjärde');
}
else if (ordinal.match(/fem$/)) {
ordinal = ordinal.replace(/fem$/, 'femte');
}
else if (ordinal.match(/sex$/)) {
ordinal = ordinal.replace(/sex$/, 'sjätte');
}
else if (ordinal.match(/sju$/)) {
ordinal = ordinal.replace(/sju$/, 'sjunde');
}
else if (ordinal.match(/åtta$/)) {
ordinal = ordinal.replace(/åtta$/, 'åttonde');
}
else if (ordinal.match(/nio$/)) {
ordinal = ordinal.replace(/nio$/, 'nionde');
}
else if (ordinal.match(/tio$/)) {
ordinal = ordinal.replace(/tio$/, 'tionde');
}
else if (ordinal.match(/elva$/)) {
ordinal = ordinal.replace(/elva$/, 'elfte');
}
else if (ordinal.match(/tolv$/)) {
ordinal = ordinal.replace(/tolv$/, 'tolfte');
}
else if (ordinal.match(/tusen$/)) {
ordinal = ordinal.replace(/tusen$/, 'tusonde');
}
else if (ordinal.match(/jard$/) || ordinal.match(/jon$/)) {
ordinal = ordinal + 'te';
}
else {
ordinal = ordinal + 'de';
}
return ordinal;
}
function numericOrdinal(num) {
const str = num.toString();
if (str.match(/11$|12$/)) {
return str + ':e';
}
return str + (str.match(/1$|2$/) ? ':a' : ':e');
}
exports.NUMBERS = (0, messages_js_1.NUMBERS)({
wordOrdinal: wordOrdinal,
numericOrdinal: numericOrdinal,
numberToWords: numberToWords,
numberToOrdinal: numberToOrdinal
});