cldr-segmentation
Version:
CLDR text segmentation for JavaScript
22 lines (18 loc) • 643 B
HTML
<html>
<head>
<script src='./node_modules/utfstring/utfstring.js'></script>
<script src='./dist/cldr-segmentation.js'></script>
</head>
<body>
<script type='text/javascript'>
var breakIter = new cldrSegmentation.BreakIterator(cldrSegmentation.suppressions.en);
var text = "I like Mrs. Patterson, she's nice.";
breakIter.eachSentence(text, function(str, start, stop) {
console.log("'" + str + "': " + start + ", " + stop);
});
breakIter.eachWord(text, function(str, start, stop) {
console.log("'" + str + "': " + start + ", " + stop);
});
</script>
</body>
</html>