function assertSegments(string, words) {
let seg = segmenter.segment(string);
let segments = [...seg];
// The computed segments match the expected value.
assertEqArray(segments.map(({segment}) => segment), words);
// |containing()| should return the same result. for (let expected of segments) {
let {segment, index} = expected; for (let i = index; i < index + segment.length; ++i) {
let actual = seg.containing(i);
assertDeepEq(actual, expected);
}
}
}
let segmenter = new Intl.Segmenter("en", {granularity: "word"});
for (let [string, words] of Object.entries(strings)) {
assertSegments(string, words);
}
// WB3, WB3a, WB3b and WB4 for (let string of ["\r\n", "\n", "\r", "\v", "\f", "\x85"]) {
assertSegments(string + "\xAD", [string, "\xAD"]);
assertSegments("\xAD" + string, ["\xAD", string]);
}
// CLDR has locale-dependent word segmentation for the "en-posix" locale. This // locale is currently not selectable, so the Latin-1 fast-paths don't need to // implement it. If one of the two below assertions ever fail, please update // the Latin-1 fast-paths for word segmentation to implement the "en-posix" // changes.
assertEq(new Intl.Segmenter("en-posix").resolvedOptions().locale, "en");
assertEq(new Intl.Segmenter("en-u-va-posix").resolvedOptions().locale, "en");
if (typeof reportCompare === "function")
reportCompare(0, 0);
Messung V0.5
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.