SlideShare una empresa de Scribd logo
1 de 54
Descargar para leer sin conexión
They’re not equal!
How the <<expletive>> do you expect me to find a
                    match?




                            kyle.burton@gmail.com
                            http://asymmetrical-view.com/
                            PLUG August 6th 2008
How Do You Spell ...?

• De Morgan
• Di Morgen
•   D’Morgun
•   Demorgyn
•   De Murgen
•   Dy Moregan      Er, So How Can You
•
•
    Dy Murgan

    Da Myrgn
                        Find a Match?
Fuzzy Matching, That’s how


•   Partial Matching
•   Phonetic Encodings
•   String Similarity Metrics
How’d We Get Here?


•   US Census Bureau
• William Winkler (not the Fonz)
How’d We Get Here?

• Record Linkage, aka Duplicate Detection
 •   My Company Does This! (it’s a complex problem domain)




• DNA Comparison and Sequence Alignment
 •   (I don’t do this, but it sounds cool on Tv)
•   Partial Matching
•   Phonetic Encodings
•   String Similarity Metrics
Partial Matching

• ‘False’ Fuzziness: prefix, suffix, infix
• SQL’s ‘%’ operator
• n-grams (bi-grams, tri-grams)
 • foobar => foo, oob, oba, bar
 • This is infix in disguise
Partial Matching
• Indexable - fast lookup / search
• Fixed Degree of ‘Fuzziness’
• Doesn’t scale based on difference
 • Any hit and you have a match
 • Can’t Measure Quality of the match
• Not going into any detail...you get it.
•   Partial Matching
•   Phonetic Encodings
•   String Similarity Metrics
Phonetic Encodings


• Soundex, NYSIIS, Double Metaphone
• ‘hash’ of input
• Fixed fuzziness, one or two degrees
Soundex
• Keep the First Character
• Convert Vowels (and some soft
  consonants) to a Zero [AEHIOUWY]
• [BFPV] => 1
• [CGJKQSXZ] => 2
• and so on (read the code)
Soundex

• B635 <= Burton, Barton
• G232 <= Gwozdziewycz, Gwozdz
• D562 <= De Morgen, Di Morgen,
  D’Morgun, Demorgyn, De Murgen, Dy
  Moregan, Dy Murgan, Da Morgan, Da Myrgn
How Do They Compare?

• Soundex, Metaphone, Nysiis
• US Census Name File
 •   http://www.census.gov/genealogy/names/names_files.html

 •   Useless Fact: 1% of the unique names cover 50% of
     population

 •   Aalderink is the least frequent

 •   Smith is the most frequent
US Census Name Files
• dist.all.last:
 •      SMITH       1.006   1.006   1

 •      JOHNSON     0.810   1.816   2

 •      WILLIAMS    0.699   2.515   3

• dist.male.first
 •      JAMES       3.318   3.318   1

 •      JOHN        3.271   6.589   2

 •      ROBERT      3.143   9.732   3
Phoneta-battle to the Death!


•Last Names:        88,799
•Soundex:             4,599 =>        1/20th
•Metaphone:         18,317 =>         1/5th
•NYSIIS:            31,149 =>         1/3rd


(sorry, got a little carried away for a second there)
Phonetic Can’t Catch Everything


•   Transcription Errors
    •Typos
•   Transmission Errors
    •Data Corruption
•   Abbreviations, Contractions
    Acronyms (oh my!)
•   Partial Matching
•   Phonetic Encodings
•   String Similarity Metrics
• Indexing Strategies
Get Your Fuzzy On

• Simpletons:
 • ascii frequency, keyboard distance
• Edit Distance and Variants
 • Levenshtein, Wu-Manber, Jaro-Winkler
    and others
Edit Distance
• Given S1 and S2
• Initialize a Matrix of S1.len+1 x S2.len+1
• Initialize First Row With Default Costs:
 • (0,1,2,3,...,S1.len)
• First Column too:
 • (0,1,2,3,...,S2.len)
