mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-16 05:39:24 +00:00
24 lines
679 B
TypeScript
24 lines
679 B
TypeScript
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;
|
|
});
|
|
}
|
|
}
|