Intl.Segmenter
Input
Output
granularity
{
granularity: "word"
}
[
{
"segment": "This",
"index": 0,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence.",
"isWordLike": false
},
{
"segment": "is",
"index": 5,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence.",
"isWordLike": false
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence.",
"isWordLike": false
},
{
"segment": "sentence",
"index": 10,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence.",
"isWordLike": false
}
]
{
granularity: "sentence"
}
[
{
"segment": "This is a sentence.",
"index": 0,
"input": "This is a sentence."
}
]
{
granularity: "grapheme"
}
[
{
"segment": "T",
"index": 0,
"input": "This is a sentence."
},
{
"segment": "h",
"index": 1,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 2,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 3,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 5,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 6,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence."
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 10,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 11,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 12,
"input": "This is a sentence."
},
{
"segment": "t",
"index": 13,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 14,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 15,
"input": "This is a sentence."
},
{
"segment": "c",
"index": 16,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 17,
"input": "This is a sentence."
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence."
}
]
localeMatcher
{
localeMatcher: "best fit"
}
[
{
"segment": "T",
"index": 0,
"input": "This is a sentence."
},
{
"segment": "h",
"index": 1,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 2,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 3,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 5,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 6,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence."
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 10,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 11,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 12,
"input": "This is a sentence."
},
{
"segment": "t",
"index": 13,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 14,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 15,
"input": "This is a sentence."
},
{
"segment": "c",
"index": 16,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 17,
"input": "This is a sentence."
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence."
}
]
{
localeMatcher: "lookup"
}
[
{
"segment": "T",
"index": 0,
"input": "This is a sentence."
},
{
"segment": "h",
"index": 1,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 2,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 3,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 5,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 6,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence."
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 10,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 11,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 12,
"input": "This is a sentence."
},
{
"segment": "t",
"index": 13,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 14,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 15,
"input": "This is a sentence."
},
{
"segment": "c",
"index": 16,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 17,
"input": "This is a sentence."
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence."
}
]