• ...
Edit Distance
           B     U    R        T   O   N
    0      1     2    3        4   5   6
B   1
A   2
R   3
T   4
O   5
N   6

        There, that’s better
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0
A   2
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1
A   2
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2
A   2
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3
A   2
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3   4
A   2
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3   4   5
A   2
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3   4   5
A   2   1   1   2   3   4   5
R   3
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3   4   5
A   2   1   1   2   3   4   5
R   3   2   2   1   2   3   4
T   4
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3   4   5
A   2   1   1   2   3   4   5
R   3   2   2   1   2   3   4
T   4   3   3   2   1   2   3
O   5
N   6
Edit Distance
        B   U   R   T   O   N
    0   1   2   3   4   5   6
B   1   0   1   2   3   4   5
A   2   1   1   2   3   4   5
R   3   2   2   1   2   3   4
T   4   3   3   2   1   2   3
O   5   4   4   3   2   1   2
N   6
Edit Distance
        B     U      R   T   O   N
    0   1     2      3   4   5   6
B   1   0     1      2   3   4   5
A   2   1     1      2   3   4   5
R   3   2     2      1   2   3   4
T   4   3     3      2   1   2   3
O   5   4     4      3   2   1   2
N   6   5     5      4   3   2   1

            Voila!
Edit Distance



•   Wanna see it again?
Edit Distance
         B   A   B   Y
     0   1   2   3   4
B    1   0   1   2   3
O    2   1   1   2   3
B    3   2   2   1   2
B    4   3   3   2   2
Y    5   4   4   3   2
Edit Distance

• De Morgan vs De Morgan 0 100%
• De_Morgan vs D'Morgun 3 64%
• De_Morgan vs Demorgyn 3 64%
• De Morgan vs De Murgen 2 77%
• De Morgan vs Dy Moregan 2 78%
Text Brew

• Configurable Costs:
 • Match, Insert, Delete, Substitute
• Saves Edit Path
Text Brew
    EDITS: ((INITIAL * ) (MATCH B B) (DEL O B) (SUBST B A) (MATCH B B) (MATCH Y Y))



                                 B                     A                    B             Y
            0.0                1.0,INS              2.0,INS              3.0,INS        4.0,INS


B        1.0,DEL           0.0,MAT,B,B           1.0,INS,B,A          2.0,MAT,B,B     3.0,INS,B,Y


O        2.0,DEL           1.0,DEL,O,B          1.0,SUB,O,A          2.0,SUB,O,B      3.0,SUB,O,Y


B        3.0,DEL           2.0,MAT,B,B          2.0,SUB,B,A           1.0,MAT,B,B     2.0,INS,B,Y


B        4.0,DEL           3.0,MAT,B,B          3.0,SUB,B,A           2.0,MAT,B,B     2.0,SUB,B,Y


Y        5.0,DEL            4.0,DEL,Y,B          4.0,SUB,Y,A          3.0,DEL,Y,B     2.0,MAT,Y,Y
Text Brew

 MATCH       0.0

  INSERT     0.1

 DELETE      15

SUBSTITUTE   1.0
Text Brew

• Hosp vs Hospital => 0.4, 93%
 • Levenshtein: 4, 67%
• Clmbs Blvd vs Columbus Boulevard => 0.8, 94%
 • Levenshtein: 8, 57%
Indexing Strategies
Indexing Edit Distance


• Method A:You’re Peter Norvig
• Pre-generate the table of all possible
  strings within N-edits of your
  dictionary
Indexing Edit Distance
• Method B (you’re me)
 • given a threshold (eg: 70%)
 • given an input string, S (say L=10)
 • there is a max # of edit (E=3)
 • there is a minimum shared substring
   (X) for any other string which is
   within 70% of S
Indexing Edit Distance [B]


 • L=10, T=70%
 • ‘1234567890’
 • ‘12_45_78_0’
Indexing Edit Distance [B]


