compute the n-grams of a string - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Miscellaneous Utilities : StringTools/NGrams

StringTools[NGrams] - compute the n-grams of a string

Calling Sequence

NGrams( s, n )

Parameters

s

-

string

n

-

non-negative (32-bit) integer

Description

• 

The NGrams(s, n) command computes the ordered list of n-grams of the string s. The second argument n must be a 32-bit positive integer no larger than the length of s.

• 

An n-gram of s is a substring of s consisting of exactly n contiguous characters from s.

• 

The empty string  has no n-grams, for any value of n.

• 

Note that NGrams( s, 1 ) is equivalent to Explodes.

Examples

withStringTools:

NGramsabcd,1

a,b,c,d

(1)

NGramsabcd,2

ab,bc,cd

(2)

NGramsabcd,3

abc,bcd

(3)

NGramsabcd,4

abcd

(4)

NGramsmathematics,3

mat,ath,the,hem,ema,mat,ati,tic,ics

(5)

See Also

length, StringTools, StringTools[Explode], StringTools[SimilarityCoefficient]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam