mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-06 17:05:34 +00:00
Revert "refactor(common/lmlayer): move placeholder word breaker to @keymanapp/lexical-model-word-breakers"
This reverts commit 73b16ae33e.
This commit is contained in:
parent
6fc39df5d0
commit
374f0dfd8e
4 changed files with 27 additions and 27 deletions
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
@ -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']);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue