WordCount - Maple Help

StringTools

 Words
 split a string into words
 WordCount
 count the number of words in a string

 Calling Sequence Words( s ) WordCount( s )

Parameters

 s - Maple string

Description

 • The Words(s) command splits a string into its constituent words. A list of the words in the input string s, in order, is returned. The non-word characters in the string are elided from the output.
 • The WordCount(s) command counts the number of words in a given string s.
 • A word is defined to be a maximal contiguous sequence of alphanumeric characters or the apostrophe character ('). Words are delimited by non-word characters.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{Words}\left("This is a sentence."\right)$
 $\left[{"This"}{,}{"is"}{,}{"a"}{,}{"sentence"}\right]$ (1)
 > $\mathrm{WordCount}\left("This is a sentence."\right)$
 ${4}$ (2)
 > $\mathrm{Words}\left("The Word command correctly parses a word with an apostrophe, like isn\text{'}t, as a single word."\right)$
 $\left[{"The"}{,}{"Word"}{,}{"command"}{,}{"correctly"}{,}{"parses"}{,}{"a"}{,}{"word"}{,}{"with"}{,}{"an"}{,}{"apostrophe"}{,}{"like"}{,}{"isn\text{'}t"}{,}{"as"}{,}{"a"}{,}{"single"}{,}{"word"}\right]$ (3)
 > $\mathrm{WordCount}\left("The WordCount command correctly counts a word with an apostrophe, like isn\text{'}t, as a single word."\right)$
 ${16}$ (4)
 > $\mathrm{Words}\left("The Words command ignores punctuation, like colons \left(:\right); this is very useful!"\right)$
 $\left[{"The"}{,}{"Words"}{,}{"command"}{,}{"ignores"}{,}{"punctuation"}{,}{"like"}{,}{"colons"}{,}{"this"}{,}{"is"}{,}{"very"}{,}{"useful"}\right]$ (5)
 > $\mathrm{WordCount}\left("The WordCount command also ignores punctuation, like colons \left(:\right); this is very useful!"\right)$
 ${12}$ (6)