Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default export in Engine module #744

Merged
merged 4 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ts/audio/abstract_audio_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author [email protected] (Volker Sorge)
*/

import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import { KeyCode } from '../common/event_util.js';
import { AudioRenderer } from './audio_renderer.js';
import { AuditoryDescription } from './auditory_description.js';
Expand Down
2 changes: 1 addition & 1 deletion ts/audio/audio_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import { setdifference } from '../common/base_util.js';
import * as EngineConst from '../common/engine_const.js';
import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import { AuditoryDescription } from './auditory_description.js';
import { Span } from './span.js';

Expand Down
2 changes: 1 addition & 1 deletion ts/audio/aural_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author [email protected] (Volker Sorge)
*/

import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import * as EngineConst from '../common/engine_const.js';
import { AcssRenderer } from './acss_renderer.js';
import { AudioRenderer } from './audio_renderer.js';
Expand Down
2 changes: 1 addition & 1 deletion ts/audio/layout_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { Debugger } from '../common/debugger.js';
import * as DomUtil from '../common/dom_util.js';
import * as EngineConst from '../common/engine_const.js';
import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import * as AudioUtil from './audio_util.js';
import { AuditoryDescription } from './auditory_description.js';
import { XmlRenderer } from './xml_renderer.js';
Expand Down
2 changes: 1 addition & 1 deletion ts/audio/ssml_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author [email protected] (Volker Sorge)
*/

import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import * as EngineConst from '../common/engine_const.js';
import { Pause } from './audio_util.js';
import { AuditoryDescription } from './auditory_description.js';
Expand Down
2 changes: 1 addition & 1 deletion ts/audio/string_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author [email protected] (Volker Sorge)
*/

import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import { AbstractAudioRenderer } from './abstract_audio_renderer.js';
import { personalityMarkup } from './audio_util.js';
import { AuditoryDescription } from './auditory_description.js';
Expand Down
2 changes: 1 addition & 1 deletion ts/common/browser_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author [email protected] (Volker Sorge)
*/

import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';
import { xpath } from './xpath_util.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion ts/common/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { EnginePromise, SREError } from './engine.js';
import * as EngineConst from './engine_const.js';
import * as ProcessorFactory from './processor_factory.js';
import * as System from './system.js';
import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';
import { Variables } from './variables.js';

