Function segment

  • Segments the input text into an array of strings.

    Parameters

    • text: string

      A string to be segmented.

    Returns string[]

    An array of strings, where each string is a segment of the input text.

    import { segment } from 'charabia-js';

    segment("Hello, world!") // [ 'Hello', ', ', 'world', '!' ]
    segment("你好,世界!") // [ '你好', ',', '世界', '!' ]
    segment("Hello, 世界!") // [ 'Hello', ', ', '世界', '!' ]")