StringSimilarity Function Example | Teradata Vantage - StringSimilarity Example: Specify Column Names - Teradata® Database

Database Analytic Functions

Product
Teradata® Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/wnd1589838592459.ditamap
dita:ditavalPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/ayr1485454803741.ditaval
dita:id
B035-1206
lifecycle
previous
Product Category
Teradata Vantage™

Input

strsimilarity_input
id src_text1 src_text2 tar_text
1 astre astter aster
2 hone fone phone
3 acqiese acquire acquiesce
4 AAAACCCCCGGGGA CCCGGGAACCAACC CCAGGGAAACCCAC
5 alice allen allies
6 angela angle angels
7 senter center centre
8 chef cheap chief
9 circus circle circuit
10 debt debut debris
11 deal dell lead
12 bare bear bear

SQL Call

SELECT * FROM StringSimilarity (
  ON strsimilarity_input PARTITION BY ANY
  USING
  ComparisonColumnPairs ('jaro (src_text1, tar_text) AS jaro1_sim',
                         'LD (src_text1, tar_text) AS ld1_sim',
                         'n_gram (src_text1, tar_text, 2) AS ngram1_sim',
                         'jaro_winkler (src_text1, tar_text, 0.1) AS jw1_sim'
  )
  CaseSensitive ('true')
  Accumulate ('id', 'src_text1', 'tar_text')
) AS dt ORDER BY id;

Output

Columns 1-3
id src_text1 tar_text
1 astre aster
2 hone phone
3 acqiese acquiesce
4 AAAACCCCCGGGGA CCAGGGAAACCCAC
5 alice allies
6 angela angels
7 senter centre
8 chef chief
9 circus circuit
10 debt debris
11 deal lead
12 bare bear
Columns 4-7
jaro1_sim ld1_sim ngram1_sim jw1_sim
0.933333333333333 0.6 0.5 0.953333333333333
0.933333333333333 0.8 0.75 0.933333333333333
0.925925925925926 0.777777777777778 0.5 0.948148148148148
0.824175824175824 0.214285714285714 0.384615384615385 0.824175824175824
0.822222222222222 0.5 0.4 0.857777777777778
0.888888888888889 0.833333333333333 0.8 0.933333333333333
0.822222222222222 0.5 0.4 0.822222222222222
0.933333333333333 0.8 0.5 0.946666666666667
0.849206349206349 0.714285714285714 0.666666666666667 0.90952380952381
0.75 0.5 0.4 0.825
0.666666666666667 0.5 0.333333333333333 0.666666666666667
0.833333333333333 0.5 0.333333333333333 0.85