export class Cli {
Expand Down
2 changes: 1 addition & 1 deletion ts/common/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author [email protected] (Volker Sorge)
*/

import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';

export class Debugger {
private static instance: Debugger;
Expand Down
4 changes: 2 additions & 2 deletions ts/common/dom_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* @author [email protected] (Volker Sorge)
*/

import Engine, { SREError } from './engine.js';
import { Engine, SREError } from './engine.js';
import * as EngineConst from '../common/engine_const.js';
import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';
import * as XpathUtil from './xpath_util.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion ts/common/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class SREError extends Error {
* Initializes the basic Speech engine and contains some global context.
*
*/
export default class Engine {
export class Engine {
/**
* Binary feature vector.
*/
Expand Down
4 changes: 2 additions & 2 deletions ts/common/engine_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import * as L10n from '../l10n/l10n.js';
import * as MathMap from '../speech_rules/math_map.js';
import * as BrowserUtil from './browser_util.js';
import { Debugger } from './debugger.js';
import Engine, { EnginePromise } from './engine.js';
import { Engine, EnginePromise } from './engine.js';
import * as FileUtil from './file_util.js';
import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';

// Engine setup method.
/**
Expand Down
2 changes: 1 addition & 1 deletion ts/common/file_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author [email protected] (Volker Sorge)
*/

import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';

/**
* Corrects pathnames to have trailing slashes.
Expand Down
2 changes: 1 addition & 1 deletion ts/common/processor_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as SpeechGeneratorUtil from '../speech_generator/speech_generator_util.
import * as WalkerFactory from '../walker/walker_factory.js';
import * as WalkerUtil from '../walker/walker_util.js';
import * as DomUtil from './dom_util.js';
import Engine, { SREError } from './engine.js';
import { Engine, SREError } from './engine.js';
import * as EngineConst from '../common/engine_const.js';
import { KeyCode } from './event_util.js';
import { Processor, KeyProcessor } from './processor.js';
Expand Down
4 changes: 2 additions & 2 deletions ts/common/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

import { AuditoryDescription } from '../audio/auditory_description.js';

import Engine, { EnginePromise, SREError } from './engine.js';
import { Engine, EnginePromise, SREError } from './engine.js';
import { setup } from './engine_setup.js';
import * as EngineConst from './engine_const.js';
import { KeyCode } from './event_util.js';
import * as FileUtil from './file_util.js';
import * as ProcessorFactory from './processor_factory.js';
import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';
import { Variables } from './variables.js';
import { standardLoader } from '../speech_rules/math_map.js';

Expand Down
2 changes: 1 addition & 1 deletion ts/common/system_external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare let global: any;
declare let require: (name: string) => any;
declare let process: any;

export default class SystemExternal {
export class SystemExternal {
/**
* The local require function for NodeJS.
*
Expand Down
4 changes: 2 additions & 2 deletions ts/common/xpath_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* @author [email protected] (Volker Sorge)
*/

import Engine from './engine.js';
import { Engine } from './engine.js';
import * as EngineConst from '../common/engine_const.js';
import SystemExternal from './system_external.js';
import { SystemExternal } from './system_external.js';

/**
* Returns whether or not xpath is supported.
Expand Down
2 changes: 1 addition & 1 deletion ts/enrich_mathml/enrich_mathml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import { Debugger } from '../common/debugger.js';
import * as DomUtil from '../common/dom_util.js';
import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import { NamedSymbol } from '../semantic_tree/semantic_attr.js';
import {
SemanticRole,
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/l10n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author [email protected] (Volker Sorge)
*/

import Engine from '../common/engine.js';
import { Engine } from '../common/engine.js';
import { Variables } from '../common/variables.js';
import { Grammar } from '../rule_engine/grammar.js';

Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_af.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { Grammar } from '../../rule_engine/grammar.js';
import { nestingToString } from '../locale_util.js';
import { createLocale, Locale } from '../locale.js';
import NUMBERS from '../numbers/numbers_af.js';
import { NUMBERS } from '../numbers/numbers_af.js';
import * as tr from '../transformers.js';

const germanPostfixCombiner = function (
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { createLocale, Locale } from '../locale.js';
import { combinePostfixIndex } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_ca.js';
import { NUMBERS } from '../numbers/numbers_ca.js';
import { Combiners } from '../transformers.js';

const sansserifCombiner = function (letter: string, font: string, cap: string) {
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import { createLocale, Locale } from '../locale.js';
import { nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_da.js';
import { NUMBERS } from '../numbers/numbers_da.js';
import * as tr from '../transformers.js';

let locale: Locale = null;
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { Grammar } from '../../rule_engine/grammar.js';
import { localFont } from '../locale_util.js';
import { createLocale, Locale } from '../locale.js';
import NUMBERS from '../numbers/numbers_de.js';
import { NUMBERS } from '../numbers/numbers_de.js';

const germanPrefixCombiner = function (
letter: string,
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { Grammar } from '../../rule_engine/grammar.js';
import { createLocale, Locale } from '../locale.js';
import { nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_en.js';
import { NUMBERS } from '../numbers/numbers_en.js';
import * as tr from '../transformers.js';

let locale: Locale = null;
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { createLocale, Locale } from '../locale.js';
import { combinePostfixIndex } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_es.js';
import { NUMBERS } from '../numbers/numbers_es.js';
import { Combiners } from '../transformers.js';

const sansserifCombiner = function (letter: string, font: string, cap: string) {
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { Grammar } from '../../rule_engine/grammar.js';
import { createLocale, Locale } from '../locale.js';
import { combinePostfixIndex, nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_fr.js';
import { NUMBERS } from '../numbers/numbers_fr.js';
import { Combiners } from '../transformers.js';

let locale: Locale = null;
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_hi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//

import { createLocale, Locale } from '../locale.js';
import NUMBERS from '../numbers/numbers_hi.js';
import { NUMBERS } from '../numbers/numbers_hi.js';
import { Combiners } from '../transformers.js';
import { nestingToString } from '../locale_util.js';

Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { combinePostfixIndex, nestingToString } from '../locale_util.js';
import { createLocale, Locale } from '../locale.js';
import NUMBERS from '../numbers/numbers_it.js';
import { NUMBERS } from '../numbers/numbers_it.js';
import { Combiners } from '../transformers.js';

const italianPostfixCombiner = function (
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import { Grammar } from '../../rule_engine/grammar.js';
import { createLocale, Locale } from '../locale.js';
import { nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_ko.js';
import { NUMBERS } from '../numbers/numbers_ko.js';
import * as tr from '../transformers.js';


Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_nb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { createLocale, Locale } from '../locale.js';
import { nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_nn.js';
import { NUMBERS } from '../numbers/numbers_nn.js';
import * as tr from '../transformers.js';

let locale: Locale = null;
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_nemeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//

import { createLocale, Locale } from '../locale.js';
import NUMBERS from '../numbers/numbers_nemeth.js';
import { NUMBERS } from '../numbers/numbers_nemeth.js';
import { identityTransformer } from '../transformers.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_nn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { createLocale, Locale } from '../locale.js';
import { nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_nn.js';
import { NUMBERS } from '../numbers/numbers_nn.js';
import * as tr from '../transformers.js';

let locale: Locale = null;
Expand Down
2 changes: 1 addition & 1 deletion ts/l10n/locales/locale_sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import { createLocale, Locale } from '../locale.js';
import { nestingToString } from '../locale_util.js';
import NUMBERS from '../numbers/numbers_sv.js';
import { NUMBERS } from '../numbers/numbers_sv.js';
import * as tr from '../transformers.js';

let locale: Locale = null;
Expand Down
43 changes: 23 additions & 20 deletions ts/l10n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,36 @@ export interface Numbers {
special?: { [key: string]: string | string[] };

// Constructor methods
wordOrdinal: tr.Transformer;
numericOrdinal: tr.Transformer;
numberToWords: tr.Transformer;
numberToOrdinal: tr.GrammarCase;
wordOrdinal?: tr.Transformer;
numericOrdinal?: tr.Transformer;
numberToWords?: tr.Transformer;
numberToOrdinal?: tr.GrammarCase;

vulgarSep: string;
numSep: string;
vulgarSep?: string;
numSep?: string;
}

/**
* @returns A numbers structure.
*/
export function NUMBERS(): Numbers {
return {
zero: 'zero',
ones: [],
tens: [],
large: [],
special: {},
export function NUMBERS(numbers: 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: ' '
};
wordOrdinal: tr.identityTransformer,
numericOrdinal: tr.identityTransformer,
numberToWords: tr.identityTransformer,
numberToOrdinal: tr.pluralCase,
vulgarSep: ' ',
numSep: ' '
},
numbers
);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions ts/l10n/numbers/numbers_af.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ function numericOrdinal(num: number): string {
return num.toString() + '.';
}

const NUMBERS: Numbers = NUMB();
NUMBERS.wordOrdinal = wordOrdinal;
NUMBERS.numericOrdinal = numericOrdinal;
NUMBERS.numberToWords = numberToWords;
NUMBERS.numberToOrdinal = numberToOrdinal;

export default NUMBERS;
export const NUMBERS: Numbers = NUMB(
{
'wordOrdinal': wordOrdinal,
'numericOrdinal': numericOrdinal,
'numberToWords': numberToWords,
'numberToOrdinal': numberToOrdinal,
}
);
Loading
Loading