From 374f0dfd8eb275eefd8fd23ded66ff047d645b4f Mon Sep 17 00:00:00 2001 From: Eddie Antonio Santos Date: Tue, 19 May 2020 14:34:11 -0600 Subject: [PATCH] Revert "refactor(common/lmlayer): move placeholder word breaker to @keymanapp/lexical-model-word-breakers" This reverts commit 73b16ae33eb62f08247fbcb1afe0fca032f3df97. --- common/models/wordbreakers/src/index.ts | 5 +--- common/models/wordbreakers/src/placeholder.ts | 21 ---------------- .../test/test-placeholder-word-breaker.ts | 4 ++-- .../word_breaking/placeholder-word-breaker.ts | 24 +++++++++++++++++++ 4 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 common/models/wordbreakers/src/placeholder.ts create mode 100644 common/predictive-text/worker/word_breaking/placeholder-word-breaker.ts diff --git a/common/models/wordbreakers/src/index.ts b/common/models/wordbreakers/src/index.ts index c3dd1420d2..ea1cc87eea 100644 --- a/common/models/wordbreakers/src/index.ts +++ b/common/models/wordbreakers/src/index.ts @@ -1,6 +1,3 @@ import {ascii} from "./ascii"; -import {placeholder} from './placeholder'; -import {default_} from "./default"; -export {ascii, placeholder}; -export {default_ as default}; +export {ascii}; diff --git a/common/models/wordbreakers/src/placeholder.ts b/common/models/wordbreakers/src/placeholder.ts deleted file mode 100644 index 7924b196e4..0000000000 --- a/common/models/wordbreakers/src/placeholder.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * A **VERY** dumb word breaker that simply splits at words. Do not use this - * word breaker! - * - * @param phrase The phrase in which to break words. - * @deprecated Use a word breaker tailored to your language instead! - */ -export function placeholder(phrase: string): Span[] { - let nextStart = 0; - return phrase.split(/\s+/).map(utterance => { - // XXX: The indices are NOT accurate to the original phrase! - let span = { - start: nextStart, - end: nextStart + utterance.length, - text: utterance, - length: utterance.length - }; - nextStart = span.end; - return span; - }); -} diff --git a/common/models/wordbreakers/test/test-placeholder-word-breaker.ts b/common/models/wordbreakers/test/test-placeholder-word-breaker.ts index dadd9cbd5f..7a90b0b34d 100644 --- a/common/models/wordbreakers/test/test-placeholder-word-breaker.ts +++ b/common/models/wordbreakers/test/test-placeholder-word-breaker.ts @@ -1,11 +1,11 @@ import {assert} from 'chai'; -import {placeholder as breakWords} from '../src'; +import {placeholder as breakWords} from '../' describe.skip('The placeholder word breaker', function () { it('should break simple English sentences', function () { let breaks = breakWords('Look! -- The quick brown fox jumps... over the lazy dog!'); let words = breaks.map(span => span.text); - assert.deepEqual(words, ['Look!', '--', 'The', 'quick', 'brown', 'fox', 'jumps...', 'over', 'the', 'lazy', 'dog!']); + assert.deepEqual(words, ['Look', 'The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']); }); }); diff --git a/common/predictive-text/worker/word_breaking/placeholder-word-breaker.ts b/common/predictive-text/worker/word_breaking/placeholder-word-breaker.ts new file mode 100644 index 0000000000..1105b89fb9 --- /dev/null +++ b/common/predictive-text/worker/word_breaking/placeholder-word-breaker.ts @@ -0,0 +1,24 @@ +namespace wordBreakers { + + /** + * A **VERY** dumb word breaker that simply splits at words. Do not use this + * word breaker! + * + * @param phrase The phrase in which to break words. + * @deprecated Use a word breaker tailored to your language instead! + */ + export function placeholder(phrase: string): Span[] { + let nextStart = 0; + return phrase.split(/\s+/).map(utterance => { + // XXX: The indices are NOT accurate to the original phrase! + let span = { + start: nextStart, + end: nextStart + utterance.length, + text: utterance, + length: utterance.length + }; + nextStart = span.end; + return span; + }); + } +}