• ~600k last names
• T=67%, L>2
• Fits in ram in a JVM
Conclusion
• You Too Can Match Fuzzily
 • Partial Matches
 • Phonetic Encodings
 • Edit Distance Family
• (We’re Hiring)
References
•   http://en.wikipedia.org/wiki/Soundex

•   http://en.wikipedia.org/wiki/New_York_State_Identification_and_Intelligence_System

•   http://en.wikipedia.org/wiki/Double_Metaphone

•   http://en.wikipedia.org/wiki/Levenshtein_distance

•   http://norvig.com/spell-correct.html

•   http://en.wikipedia.org/wiki/Jaro-Winkler

•   http://search.cpan.org/~kcivey/Text-Brew-0.02/lib/Text/Brew.pm

•   http://asymmetrical-view.com/talks/fuzzy-string/
Fin
(Questions? Examples? Want Background on
     Soundex, Nysiis and Metaphone?)
Soundex

• Robert Russel and Margaret Odell
• Patented in 1918 and 1922!
• Heavy use by Census Bureau from 1890
  through 1920
• Popularized in TAOCP
NYSIIS

• New York State Immunization Information
  System
• Circa 1970
• 2.7% better than Soundex
• Targeted at Names
NYSIIS
• I can describe what Nysiis does, but not why
  (I’m not a linguist)
• Drop Trailing SZs
• ^MAC => MC
• ^PF => F
• and so on (see the example code)
NYSIIS

• Burton, Barton => BARTAN
• Gwozdziewycz => GWASDSAC
• Gwozdz => GWASD
Double Metaphone

• Lawrence Phillips, derived from Metaphone
• Primary and alternate encodings are possible
• Helps account for irregularities across multiple
  languages
  • eg: English, Slavic, Germanic, Celtic, Greek,
    French, Italian, Spanish...(atw)
Double Metaphone

• I can describe what Metaphone does, but
  not why (is this getting old yet?)
• Lots and Lots of special rules...
• and so on (see the example code)
Double Metaphone

• Burton, Barton => PRTN
• Gwozdziewycz => KSTSS
• Gwozdz => KSTS
Fin
(For Real This Time)

Más contenido relacionado

