StringTools - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Distances and Metrics : StringTools/PrefixDistance

StringTools

  

PrefixDistance

  

compute the prefix distance between two strings

  

SuffixDistance

  

compute the suffix distance between two strings

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

PrefixDistance( s, t )

SuffixDistance( s, t )

Parameters

s

-

Maple string

t

-

Maple string

Description

• 

The PrefixDistance(s,t) and SuffixDistance(s,t) commands return integer measures of the distance between the two strings s and t.

• 

Let s and t be arbitrary strings. The prefix distance PrefixDistance( s, t ) is defined to be lengths+lengtht2CommonPrefixs,t, and the suffix distance SuffixDistances,t is defined, similarly, to be lengths+lengtht2CommonSuffixs,t. Both are metrics.

• 

Other string metrics available in this package include StringTools[HammingDistance] and StringTools[Levenshtein].

Examples

useStringToolsinPrefixDistanceMathematics,Mathematischeend use

6

(1)

withStringTools:

PrefixDistanceabc,abd

2

(2)

PrefixDistanceabc,abcd

1

(3)

PrefixDistanceElisabeth,Elyse

10

(4)

PrefixDistanceConnor,Constance

9

(5)

SuffixDistancefoe,Defoe

2

(6)

SuffixDistanceNorth America,Central America

12

(7)

SuffixDistanceNorth America,South America

6

(8)

SuffixDistanceabba,abba

0

(9)

Being metrics, both PrefixDistance and SuffixDistance satisfy the triangle inequality.

sRandom10,'binary'

s:=0000101110

(10)

tRandom10,'binary'

t:=1101110100

(11)

uRandom10,'binary'

u:=0100010001

(12)

SuffixDistances,t

18

(13)

SuffixDistances,u+SuffixDistanceu,t

40

(14)

See Also

string

StringTools

StringTools[CommonPrefix]

StringTools[CommonSuffix]

StringTools[HammingDistance]

StringTools[Levenshtein]

 


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