joinWords - Convert documents to string by joining words - MATLAB (original) (raw)

Main Content

Convert documents to string by joining words

Syntax

Description

[newStr](#mw%5F35ea6bce-6fd8-416d-a463-5aa07a02df9a) = joinWords([documents](#d126e29377)) converts a tokenizedDocument array to a string array by joining the words in each document with a space.

example

[newStr](#mw%5F35ea6bce-6fd8-416d-a463-5aa07a02df9a) = joinWords([documents](#d126e29377),[delim](#d126e29393)) joins the words with delimiter delim instead of a space.

example

Examples

collapse all

Convert a tokenizedDocument array to a string array by joining the words with a space.

documents = tokenizedDocument([ "an example of a short sentence" "a second short sentence"])

documents = 2×1 tokenizedDocument:

6 tokens: an example of a short sentence
4 tokens: a second short sentence

str = joinWords(documents)

str = 2×1 string "an example of a short sentence" "a second short sentence"

Convert a tokenizedDocument array to a string array by joining the words with an underscore.

str = joinWords(documents,"_")

str = 2×1 string "an_example_of_a_short_sentence" "a_second_short_sentence"

Input Arguments

collapse all

Delimiter to join words, specified as a string scalar, character vector, or scalar cell array containing a character vector.

Example: "_"

Example: '_'

Example: {'_'}

Data Types: char | string | cell

Output Arguments

collapse all

Output text, returned as a string array.

Data Types: string

Version History

Introduced in R2017b