Último

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Fuzzy String Matching

  • 1. They’re not equal! How the <<expletive>> do you expect me to find a match? kyle.burton@gmail.com http://asymmetrical-view.com/ PLUG August 6th 2008
  • 2. How Do You Spell ...? • De Morgan • Di Morgen • D’Morgun • Demorgyn • De Murgen • Dy Moregan Er, So How Can You • • Dy Murgan Da Myrgn Find a Match?
  • 3. Fuzzy Matching, That’s how • Partial Matching • Phonetic Encodings • String Similarity Metrics
  • 4. How’d We Get Here? • US Census Bureau • William Winkler (not the Fonz)
  • 5. How’d We Get Here? • Record Linkage, aka Duplicate Detection • My Company Does This! (it’s a complex problem domain) • DNA Comparison and Sequence Alignment • (I don’t do this, but it sounds cool on Tv)
  • 6. Partial Matching • Phonetic Encodings • String Similarity Metrics
  • 7. Partial Matching • ‘False’ Fuzziness: prefix, suffix, infix • SQL’s ‘%’ operator • n-grams (bi-grams, tri-grams) • foobar => foo, oob, oba, bar • This is infix in disguise
  • 8. Partial Matching • Indexable - fast lookup / search • Fixed Degree of ‘Fuzziness’ • Doesn’t scale based on difference • Any hit and you have a match • Can’t Measure Quality of the match • Not going into any detail...you get it.
  • 9. Partial Matching • Phonetic Encodings • String Similarity Metrics
  • 10. Phonetic Encodings • Soundex, NYSIIS, Double Metaphone • ‘hash’ of input • Fixed fuzziness, one or two degrees
  • 11. Soundex • Keep the First Character • Convert Vowels (and some soft consonants) to a Zero [AEHIOUWY] • [BFPV] => 1 • [CGJKQSXZ] => 2 • and so on (read the code)
  • 12. Soundex • B635 <= Burton, Barton • G232 <= Gwozdziewycz, Gwozdz • D562 <= De Morgen, Di Morgen, D’Morgun, Demorgyn, De Murgen, Dy Moregan, Dy Murgan, Da Morgan, Da Myrgn
  • 13. How Do They Compare? • Soundex, Metaphone, Nysiis • US Census Name File • http://www.census.gov/genealogy/names/names_files.html • Useless Fact: 1% of the unique names cover 50% of population • Aalderink is the least frequent • Smith is the most frequent
  • 14. US Census Name Files • dist.all.last: • SMITH 1.006 1.006 1 • JOHNSON 0.810 1.816 2 • WILLIAMS 0.699 2.515 3 • dist.male.first • JAMES 3.318 3.318 1 • JOHN 3.271 6.589 2 • ROBERT 3.143 9.732 3
  • 15. Phoneta-battle to the Death! •Last Names: 88,799 •Soundex: 4,599 => 1/20th •Metaphone: 18,317 => 1/5th •NYSIIS: 31,149 => 1/3rd (sorry, got a little carried away for a second there)
  • 16. Phonetic Can’t Catch Everything • Transcription Errors •Typos • Transmission Errors •Data Corruption • Abbreviations, Contractions Acronyms (oh my!)
  • 17. Partial Matching • Phonetic Encodings • String Similarity Metrics • Indexing Strategies
  • 18. Get Your Fuzzy On • Simpletons: • ascii frequency, keyboard distance • Edit Distance and Variants • Levenshtein, Wu-Manber, Jaro-Winkler and others
  • 19. Edit Distance • Given S1 and S2 • Initialize a Matrix of S1.len+1 x S2.len+1 • Initialize First Row With Default Costs: • (0,1,2,3,...,S1.len) • First Column too: • (0,1,2,3,...,S2.len) • ...
  • 20. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 A 2 R 3 T 4 O 5 N 6 There, that’s better
  • 21. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 A 2 R 3 T 4 O 5 N 6
  • 22. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 A 2 R 3 T 4 O 5 N 6
  • 23. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 A 2 R 3 T 4 O 5 N 6
  • 24. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 A 2 R 3 T 4 O 5 N 6
  • 25. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 A 2 R 3 T 4 O 5 N 6
  • 26. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 5 A 2 R 3 T 4 O 5 N 6
  • 27. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 5 A 2 1 1 2 3 4 5 R 3 T 4 O 5 N 6
  • 28. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 5 A 2 1 1 2 3 4 5 R 3 2 2 1 2 3 4 T 4 O 5 N 6
  • 29. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 5 A 2 1 1 2 3 4 5 R 3 2 2 1 2 3 4 T 4 3 3 2 1 2 3 O 5 N 6
  • 30. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 5 A 2 1 1 2 3 4 5 R 3 2 2 1 2 3 4 T 4 3 3 2 1 2 3 O 5 4 4 3 2 1 2 N 6
  • 31. Edit Distance B U R T O N 0 1 2 3 4 5 6 B 1 0 1 2 3 4 5 A 2 1 1 2 3 4 5 R 3 2 2 1 2 3 4 T 4 3 3 2 1 2 3 O 5 4 4 3 2 1 2 N 6 5 5 4 3 2 1 Voila!
  • 32. Edit Distance • Wanna see it again?
  • 33. Edit Distance B A B Y 0 1 2 3 4 B 1 0 1 2 3 O 2 1 1 2 3 B 3 2 2 1 2 B 4 3 3 2 2 Y 5 4 4 3 2
  • 34. Edit Distance • De Morgan vs De Morgan 0 100% • De_Morgan vs D'Morgun 3 64% • De_Morgan vs Demorgyn 3 64% • De Morgan vs De Murgen 2 77% • De Morgan vs Dy Moregan 2 78%
  • 35. Text Brew • Configurable Costs: • Match, Insert, Delete, Substitute • Saves Edit Path
  • 36. Text Brew EDITS: ((INITIAL * ) (MATCH B B) (DEL O B) (SUBST B A) (MATCH B B) (MATCH Y Y)) B A B Y 0.0 1.0,INS 2.0,INS 3.0,INS 4.0,INS B 1.0,DEL 0.0,MAT,B,B 1.0,INS,B,A 2.0,MAT,B,B 3.0,INS,B,Y O 2.0,DEL 1.0,DEL,O,B 1.0,SUB,O,A 2.0,SUB,O,B 3.0,SUB,O,Y B 3.0,DEL 2.0,MAT,B,B 2.0,SUB,B,A 1.0,MAT,B,B 2.0,INS,B,Y B 4.0,DEL 3.0,MAT,B,B 3.0,SUB,B,A 2.0,MAT,B,B 2.0,SUB,B,Y Y 5.0,DEL 4.0,DEL,Y,B 4.0,SUB,Y,A 3.0,DEL,Y,B 2.0,MAT,Y,Y
  • 37. Text Brew MATCH 0.0 INSERT 0.1 DELETE 15 SUBSTITUTE 1.0
  • 38. Text Brew • Hosp vs Hospital => 0.4, 93% • Levenshtein: 4, 67% • Clmbs Blvd vs Columbus Boulevard => 0.8, 94% • Levenshtein: 8, 57%
  • 40. Indexing Edit Distance • Method A:You’re Peter Norvig • Pre-generate the table of all possible strings within N-edits of your dictionary
  • 41. Indexing Edit Distance • Method B (you’re me) • given a threshold (eg: 70%) • given an input string, S (say L=10) • there is a max # of edit (E=3) • there is a minimum shared substring (X) for any other string which is within 70% of S
  • 42. Indexing Edit Distance [B] • L=10, T=70% • ‘1234567890’ • ‘12_45_78_0’
  • 43. Indexing Edit Distance [B] • ~600k last names • T=67%, L>2 • Fits in ram in a JVM
  • 44. Conclusion • You Too Can Match Fuzzily • Partial Matches • Phonetic Encodings • Edit Distance Family • (We’re Hiring)
  • 45. References • http://en.wikipedia.org/wiki/Soundex • http://en.wikipedia.org/wiki/New_York_State_Identification_and_Intelligence_System • http://en.wikipedia.org/wiki/Double_Metaphone • http://en.wikipedia.org/wiki/Levenshtein_distance • http://norvig.com/spell-correct.html • http://en.wikipedia.org/wiki/Jaro-Winkler • http://search.cpan.org/~kcivey/Text-Brew-0.02/lib/Text/Brew.pm • http://asymmetrical-view.com/talks/fuzzy-string/
  • 46. Fin (Questions? Examples? Want Background on Soundex, Nysiis and Metaphone?)
  • 47. Soundex • Robert Russel and Margaret Odell • Patented in 1918 and 1922! • Heavy use by Census Bureau from 1890 through 1920 • Popularized in TAOCP
  • 48. NYSIIS • New York State Immunization Information System • Circa 1970 • 2.7% better than Soundex • Targeted at Names
  • 49. NYSIIS • I can describe what Nysiis does, but not why (I’m not a linguist) • Drop Trailing SZs • ^MAC => MC • ^PF => F • and so on (see the example code)
  • 50. NYSIIS • Burton, Barton => BARTAN • Gwozdziewycz => GWASDSAC • Gwozdz => GWASD
  • 51. Double Metaphone • Lawrence Phillips, derived from Metaphone • Primary and alternate encodings are possible • Helps account for irregularities across multiple languages • eg: English, Slavic, Germanic, Celtic, Greek, French, Italian, Spanish...(atw)
  • 52. Double Metaphone • I can describe what Metaphone does, but not why (is this getting old yet?) • Lots and Lots of special rules... • and so on (see the example code)
  • 53. Double Metaphone • Burton, Barton => PRTN • Gwozdziewycz => KSTSS • Gwozdz => KSTS