Skip to main content

Text

Compare two strings and return the intersection or difference, use overlap to find the matching characters between the two strings, or use similarity to get a numeric similarity score.

Compare two strings and return the intersection or difference, or use overlap to find the matching characters between the two strings.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
I/O
inputThe columns to compare. First column is the base column.array—Yes
outputThe column to output the results to. Must be a list of two column names [mask_column, ratio_column] when method is overlap and include_ratio is true; otherwise a single column name.string, array—Yes
Options
methodThe type of comparison to perform (difference, intersection, overlap, similarity).string; one of:
  • difference
  • intersection
  • overlap
  • similarity
"difference"No
charCharacter to split strings on for difference and intersection. Defaults to a space.string" "No
exact_matchValue to use for exact matches when using overlap.string, nullnullNo
empty_aValue to use when input A is empty when using overlap.string, nullnullNo
empty_bValue to use when input B is empty when using overlap.string, nullnullNo
all_emptyValue to use when both inputs are empty when using overlap.string, nullnullNo
case_sensitiveWhether the comparison is case sensitive. Defaults to true.booleanfalseNo
metricMetric value accepted by the runtime.string"token_sort"No
Formatting
non_match_charCharacter to use for non-matching characters when using overlap.string"*"No
include_ratioInclude the ratio of matching characters when using overlap.booleanfalseNo
decimal_placesNumber of decimal places to round the overlap ratio to.integer3No
Conditions
ifCondition that determines whether the wrangle runs as a whole. Recipe variables may be referenced with ${variable}.string—No
whereFilter rows before applying the wrangle using SQL-like criteria, such as column1 = 123 OR column2 = 'abc'.string—No
where_paramsValues used with where for parameterized criteria. Uses SQLite placeholder syntax such as ? or :name.array, object—No

Examples​

wrangles:
- compare.text:
input:
- col1
- col2
output: Difference
method: difference
Col1Col2
Large Oak Wood White Marble Top BookshelfLarge Pine Wood Black Marble Bottom Bookshelf
Medium Oak Wood White Marble Top Coffee TableMedium Maple Wood Orange Steel Top Coffee Table
Small Oak Wood White Marble Top Console TableSmall Normal Wood Blue Plastic Top Console Table
Difference
Pine Black Bottom
Maple Orange Steel
Normal Blue Plastic
wrangles:
- compare.text:
input:
- col1
- col2
output: Intersection
method: intersection
Col1Col2
Large Oak Wood White Marble Top BookshelfLarge Pine Wood Black Marble Bottom Bookshelf
Medium Oak Wood White Marble Top Coffee TableMedium Maple Wood Orange Steel Top Coffee Table
Small Oak Wood White Marble Top Console TableSmall Normal Wood Blue Plastic Top Console Table
Intersection
Large Wood Marble Bookshelf
Medium Wood Top Coffee Table
Small Wood Top Console Table
wrangles:
- compare.text:
input:
- Part Code1
- Part Code2
output: Overlap
method: overlap
Part Code1Part Code2
SKF6202TMKN6202
X06-02-000X06-81-000
7100E15-V-230/37100E15-V-120/1
Overlap
****6202
X06-**-000
7100E15-V-**0/*
Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID2
Catalog keycompare.text
Recipe keycompare.text
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleYes
Namespacecompare
Documentation groupcompare
AliasesNone
Runtime symbolwrangles.recipe_wrangles.compare.text
Legacy UUID31905b74-ce58-45cd-8add-821cc04ab946

Sources