add initial marp implementation with sample content and build configuration
This commit is contained in:
6
node_modules/speech-rule-engine/mjs/l10n/l10n.d.ts
generated
vendored
Normal file
6
node_modules/speech-rule-engine/mjs/l10n/l10n.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Locale } from './locale.js';
|
||||
export declare const locales: {
|
||||
[key: string]: () => Locale;
|
||||
};
|
||||
export declare function setLocale(): void;
|
||||
export declare function completeLocale(json: any): void;
|
||||
75
node_modules/speech-rule-engine/mjs/l10n/l10n.js
generated
vendored
Normal file
75
node_modules/speech-rule-engine/mjs/l10n/l10n.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Engine } from '../common/engine.js';
|
||||
import { Variables } from '../common/variables.js';
|
||||
import { Grammar } from '../rule_engine/grammar.js';
|
||||
import { af } from './locales/locale_af.js';
|
||||
import { ca } from './locales/locale_ca.js';
|
||||
import { da } from './locales/locale_da.js';
|
||||
import { de } from './locales/locale_de.js';
|
||||
import { en } from './locales/locale_en.js';
|
||||
import { es } from './locales/locale_es.js';
|
||||
import { euro } from './locales/locale_euro.js';
|
||||
import { fr } from './locales/locale_fr.js';
|
||||
import { hi } from './locales/locale_hi.js';
|
||||
import { ko } from './locales/locale_ko.js';
|
||||
import { it } from './locales/locale_it.js';
|
||||
import { nb } from './locales/locale_nb.js';
|
||||
import { nemeth } from './locales/locale_nemeth.js';
|
||||
import { nn } from './locales/locale_nn.js';
|
||||
import { sv } from './locales/locale_sv.js';
|
||||
import { LOCALE } from './locale.js';
|
||||
export const locales = {
|
||||
af: af,
|
||||
ca: ca,
|
||||
da: da,
|
||||
de: de,
|
||||
en: en,
|
||||
es: es,
|
||||
euro: euro,
|
||||
fr: fr,
|
||||
hi: hi,
|
||||
it: it,
|
||||
ko: ko,
|
||||
nb: nb,
|
||||
nn: nn,
|
||||
sv: sv,
|
||||
nemeth: nemeth
|
||||
};
|
||||
export function setLocale() {
|
||||
const msgs = getLocale();
|
||||
setSubiso(msgs);
|
||||
if (msgs) {
|
||||
for (const key of Object.getOwnPropertyNames(msgs)) {
|
||||
LOCALE[key] = msgs[key];
|
||||
}
|
||||
for (const [key, func] of Object.entries(msgs.CORRECTIONS)) {
|
||||
Grammar.getInstance().setCorrection(key, func);
|
||||
}
|
||||
}
|
||||
}
|
||||
function setSubiso(msg) {
|
||||
const subiso = Engine.getInstance().subiso;
|
||||
if (msg.SUBISO.all.indexOf(subiso) === -1) {
|
||||
Engine.getInstance().subiso = msg.SUBISO.default;
|
||||
}
|
||||
msg.SUBISO.current = Engine.getInstance().subiso;
|
||||
}
|
||||
function getLocale() {
|
||||
const locale = Variables.ensureLocale(Engine.getInstance().locale, Engine.getInstance().defaultLocale);
|
||||
Engine.getInstance().locale = locale;
|
||||
return locales[locale]();
|
||||
}
|
||||
export function completeLocale(json) {
|
||||
const locale = locales[json.locale];
|
||||
if (!locale) {
|
||||
console.error('Locale ' + json.locale + ' does not exist!');
|
||||
return;
|
||||
}
|
||||
const kind = json.kind.toUpperCase();
|
||||
const messages = json.messages;
|
||||
if (!messages)
|
||||
return;
|
||||
const loc = locale();
|
||||
for (const [key, value] of Object.entries(messages)) {
|
||||
loc[kind][key] = value;
|
||||
}
|
||||
}
|
||||
17
node_modules/speech-rule-engine/mjs/l10n/locale.d.ts
generated
vendored
Normal file
17
node_modules/speech-rule-engine/mjs/l10n/locale.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Alphabets, Functions, Messages, Numbers, SubIso } from './messages.js';
|
||||
import * as tr from './transformers.js';
|
||||
export interface Locale {
|
||||
FUNCTIONS: Functions;
|
||||
MESSAGES: Messages;
|
||||
ALPHABETS: Alphabets;
|
||||
NUMBERS: Numbers;
|
||||
COMBINERS?: {
|
||||
[key: string]: tr.Combiner;
|
||||
};
|
||||
CORRECTIONS?: {
|
||||
[key: string]: (a: string) => string;
|
||||
};
|
||||
SUBISO: SubIso;
|
||||
}
|
||||
export declare const LOCALE: Locale;
|
||||
export declare function createLocale(): Locale;
|
||||
13
node_modules/speech-rule-engine/mjs/l10n/locale.js
generated
vendored
Normal file
13
node_modules/speech-rule-engine/mjs/l10n/locale.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ALPHABETS, FUNCTIONS, MESSAGES, NUMBERS, SUBISO } from './messages.js';
|
||||
export const LOCALE = createLocale();
|
||||
export function createLocale() {
|
||||
return {
|
||||
FUNCTIONS: FUNCTIONS(),
|
||||
MESSAGES: MESSAGES(),
|
||||
ALPHABETS: ALPHABETS(),
|
||||
NUMBERS: NUMBERS(),
|
||||
COMBINERS: {},
|
||||
CORRECTIONS: {},
|
||||
SUBISO: SUBISO()
|
||||
};
|
||||
}
|
||||
10
node_modules/speech-rule-engine/mjs/l10n/locale_util.d.ts
generated
vendored
Normal file
10
node_modules/speech-rule-engine/mjs/l10n/locale_util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Combiner } from './transformers.js';
|
||||
export declare function nestingToString(count: number): string;
|
||||
export declare function combinePostfixIndex(postfix: string, index: string): string;
|
||||
export declare function localFont(font: string): string;
|
||||
export declare function localRole(role: string): string;
|
||||
export declare function localEnclose(enclose: string): string;
|
||||
export declare function localeFontCombiner(font: string | [string, string]): {
|
||||
font: string;
|
||||
combiner: Combiner;
|
||||
};
|
||||
43
node_modules/speech-rule-engine/mjs/l10n/locale_util.js
generated
vendored
Normal file
43
node_modules/speech-rule-engine/mjs/l10n/locale_util.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import { LOCALE } from './locale.js';
|
||||
import { Combiners } from './transformers.js';
|
||||
export function nestingToString(count) {
|
||||
switch (count) {
|
||||
case 1:
|
||||
return LOCALE.MESSAGES.MS.ONCE || '';
|
||||
case 2:
|
||||
return LOCALE.MESSAGES.MS.TWICE;
|
||||
default:
|
||||
return count.toString();
|
||||
}
|
||||
}
|
||||
export function combinePostfixIndex(postfix, index) {
|
||||
return postfix === LOCALE.MESSAGES.MS.ROOTINDEX ||
|
||||
postfix === LOCALE.MESSAGES.MS.INDEX
|
||||
? postfix
|
||||
: postfix + ' ' + index;
|
||||
}
|
||||
export function localFont(font) {
|
||||
return extractString(LOCALE.MESSAGES.font[font], font);
|
||||
}
|
||||
export function localRole(role) {
|
||||
return extractString(LOCALE.MESSAGES.role[role], role);
|
||||
}
|
||||
export function localEnclose(enclose) {
|
||||
return extractString(LOCALE.MESSAGES.enclose[enclose], enclose);
|
||||
}
|
||||
function extractString(combiner, fallback) {
|
||||
if (combiner === undefined) {
|
||||
return fallback;
|
||||
}
|
||||
return typeof combiner === 'string' ? combiner : combiner[0];
|
||||
}
|
||||
export function localeFontCombiner(font) {
|
||||
return typeof font === 'string'
|
||||
? { font: font, combiner: LOCALE.ALPHABETS.combiner }
|
||||
: {
|
||||
font: font[0],
|
||||
combiner: LOCALE.COMBINERS[font[1]] ||
|
||||
Combiners[font[1]] ||
|
||||
LOCALE.ALPHABETS.combiner
|
||||
};
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_af.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_af.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function af(): Locale;
|
||||
34
node_modules/speech-rule-engine/mjs/l10n/locales/locale_af.js
generated
vendored
Normal file
34
node_modules/speech-rule-engine/mjs/l10n/locales/locale_af.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { createLocale } from '../locale.js';
|
||||
import { NUMBERS } from '../numbers/numbers_af.js';
|
||||
import * as tr from '../transformers.js';
|
||||
const germanPostfixCombiner = function (letter, font, cap) {
|
||||
letter = !cap ? letter : cap + ' ' + letter;
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
let locale = null;
|
||||
export function af() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.COMBINERS['germanPostfix'] = germanPostfixCombiner;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.plural = (unit) => {
|
||||
return /.*s$/.test(unit) ? unit : unit + 's';
|
||||
};
|
||||
loc.FUNCTIONS.fontRegexp = function (font) {
|
||||
return new RegExp('((^' + font + ' )|( ' + font + '$))');
|
||||
};
|
||||
loc.ALPHABETS.combiner = tr.Combiners.prefixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
loc.CORRECTIONS.article = (name) => {
|
||||
return Grammar.getInstance().getParameter('noArticle') ? '' : name;
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ca.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ca.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function ca(): Locale;
|
||||
65
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ca.js
generated
vendored
Normal file
65
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ca.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { combinePostfixIndex } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_ca.js';
|
||||
import { Combiners } from '../transformers.js';
|
||||
const sansserifCombiner = function (letter, font, cap) {
|
||||
letter = 'sans serif ' + (cap ? cap + ' ' + letter : letter);
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
let locale = null;
|
||||
export function ca() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.COMBINERS['sansserif'] = sansserifCombiner;
|
||||
loc.FUNCTIONS.fracNestDepth = (_node) => false;
|
||||
loc.FUNCTIONS.combineRootIndex = combinePostfixIndex;
|
||||
loc.FUNCTIONS.combineNestedRadical = (a, _b, c) => a + c;
|
||||
loc.FUNCTIONS.fontRegexp = (font) => RegExp('^' + font + ' ');
|
||||
loc.FUNCTIONS.plural = (unit) => {
|
||||
if (/.*os$/.test(unit)) {
|
||||
return unit + 'sos';
|
||||
}
|
||||
if (/.*s$/.test(unit)) {
|
||||
return unit + 'os';
|
||||
}
|
||||
if (/.*ga$/.test(unit)) {
|
||||
return unit.slice(0, -2) + 'gues';
|
||||
}
|
||||
if (/.*ça$/.test(unit)) {
|
||||
return unit.slice(0, -2) + 'ces';
|
||||
}
|
||||
if (/.*ca$/.test(unit)) {
|
||||
return unit.slice(0, -2) + 'ques';
|
||||
}
|
||||
if (/.*ja$/.test(unit)) {
|
||||
return unit.slice(0, -2) + 'ges';
|
||||
}
|
||||
if (/.*qua$/.test(unit)) {
|
||||
return unit.slice(0, -3) + 'qües';
|
||||
}
|
||||
if (/.*a$/.test(unit)) {
|
||||
return unit.slice(0, -1) + 'es';
|
||||
}
|
||||
if (/.*(e|i)$/.test(unit)) {
|
||||
return unit + 'ns';
|
||||
}
|
||||
if (/.*í$/.test(unit)) {
|
||||
return unit.slice(0, -1) + 'ins';
|
||||
}
|
||||
return unit + 's';
|
||||
};
|
||||
loc.FUNCTIONS.si = (prefix, unit) => {
|
||||
if (unit.match(/^metre/)) {
|
||||
prefix = prefix.replace(/a$/, 'à').replace(/o$/, 'ò').replace(/i$/, 'í');
|
||||
}
|
||||
return prefix + unit;
|
||||
};
|
||||
loc.ALPHABETS.combiner = Combiners.prefixCombiner;
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_da.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_da.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function da(): Locale;
|
||||
24
node_modules/speech-rule-engine/mjs/l10n/locales/locale_da.js
generated
vendored
Normal file
24
node_modules/speech-rule-engine/mjs/l10n/locales/locale_da.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_da.js';
|
||||
import * as tr from '../transformers.js';
|
||||
let locale = null;
|
||||
export function da() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.fontRegexp = (font) => {
|
||||
return font === loc.ALPHABETS.capPrefix['default']
|
||||
? RegExp('^' + font + ' ')
|
||||
: RegExp(' ' + font + '$');
|
||||
};
|
||||
loc.ALPHABETS.combiner = tr.Combiners.postfixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_de.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_de.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function de(): Locale;
|
||||
82
node_modules/speech-rule-engine/mjs/l10n/locales/locale_de.js
generated
vendored
Normal file
82
node_modules/speech-rule-engine/mjs/l10n/locales/locale_de.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { localFont } from '../locale_util.js';
|
||||
import { createLocale } from '../locale.js';
|
||||
import { NUMBERS } from '../numbers/numbers_de.js';
|
||||
const germanPrefixCombiner = function (letter, font, cap) {
|
||||
if (cap === 's') {
|
||||
font = font
|
||||
.split(' ')
|
||||
.map(function (x) {
|
||||
return x.replace(/s$/, '');
|
||||
})
|
||||
.join(' ');
|
||||
cap = '';
|
||||
}
|
||||
letter = cap ? cap + ' ' + letter : letter;
|
||||
return font ? font + ' ' + letter : letter;
|
||||
};
|
||||
const germanPostfixCombiner = function (letter, font, cap) {
|
||||
letter = !cap || cap === 's' ? letter : cap + ' ' + letter;
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
let locale = null;
|
||||
export function de() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.COMBINERS['germanPostfix'] = germanPostfixCombiner;
|
||||
loc.ALPHABETS.combiner = germanPrefixCombiner;
|
||||
loc.FUNCTIONS.radicalNestDepth = (x) => {
|
||||
return x > 1 ? loc.NUMBERS.numberToWords(x) + 'fach' : '';
|
||||
};
|
||||
loc.FUNCTIONS.combineRootIndex = (postfix, index) => {
|
||||
const root = index ? index + 'wurzel' : '';
|
||||
return postfix.replace('Wurzel', root);
|
||||
};
|
||||
loc.FUNCTIONS.combineNestedRadical = (a, b, c) => {
|
||||
a = c.match(/exponent$/) ? a + 'r' : a;
|
||||
const count = (b ? b + ' ' : '') + a;
|
||||
return c.match(/ /) ? c.replace(/ /, ' ' + count + ' ') : count + ' ' + c;
|
||||
};
|
||||
loc.FUNCTIONS.fontRegexp = function (font) {
|
||||
font = font
|
||||
.split(' ')
|
||||
.map(function (x) {
|
||||
return x.replace(/s$/, '(|s)');
|
||||
})
|
||||
.join(' ');
|
||||
return new RegExp('((^' + font + ' )|( ' + font + '$))');
|
||||
};
|
||||
loc.CORRECTIONS.correctOne = (num) => num.replace(/^eins$/, 'ein');
|
||||
loc.CORRECTIONS.localFontNumber = (font) => {
|
||||
const realFont = localFont(font);
|
||||
return realFont
|
||||
.split(' ')
|
||||
.map(function (x) {
|
||||
return x.replace(/s$/, '');
|
||||
})
|
||||
.join(' ');
|
||||
};
|
||||
loc.CORRECTIONS.lowercase = (name) => name.toLowerCase();
|
||||
loc.CORRECTIONS.article = (name) => {
|
||||
const decl = Grammar.getInstance().getParameter('case');
|
||||
const plural = Grammar.getInstance().getParameter('plural');
|
||||
if (decl === 'dative') {
|
||||
return { der: 'dem', die: plural ? 'den' : 'der', das: 'dem' }[name];
|
||||
}
|
||||
return name;
|
||||
};
|
||||
loc.CORRECTIONS.masculine = (name) => {
|
||||
const decl = Grammar.getInstance().getParameter('case');
|
||||
if (decl === 'dative') {
|
||||
return name + 'n';
|
||||
}
|
||||
return name;
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_en.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_en.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function en(): Locale;
|
||||
26
node_modules/speech-rule-engine/mjs/l10n/locales/locale_en.js
generated
vendored
Normal file
26
node_modules/speech-rule-engine/mjs/l10n/locales/locale_en.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { createLocale } from '../locale.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_en.js';
|
||||
import * as tr from '../transformers.js';
|
||||
let locale = null;
|
||||
export function en() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.plural = (unit) => {
|
||||
return /.*s$/.test(unit) ? unit : unit + 's';
|
||||
};
|
||||
loc.ALPHABETS.combiner = tr.Combiners.prefixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
loc.CORRECTIONS.article = (name) => {
|
||||
return Grammar.getInstance().getParameter('noArticle') ? '' : name;
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_es.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_es.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function es(): Locale;
|
||||
50
node_modules/speech-rule-engine/mjs/l10n/locales/locale_es.js
generated
vendored
Normal file
50
node_modules/speech-rule-engine/mjs/l10n/locales/locale_es.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { combinePostfixIndex } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_es.js';
|
||||
import { Combiners } from '../transformers.js';
|
||||
const sansserifCombiner = function (letter, font, cap) {
|
||||
letter = 'sans serif ' + (cap ? cap + ' ' + letter : letter);
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
let locale = null;
|
||||
export function es() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.COMBINERS['sansserif'] = sansserifCombiner;
|
||||
loc.FUNCTIONS.fracNestDepth = (_node) => false;
|
||||
loc.FUNCTIONS.combineRootIndex = combinePostfixIndex;
|
||||
loc.FUNCTIONS.combineNestedRadical = (a, _b, c) => a + c;
|
||||
loc.FUNCTIONS.fontRegexp = (font) => RegExp('^' + font + ' ');
|
||||
loc.FUNCTIONS.plural = (unit) => {
|
||||
if (/.*(a|e|i|o|u)$/.test(unit)) {
|
||||
return unit + 's';
|
||||
}
|
||||
if (/.*z$/.test(unit)) {
|
||||
return unit.slice(0, -1) + 'ces';
|
||||
}
|
||||
if (/.*c$/.test(unit)) {
|
||||
return unit.slice(0, -1) + 'ques';
|
||||
}
|
||||
if (/.*g$/.test(unit)) {
|
||||
return unit + 'ues';
|
||||
}
|
||||
if (/.*\u00f3n$/.test(unit)) {
|
||||
return unit.slice(0, -2) + 'ones';
|
||||
}
|
||||
return unit + 'es';
|
||||
};
|
||||
loc.FUNCTIONS.si = (prefix, unit) => {
|
||||
if (unit.match(/^metro/)) {
|
||||
prefix = prefix.replace(/a$/, 'á').replace(/o$/, 'ó').replace(/i$/, 'í');
|
||||
}
|
||||
return prefix + unit;
|
||||
};
|
||||
loc.ALPHABETS.combiner = Combiners.prefixCombiner;
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_euro.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_euro.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function euro(): Locale;
|
||||
8
node_modules/speech-rule-engine/mjs/l10n/locales/locale_euro.js
generated
vendored
Normal file
8
node_modules/speech-rule-engine/mjs/l10n/locales/locale_euro.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
let locale = null;
|
||||
export function euro() {
|
||||
if (!locale) {
|
||||
locale = createLocale();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_fr.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_fr.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function fr(): Locale;
|
||||
34
node_modules/speech-rule-engine/mjs/l10n/locales/locale_fr.js
generated
vendored
Normal file
34
node_modules/speech-rule-engine/mjs/l10n/locales/locale_fr.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { createLocale } from '../locale.js';
|
||||
import { combinePostfixIndex, nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_fr.js';
|
||||
import { Combiners } from '../transformers.js';
|
||||
let locale = null;
|
||||
export function fr() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.combineRootIndex = combinePostfixIndex;
|
||||
loc.FUNCTIONS.combineNestedFraction = (a, b, c) => c.replace(/ $/g, '') + b + a;
|
||||
loc.FUNCTIONS.combineNestedRadical = (a, _b, c) => c + ' ' + a;
|
||||
loc.FUNCTIONS.fontRegexp = (font) => RegExp(' (en |)' + font + '$');
|
||||
loc.FUNCTIONS.plural = (unit) => {
|
||||
return /.*s$/.test(unit) ? unit : unit + 's';
|
||||
};
|
||||
loc.CORRECTIONS.article = (name) => {
|
||||
return Grammar.getInstance().getParameter('noArticle') ? '' : name;
|
||||
};
|
||||
loc.ALPHABETS.combiner = Combiners.romanceCombiner;
|
||||
loc.SUBISO = {
|
||||
default: 'fr',
|
||||
current: 'fr',
|
||||
all: ['fr', 'be', 'ch']
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_hi.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_hi.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function hi(): Locale;
|
||||
18
node_modules/speech-rule-engine/mjs/l10n/locales/locale_hi.js
generated
vendored
Normal file
18
node_modules/speech-rule-engine/mjs/l10n/locales/locale_hi.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { NUMBERS } from '../numbers/numbers_hi.js';
|
||||
import { Combiners } from '../transformers.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
let locale = null;
|
||||
export function hi() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.ALPHABETS.combiner = Combiners.prefixCombiner;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_it.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_it.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function it(): Locale;
|
||||
30
node_modules/speech-rule-engine/mjs/l10n/locales/locale_it.js
generated
vendored
Normal file
30
node_modules/speech-rule-engine/mjs/l10n/locales/locale_it.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { combinePostfixIndex, nestingToString } from '../locale_util.js';
|
||||
import { createLocale } from '../locale.js';
|
||||
import { NUMBERS } from '../numbers/numbers_it.js';
|
||||
import { Combiners } from '../transformers.js';
|
||||
const italianPostfixCombiner = function (letter, font, cap) {
|
||||
if (letter.match(/^[a-zA-Z]$/)) {
|
||||
font = font.replace('cerchiato', 'cerchiata');
|
||||
}
|
||||
letter = cap ? letter + ' ' + cap : letter;
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
let locale = null;
|
||||
export function it() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.COMBINERS['italianPostfix'] = italianPostfixCombiner;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.combineRootIndex = combinePostfixIndex;
|
||||
loc.FUNCTIONS.combineNestedFraction = (a, b, c) => c.replace(/ $/g, '') + b + a;
|
||||
loc.FUNCTIONS.combineNestedRadical = (a, _b, c) => c + ' ' + a;
|
||||
loc.FUNCTIONS.fontRegexp = (font) => RegExp(' (en |)' + font + '$');
|
||||
loc.ALPHABETS.combiner = Combiners.romanceCombiner;
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ko.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ko.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function ko(): Locale;
|
||||
49
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ko.js
generated
vendored
Normal file
49
node_modules/speech-rule-engine/mjs/l10n/locales/locale_ko.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { createLocale } from '../locale.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_ko.js';
|
||||
import * as tr from '../transformers.js';
|
||||
let locale = null;
|
||||
export function ko() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.plural = function (unit) {
|
||||
return unit;
|
||||
};
|
||||
loc.FUNCTIONS.si = (prefix, unit) => {
|
||||
return prefix + unit;
|
||||
};
|
||||
loc.FUNCTIONS.combineRootIndex = function (index, postfix) {
|
||||
return index + postfix;
|
||||
};
|
||||
loc.ALPHABETS.combiner = tr.Combiners.prefixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
loc.CORRECTIONS.postposition = (name) => {
|
||||
if (['같다', '는', '와', '를', '로'].includes(name))
|
||||
return name;
|
||||
const char = name.slice(-1);
|
||||
const value = (char.charCodeAt(0) - 44032) % 28;
|
||||
let final = value > 0 ? true : false;
|
||||
if (char.match(/[r,l,n,m,1,3,6,7,8,0]/i))
|
||||
final = true;
|
||||
Grammar.getInstance().setParameter('final', final);
|
||||
return name;
|
||||
};
|
||||
loc.CORRECTIONS.article = (name) => {
|
||||
const final = Grammar.getInstance().getParameter('final');
|
||||
if (final)
|
||||
Grammar.getInstance().setParameter('final', false);
|
||||
if (name === '같다')
|
||||
name = '는';
|
||||
const temp = { 는: '은', 와: '과', 를: '을', 로: '으로' }[name];
|
||||
return temp !== undefined && final ? temp : name;
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nb.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nb.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function nb(): Locale;
|
||||
19
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nb.js
generated
vendored
Normal file
19
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nb.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_nn.js';
|
||||
import * as tr from '../transformers.js';
|
||||
let locale = null;
|
||||
export function nb() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.ALPHABETS.combiner = tr.Combiners.prefixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nemeth.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nemeth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function nemeth(): Locale;
|
||||
53
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nemeth.js
generated
vendored
Normal file
53
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nemeth.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { NUMBERS } from '../numbers/numbers_nemeth.js';
|
||||
import { identityTransformer } from '../transformers.js';
|
||||
const simpleEnglish = function (letter) {
|
||||
return letter.match(RegExp('^' + locale.ALPHABETS.languagePrefix.english))
|
||||
? letter.slice(1)
|
||||
: letter;
|
||||
};
|
||||
const postfixCombiner = function (letter, font, _number) {
|
||||
letter = simpleEnglish(letter);
|
||||
return font ? letter + font : letter;
|
||||
};
|
||||
const germanCombiner = function (letter, font, _cap) {
|
||||
return font + simpleEnglish(letter);
|
||||
};
|
||||
const embellishCombiner = function (letter, font, num) {
|
||||
letter = simpleEnglish(letter);
|
||||
return font + (num ? num : '') + letter + '⠻';
|
||||
};
|
||||
const doubleEmbellishCombiner = function (letter, font, num) {
|
||||
letter = simpleEnglish(letter);
|
||||
return font + (num ? num : '') + letter + '⠻⠻';
|
||||
};
|
||||
const parensCombiner = function (letter, font, _number) {
|
||||
letter = simpleEnglish(letter);
|
||||
return font + letter + '⠾';
|
||||
};
|
||||
let locale = null;
|
||||
export function nemeth() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.COMBINERS = {
|
||||
postfixCombiner: postfixCombiner,
|
||||
germanCombiner: germanCombiner,
|
||||
embellishCombiner: embellishCombiner,
|
||||
doubleEmbellishCombiner: doubleEmbellishCombiner,
|
||||
parensCombiner: parensCombiner
|
||||
};
|
||||
loc.FUNCTIONS.fracNestDepth = (_node) => false;
|
||||
loc.FUNCTIONS.fontRegexp = (font) => RegExp('^' + font);
|
||||
loc.FUNCTIONS.si = identityTransformer;
|
||||
loc.ALPHABETS.combiner = (letter, font, num) => {
|
||||
return font ? font + num + letter : simpleEnglish(letter);
|
||||
};
|
||||
loc.ALPHABETS.digitTrans = { default: NUMBERS.numberToWords };
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nn.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nn.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function nn(): Locale;
|
||||
24
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nn.js
generated
vendored
Normal file
24
node_modules/speech-rule-engine/mjs/l10n/locales/locale_nn.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_nn.js';
|
||||
import * as tr from '../transformers.js';
|
||||
let locale = null;
|
||||
export function nn() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.ALPHABETS.combiner = tr.Combiners.prefixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.SUBISO = {
|
||||
default: '',
|
||||
current: '',
|
||||
all: ['', 'alt']
|
||||
};
|
||||
return loc;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_sv.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/locales/locale_sv.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Locale } from '../locale.js';
|
||||
export declare function sv(): Locale;
|
||||
23
node_modules/speech-rule-engine/mjs/l10n/locales/locale_sv.js
generated
vendored
Normal file
23
node_modules/speech-rule-engine/mjs/l10n/locales/locale_sv.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { createLocale } from '../locale.js';
|
||||
import { nestingToString } from '../locale_util.js';
|
||||
import { NUMBERS } from '../numbers/numbers_sv.js';
|
||||
import * as tr from '../transformers.js';
|
||||
let locale = null;
|
||||
export function sv() {
|
||||
if (!locale) {
|
||||
locale = create();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
function create() {
|
||||
const loc = createLocale();
|
||||
loc.NUMBERS = NUMBERS;
|
||||
loc.FUNCTIONS.radicalNestDepth = nestingToString;
|
||||
loc.FUNCTIONS.fontRegexp = function (font) {
|
||||
return new RegExp('((^' + font + ' )|( ' + font + '$))');
|
||||
};
|
||||
loc.ALPHABETS.combiner = tr.Combiners.prefixCombiner;
|
||||
loc.ALPHABETS.digitTrans.default = NUMBERS.numberToWords;
|
||||
loc.CORRECTIONS.correctOne = (num) => num.replace(/^ett$/, 'en');
|
||||
return loc;
|
||||
}
|
||||
88
node_modules/speech-rule-engine/mjs/l10n/messages.d.ts
generated
vendored
Normal file
88
node_modules/speech-rule-engine/mjs/l10n/messages.d.ts
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import * as tr from './transformers.js';
|
||||
export interface Messages {
|
||||
MS: {
|
||||
[msg: string]: string;
|
||||
};
|
||||
MSroots: {
|
||||
[msg: string]: string;
|
||||
};
|
||||
font: {
|
||||
[msg: string]: string | [string, string];
|
||||
};
|
||||
embellish: {
|
||||
[msg: string]: string | [string, string];
|
||||
};
|
||||
role: {
|
||||
[msg: string]: string | [string, string];
|
||||
};
|
||||
enclose: {
|
||||
[msg: string]: string | [string, string];
|
||||
};
|
||||
navigate: {
|
||||
[msg: string]: string;
|
||||
};
|
||||
regexp: {
|
||||
[msg: string]: string;
|
||||
};
|
||||
unitTimes: string;
|
||||
}
|
||||
export declare function MESSAGES(): Messages;
|
||||
export interface Numbers {
|
||||
zero?: string;
|
||||
ones?: string[];
|
||||
tens?: string[];
|
||||
large?: string[];
|
||||
special?: {
|
||||
[key: string]: string | string[];
|
||||
};
|
||||
wordOrdinal?: tr.Transformer;
|
||||
numericOrdinal?: tr.Transformer;
|
||||
numberToWords?: tr.Transformer;
|
||||
numberToOrdinal?: tr.GrammarCase;
|
||||
vulgarSep?: string;
|
||||
numSep?: string;
|
||||
}
|
||||
export declare function NUMBERS(numbers?: Numbers): Numbers;
|
||||
export interface Alphabets {
|
||||
latinSmall: string[];
|
||||
latinCap: string[];
|
||||
greekSmall: string[];
|
||||
greekCap: string[];
|
||||
capPrefix: {
|
||||
[key: string]: string;
|
||||
};
|
||||
smallPrefix: {
|
||||
[key: string]: string;
|
||||
};
|
||||
digitPrefix: {
|
||||
[key: string]: string;
|
||||
};
|
||||
languagePrefix?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
digitTrans: {
|
||||
[key: string]: tr.Transformer;
|
||||
};
|
||||
letterTrans: {
|
||||
[key: string]: tr.Transformer;
|
||||
};
|
||||
combiner: tr.Combiner;
|
||||
}
|
||||
export declare function ALPHABETS(): Alphabets;
|
||||
export interface Functions {
|
||||
fracNestDepth: (node: Element) => boolean;
|
||||
radicalNestDepth: (count: number) => string;
|
||||
combineRootIndex: (name: string, index: string) => string;
|
||||
combineNestedFraction: tr.Combiner;
|
||||
combineNestedRadical: tr.Combiner;
|
||||
fontRegexp: (font: string) => RegExp;
|
||||
si: tr.SiCombiner;
|
||||
plural: tr.Transformer;
|
||||
}
|
||||
export declare function FUNCTIONS(): Functions;
|
||||
export interface SubIso {
|
||||
default: string;
|
||||
current: string;
|
||||
all: string[];
|
||||
}
|
||||
export declare function SUBISO(): SubIso;
|
||||
73
node_modules/speech-rule-engine/mjs/l10n/messages.js
generated
vendored
Normal file
73
node_modules/speech-rule-engine/mjs/l10n/messages.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import * as tr from './transformers.js';
|
||||
export function MESSAGES() {
|
||||
return {
|
||||
MS: {},
|
||||
MSroots: {},
|
||||
font: {},
|
||||
embellish: {},
|
||||
role: {},
|
||||
enclose: {},
|
||||
navigate: {},
|
||||
regexp: {},
|
||||
unitTimes: ''
|
||||
};
|
||||
}
|
||||
export function NUMBERS(numbers = {}) {
|
||||
return Object.assign({
|
||||
zero: 'zero',
|
||||
ones: [],
|
||||
tens: [],
|
||||
large: [],
|
||||
special: {},
|
||||
wordOrdinal: tr.identityTransformer,
|
||||
numericOrdinal: tr.identityTransformer,
|
||||
numberToWords: tr.identityTransformer,
|
||||
numberToOrdinal: tr.pluralCase,
|
||||
vulgarSep: ' ',
|
||||
numSep: ' '
|
||||
}, numbers);
|
||||
}
|
||||
export function ALPHABETS() {
|
||||
return {
|
||||
latinSmall: [],
|
||||
latinCap: [],
|
||||
greekSmall: [],
|
||||
greekCap: [],
|
||||
capPrefix: { default: '' },
|
||||
smallPrefix: { default: '' },
|
||||
digitPrefix: { default: '' },
|
||||
languagePrefix: {},
|
||||
digitTrans: {
|
||||
default: tr.identityTransformer,
|
||||
mathspeak: tr.identityTransformer,
|
||||
clearspeak: tr.identityTransformer
|
||||
},
|
||||
letterTrans: { default: tr.identityTransformer },
|
||||
combiner: (letter, _font, _cap) => {
|
||||
return letter;
|
||||
}
|
||||
};
|
||||
}
|
||||
export function FUNCTIONS() {
|
||||
return {
|
||||
fracNestDepth: (n) => tr.vulgarFractionSmall(n, 10, 100),
|
||||
radicalNestDepth: (_count) => '',
|
||||
combineRootIndex: function (postfix, _index) {
|
||||
return postfix;
|
||||
},
|
||||
combineNestedFraction: tr.Combiners.identityCombiner,
|
||||
combineNestedRadical: tr.Combiners.identityCombiner,
|
||||
fontRegexp: function (font) {
|
||||
return new RegExp('^' + font.split(/ |-/).join('( |-)') + '( |-)');
|
||||
},
|
||||
si: tr.siCombiner,
|
||||
plural: tr.identityTransformer
|
||||
};
|
||||
}
|
||||
export function SUBISO() {
|
||||
return {
|
||||
default: '',
|
||||
current: '',
|
||||
all: []
|
||||
};
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_af.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_af.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
84
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_af.js
generated
vendored
Normal file
84
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_af.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
let ones = NUMBERS.ones[Math.floor(n / 100)];
|
||||
str += ones ? ones + NUMBERS.numSep + 'honderd' : '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? NUMBERS.numSep : '';
|
||||
ones = NUMBERS.ones[n];
|
||||
if (ones) {
|
||||
str += ones;
|
||||
}
|
||||
else {
|
||||
const tens = NUMBERS.tens[Math.floor(n / 10)];
|
||||
ones = NUMBERS.ones[n % 10];
|
||||
str += ones ? ones + '-en-' + tens : tens;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0) {
|
||||
return 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 = NUMBERS.large[pos];
|
||||
str = hund + NUMBERS.numSep + large + (str ? NUMBERS.numSep + str : '');
|
||||
}
|
||||
else {
|
||||
str = hund + (str ? 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() + '.';
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ca.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ca.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
88
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ca.js
generated
vendored
Normal file
88
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ca.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function tensToWords_(num) {
|
||||
const n = num % 100;
|
||||
if (n < 20) {
|
||||
return NUMBERS.ones[n];
|
||||
}
|
||||
const ten = Math.floor(n / 10);
|
||||
const tens = NUMBERS.tens[ten];
|
||||
const ones = 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'
|
||||
: NUMBERS.ones[hundred] + '-cents'
|
||||
: '';
|
||||
const tens = tensToWords_(n % 100);
|
||||
return hundreds && tens ? hundreds + NUMBERS.numSep + tens : hundreds || tens;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0) {
|
||||
return 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 = NUMBERS.large[pos];
|
||||
if (!pos) {
|
||||
str = hundredsToWords_(hundreds);
|
||||
}
|
||||
else if (pos === 1) {
|
||||
str =
|
||||
(hundreds === 1 ? '' : hundredsToWords_(hundreds) + NUMBERS.numSep) +
|
||||
large +
|
||||
(str ? NUMBERS.numSep + str : '');
|
||||
}
|
||||
else {
|
||||
const thousands = numberToWords(hundreds);
|
||||
large = hundreds === 1 ? large : large.replace(/\u00f3$/, 'ons');
|
||||
str =
|
||||
thousands +
|
||||
NUMBERS.numSep +
|
||||
large +
|
||||
(str ? 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 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.getInstance().getParameter('gender');
|
||||
return num.toString() + (gender === 'f' ? 'a' : 'n');
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_da.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_da.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
84
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_da.js
generated
vendored
Normal file
84
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_da.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function onePrefix_(num, mill = false) {
|
||||
return num === NUMBERS.ones[1] ? (mill ? 'et' : 'en') : num;
|
||||
}
|
||||
function hundredsToWords_(num, ordinal = false) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
let ones = NUMBERS.ones[Math.floor(n / 100)];
|
||||
str += ones ? onePrefix_(ones, true) + ' hundrede' : '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? ' og ' : '';
|
||||
ones = ordinal ? NUMBERS.special.smallOrdinals[n] : NUMBERS.ones[n];
|
||||
if (ones) {
|
||||
str += ones;
|
||||
}
|
||||
else {
|
||||
const tens = ordinal
|
||||
? NUMBERS.special.tensOrdinals[Math.floor(n / 10)]
|
||||
: NUMBERS.tens[Math.floor(n / 10)];
|
||||
ones = NUMBERS.ones[n % 10];
|
||||
str += ones ? onePrefix_(ones) + 'og' + tens : tens;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num, ordinal = false) {
|
||||
if (num === 0) {
|
||||
return 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 = 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() + '.';
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_de.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_de.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
85
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_de.js
generated
vendored
Normal file
85
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_de.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function onePrefix_(num, mill = false) {
|
||||
return num === NUMBERS.ones[1] ? (mill ? 'eine' : 'ein') : num;
|
||||
}
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
let ones = NUMBERS.ones[Math.floor(n / 100)];
|
||||
str += ones ? onePrefix_(ones) + 'hundert' : '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? NUMBERS.numSep : '';
|
||||
ones = NUMBERS.ones[n];
|
||||
if (ones) {
|
||||
str += ones;
|
||||
}
|
||||
else {
|
||||
const tens = NUMBERS.tens[Math.floor(n / 10)];
|
||||
ones = NUMBERS.ones[n % 10];
|
||||
str += ones ? onePrefix_(ones) + 'und' + tens : tens;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0) {
|
||||
return 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 = 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() + '.';
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_en.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_en.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
103
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_en.js
generated
vendored
Normal file
103
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_en.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
str += NUMBERS.ones[Math.floor(n / 100)]
|
||||
? NUMBERS.ones[Math.floor(n / 100)] + NUMBERS.numSep + 'hundred'
|
||||
: '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? NUMBERS.numSep : '';
|
||||
str +=
|
||||
NUMBERS.ones[n] ||
|
||||
NUMBERS.tens[Math.floor(n / 10)] +
|
||||
(n % 10 ? NUMBERS.numSep + NUMBERS.ones[n % 10] : '');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0) {
|
||||
return 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 ? '-' + 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';
|
||||
}
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_es.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_es.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
100
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_es.js
generated
vendored
Normal file
100
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_es.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function tensToWords_(num) {
|
||||
const n = num % 100;
|
||||
if (n < 30) {
|
||||
return NUMBERS.ones[n];
|
||||
}
|
||||
const tens = NUMBERS.tens[Math.floor(n / 10)];
|
||||
const ones = 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 = 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 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 = 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 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(NUMBERS.special.hundredsOrdinals[pos - 1]);
|
||||
num = num % 100;
|
||||
}
|
||||
if (num <= 12) {
|
||||
result.push(NUMBERS.special.onesOrdinals[num - 1]);
|
||||
}
|
||||
else {
|
||||
pos = Math.floor(num / 10);
|
||||
if (pos > 0) {
|
||||
result.push(NUMBERS.special.tensOrdinals[pos - 1]);
|
||||
num = num % 10;
|
||||
}
|
||||
if (num > 0) {
|
||||
result.push(NUMBERS.special.onesOrdinals[num - 1]);
|
||||
}
|
||||
}
|
||||
return result.join(' ');
|
||||
}
|
||||
function numericOrdinal(num) {
|
||||
const gender = Grammar.getInstance().getParameter('gender');
|
||||
return num.toString() + (gender === 'f' ? 'a' : 'o');
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_fr.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_fr.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
116
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_fr.js
generated
vendored
Normal file
116
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_fr.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import { Engine } from '../../common/engine.js';
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
str += NUMBERS.ones[Math.floor(n / 100)]
|
||||
? NUMBERS.ones[Math.floor(n / 100)] + '-cent'
|
||||
: '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? '-' : '';
|
||||
let ones = NUMBERS.ones[n];
|
||||
if (ones) {
|
||||
str += ones;
|
||||
}
|
||||
else {
|
||||
const tens = NUMBERS.tens[Math.floor(n / 10)];
|
||||
if (tens.match(/-dix$/)) {
|
||||
ones = NUMBERS.ones[(n % 10) + 10];
|
||||
str += tens.replace(/-dix$/, '') + '-' + ones;
|
||||
}
|
||||
else {
|
||||
str += tens + (n % 10 ? '-' + 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 NUMBERS.zero;
|
||||
}
|
||||
if (num >= Math.pow(10, 36)) {
|
||||
return num.toString();
|
||||
}
|
||||
if (NUMBERS.special['tens-' + Engine.getInstance().subiso]) {
|
||||
NUMBERS.tens = NUMBERS.special['tens-' + Engine.getInstance().subiso];
|
||||
}
|
||||
let pos = 0;
|
||||
let str = '';
|
||||
while (num > 0) {
|
||||
const hundreds = num % 1000;
|
||||
if (hundreds) {
|
||||
let large = 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.getInstance().getParameter('gender');
|
||||
return num === 1
|
||||
? num.toString() + (gender === 'm' ? 'er' : 're')
|
||||
: num.toString() + 'e';
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_hi.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_hi.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
88
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_hi.js
generated
vendored
Normal file
88
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_hi.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
str += NUMBERS.ones[Math.floor(n / 100)]
|
||||
? NUMBERS.ones[Math.floor(n / 100)] +
|
||||
NUMBERS.numSep +
|
||||
NUMBERS.special.hundred
|
||||
: '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? NUMBERS.numSep : '';
|
||||
str += NUMBERS.ones[n];
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0) {
|
||||
return 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 =
|
||||
NUMBERS.ones[thousands] +
|
||||
NUMBERS.numSep +
|
||||
NUMBERS.large[pos] +
|
||||
(str ? NUMBERS.numSep + str : '');
|
||||
}
|
||||
num = Math.floor(num / 100);
|
||||
pos++;
|
||||
}
|
||||
return hundredsWords ? str + NUMBERS.numSep + hundredsWords : str;
|
||||
}
|
||||
function numberToOrdinal(num, _plural) {
|
||||
if (num <= 10) {
|
||||
return NUMBERS.special.smallDenominators[num];
|
||||
}
|
||||
return wordOrdinal(num) + ' अंश';
|
||||
}
|
||||
function wordOrdinal(num) {
|
||||
const gender = Grammar.getInstance().getParameter('gender');
|
||||
if (num <= 0) {
|
||||
return num.toString();
|
||||
}
|
||||
if (num < 10) {
|
||||
return gender === 'f'
|
||||
? NUMBERS.special.ordinalsFeminine[num]
|
||||
: NUMBERS.special.ordinalsMasculine[num];
|
||||
}
|
||||
const ordinal = numberToWords(num);
|
||||
return ordinal + (gender === 'f' ? 'वीं' : 'वाँ');
|
||||
}
|
||||
function numericOrdinal(num) {
|
||||
const gender = Grammar.getInstance().getParameter('gender');
|
||||
if (num > 0 && num < 10) {
|
||||
return gender === 'f'
|
||||
? NUMBERS.special.simpleSmallOrdinalsFeminine[num]
|
||||
: NUMBERS.special.simpleSmallOrdinalsMasculine[num];
|
||||
}
|
||||
const ordinal = num
|
||||
.toString()
|
||||
.split('')
|
||||
.map(function (x) {
|
||||
const num = parseInt(x, 10);
|
||||
return isNaN(num) ? '' : NUMBERS.special.simpleNumbers[num];
|
||||
})
|
||||
.join('');
|
||||
return ordinal + (gender === 'f' ? 'वीं' : 'वाँ');
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_it.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_it.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
83
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_it.js
generated
vendored
Normal file
83
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_it.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
import { Grammar } from '../../rule_engine/grammar.js';
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
str += NUMBERS.ones[Math.floor(n / 100)]
|
||||
? NUMBERS.ones[Math.floor(n / 100)] + NUMBERS.numSep + 'cento'
|
||||
: '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? NUMBERS.numSep : '';
|
||||
const ones = NUMBERS.ones[n];
|
||||
if (ones) {
|
||||
str += ones;
|
||||
}
|
||||
else {
|
||||
let tens = NUMBERS.tens[Math.floor(n / 10)];
|
||||
const rest = n % 10;
|
||||
if (rest === 1 || rest === 8) {
|
||||
tens = tens.slice(0, -1);
|
||||
}
|
||||
str += tens;
|
||||
str += rest ? NUMBERS.numSep + NUMBERS.ones[n % 10] : '';
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0) {
|
||||
return NUMBERS.zero;
|
||||
}
|
||||
if (num >= Math.pow(10, 36)) {
|
||||
return num.toString();
|
||||
}
|
||||
if (num === 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 ? '-' + 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.getInstance().getParameter('gender');
|
||||
const postfix = gender === 'm' ? 'o' : 'a';
|
||||
let ordinal = 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.getInstance().getParameter('gender');
|
||||
return num.toString() + (gender === 'm' ? 'o' : 'a');
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ko.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ko.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
66
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ko.js
generated
vendored
Normal file
66
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_ko.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function thousandsToWords_(num) {
|
||||
let n = num % 10000;
|
||||
let str = '';
|
||||
str += NUMBERS.ones[Math.floor(n / 1000)]
|
||||
? Math.floor(n / 1000) === 1
|
||||
? '천'
|
||||
: NUMBERS.ones[Math.floor(n / 1000)] + '천'
|
||||
: '';
|
||||
n = n % 1000;
|
||||
if (n) {
|
||||
str += NUMBERS.ones[Math.floor(n / 100)]
|
||||
? Math.floor(n / 100) === 1
|
||||
? '백'
|
||||
: NUMBERS.ones[Math.floor(n / 100)] + '백'
|
||||
: '';
|
||||
n = n % 100;
|
||||
str +=
|
||||
NUMBERS.tens[Math.floor(n / 10)] + (n % 10 ? NUMBERS.ones[n % 10] : '');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num) {
|
||||
if (num === 0)
|
||||
return 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 ? NUMBERS.large[pos] + 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 ? '스무' : NUMBERS.tens[10 + Math.floor(num / 10)];
|
||||
const ones = NUMBERS.ones[10 + Math.floor(num % 10)];
|
||||
return ordinal.slice(0, -label.length) + tens + ones;
|
||||
}
|
||||
function numericOrdinal(num) {
|
||||
return numberToOrdinal(num, false);
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nemeth.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nemeth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
13
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nemeth.js
generated
vendored
Normal file
13
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nemeth.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function numberToWords(num) {
|
||||
const digits = num.toString().split('');
|
||||
return digits
|
||||
.map(function (digit) {
|
||||
return NUMBERS.ones[parseInt(digit, 10)];
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToWords
|
||||
});
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nn.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nn.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
160
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nn.js
generated
vendored
Normal file
160
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_nn.js
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
import { Engine } from '../../common/engine.js';
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWordsRo_(num, ordinal = false) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
const count = Math.floor(n / 100);
|
||||
const ones = NUMBERS.ones[count];
|
||||
str += ones ? (count === 1 ? '' : ones) + 'hundre' : '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? 'og' : '';
|
||||
if (ordinal) {
|
||||
const ord = NUMBERS.special.smallOrdinals[n];
|
||||
if (ord) {
|
||||
return str + ord;
|
||||
}
|
||||
if (n % 10) {
|
||||
return (str +
|
||||
NUMBERS.tens[Math.floor(n / 10)] +
|
||||
NUMBERS.special.smallOrdinals[n % 10]);
|
||||
}
|
||||
}
|
||||
str +=
|
||||
NUMBERS.ones[n] ||
|
||||
NUMBERS.tens[Math.floor(n / 10)] + (n % 10 ? NUMBERS.ones[n % 10] : '');
|
||||
}
|
||||
return ordinal ? replaceOrdinal(str) : str;
|
||||
}
|
||||
function numberToWordsRo(num, ordinal = false) {
|
||||
if (num === 0) {
|
||||
return ordinal ? NUMBERS.special.smallOrdinals[0] : 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
|
||||
? ' ' +
|
||||
(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 = NUMBERS.special.endOrdinal[0];
|
||||
if (letOne === 'a' && str.match(/en$/)) {
|
||||
return str.slice(0, -2) + NUMBERS.special.endOrdinal;
|
||||
}
|
||||
if (str.match(/(d|n)$/) || str.match(/hundre$/)) {
|
||||
return str + 'de';
|
||||
}
|
||||
if (str.match(/i$/)) {
|
||||
return str + NUMBERS.special.endOrdinal;
|
||||
}
|
||||
if (letOne === 'a' && str.match(/e$/)) {
|
||||
return str.slice(0, -1) + 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() + '.';
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
function onePrefix_(num, thd = false) {
|
||||
const numOne = 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 = NUMBERS.ones[Math.floor(n / 100)];
|
||||
str += ones ? onePrefix_(ones) + 'hundre' : '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? 'og' : '';
|
||||
if (ordinal) {
|
||||
const ord = NUMBERS.special.smallOrdinals[n];
|
||||
if (ord) {
|
||||
return (str += ord);
|
||||
}
|
||||
}
|
||||
ones = NUMBERS.ones[n];
|
||||
if (ones) {
|
||||
str += ones;
|
||||
}
|
||||
else {
|
||||
const tens = NUMBERS.tens[Math.floor(n / 10)];
|
||||
ones = 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 ? NUMBERS.special.smallOrdinals[0] : 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 ? NUMBERS.numSep : '') +
|
||||
(pos
|
||||
?
|
||||
NUMBERS.large[pos] + (pos > 1 && hundreds > 1 ? 'er' : '')
|
||||
: '') +
|
||||
(pos > 1 && str ? 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.getInstance().subiso === 'alt'
|
||||
? numberToWordsGe(num, ordinal)
|
||||
: numberToWordsRo(num, ordinal);
|
||||
return word;
|
||||
}
|
||||
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_sv.d.ts
generated
vendored
Normal file
2
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_sv.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Numbers } from '../messages.js';
|
||||
export declare const NUMBERS: Numbers;
|
||||
121
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_sv.js
generated
vendored
Normal file
121
node_modules/speech-rule-engine/mjs/l10n/numbers/numbers_sv.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
import { NUMBERS as NUMB } from '../messages.js';
|
||||
function hundredsToWords_(num) {
|
||||
let n = num % 1000;
|
||||
let str = '';
|
||||
const hundreds = Math.floor(n / 100);
|
||||
str += NUMBERS.ones[hundreds]
|
||||
? (hundreds === 1 ? '' : NUMBERS.ones[hundreds] + NUMBERS.numSep) + 'hundra'
|
||||
: '';
|
||||
n = n % 100;
|
||||
if (n) {
|
||||
str += str ? NUMBERS.numSep : '';
|
||||
str +=
|
||||
NUMBERS.ones[n] ||
|
||||
NUMBERS.tens[Math.floor(n / 10)] +
|
||||
(n % 10 ? NUMBERS.numSep + NUMBERS.ones[n % 10] : '');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function numberToWords(num, ordinal = false) {
|
||||
if (num === 0) {
|
||||
return 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 = 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');
|
||||
}
|
||||
export const NUMBERS = NUMB({
|
||||
wordOrdinal: wordOrdinal,
|
||||
numericOrdinal: numericOrdinal,
|
||||
numberToWords: numberToWords,
|
||||
numberToOrdinal: numberToOrdinal
|
||||
});
|
||||
17
node_modules/speech-rule-engine/mjs/l10n/transformers.d.ts
generated
vendored
Normal file
17
node_modules/speech-rule-engine/mjs/l10n/transformers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export type Transformer = (p1: string | number) => string;
|
||||
export type Combiner = (p1: string, p2: string, p3: string) => string;
|
||||
export type SiCombiner = (p1: string, p2: string) => string;
|
||||
export type GrammarCase = (p1: number, p2: boolean) => string;
|
||||
export declare function pluralCase(num: number, _plural: boolean): string;
|
||||
export declare function identityTransformer(input: string | number): string;
|
||||
export declare function siCombiner(prefix: string, unit: string): string;
|
||||
export declare const Combiners: Record<string, Combiner>;
|
||||
interface Convertible {
|
||||
convertible: boolean;
|
||||
content?: string;
|
||||
denominator?: number;
|
||||
enumerator?: number;
|
||||
}
|
||||
export declare function convertVulgarFraction(node: Element, over?: string): Convertible;
|
||||
export declare function vulgarFractionSmall(node: Element, enumer: number, denom: number): boolean;
|
||||
export {};
|
||||
69
node_modules/speech-rule-engine/mjs/l10n/transformers.js
generated
vendored
Normal file
69
node_modules/speech-rule-engine/mjs/l10n/transformers.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import { SemanticRole, SemanticType } from '../semantic_tree/semantic_meaning.js';
|
||||
export function pluralCase(num, _plural) {
|
||||
return num.toString();
|
||||
}
|
||||
export function identityTransformer(input) {
|
||||
return input.toString();
|
||||
}
|
||||
export function siCombiner(prefix, unit) {
|
||||
return prefix + unit.toLowerCase();
|
||||
}
|
||||
export const Combiners = {};
|
||||
Combiners.identityCombiner = function (a, b, c) {
|
||||
return a + b + c;
|
||||
};
|
||||
Combiners.prefixCombiner = function (letter, font, cap) {
|
||||
letter = cap ? cap + ' ' + letter : letter;
|
||||
return font ? font + ' ' + letter : letter;
|
||||
};
|
||||
Combiners.postfixCombiner = function (letter, font, cap) {
|
||||
letter = cap ? cap + ' ' + letter : letter;
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
Combiners.romanceCombiner = function (letter, font, cap) {
|
||||
letter = cap ? letter + ' ' + cap : letter;
|
||||
return font ? letter + ' ' + font : letter;
|
||||
};
|
||||
export function convertVulgarFraction(node, over = '') {
|
||||
if (!node.childNodes ||
|
||||
!node.childNodes[0] ||
|
||||
!node.childNodes[0].childNodes ||
|
||||
node.childNodes[0].childNodes.length < 2 ||
|
||||
node.childNodes[0].childNodes[0].tagName !==
|
||||
SemanticType.NUMBER ||
|
||||
node.childNodes[0].childNodes[0].getAttribute('role') !==
|
||||
SemanticRole.INTEGER ||
|
||||
node.childNodes[0].childNodes[1].tagName !==
|
||||
SemanticType.NUMBER ||
|
||||
node.childNodes[0].childNodes[1].getAttribute('role') !==
|
||||
SemanticRole.INTEGER) {
|
||||
return { convertible: false, content: node.textContent };
|
||||
}
|
||||
const denStr = node.childNodes[0].childNodes[1].textContent;
|
||||
const enumStr = node.childNodes[0].childNodes[0].textContent;
|
||||
const denominator = Number(denStr);
|
||||
const enumerator = Number(enumStr);
|
||||
if (isNaN(denominator) || isNaN(enumerator)) {
|
||||
return {
|
||||
convertible: false,
|
||||
content: `${enumStr} ${over} ${denStr}`
|
||||
};
|
||||
}
|
||||
return {
|
||||
convertible: true,
|
||||
enumerator: enumerator,
|
||||
denominator: denominator
|
||||
};
|
||||
}
|
||||
export function vulgarFractionSmall(node, enumer, denom) {
|
||||
const conversion = convertVulgarFraction(node);
|
||||
if (conversion.convertible) {
|
||||
const enumerator = conversion.enumerator;
|
||||
const denominator = conversion.denominator;
|
||||
return (enumerator > 0 &&
|
||||
enumerator < enumer &&
|
||||
denominator > 0 &&
|
||||
denominator < denom);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user