SlideShare a Scribd company logo

Fuzzy search in Ruby

Visuality
Visuality

Fuzzy Search in Ruby by Paweł Strzałkowski. How to find and replace when you don't really know what to look for.

1 of 20
Download to read offline
Fuzzy Text Search in Ruby
How to find and replace when you
don't really know what to look for
Paweł Strzałkowski
Task: Replace company name with "The Company" in a job offer description
Take
- Job offer description
- Company name
Task: Replace company name with "The Company" in a job offer description
Take
- Job offer description
- Company name
Simple?
> description.gsub(company_name, 'The Company')
Task: Replace company name with "The Company" in a job offer description
Thank you for your attention
Take
- Job offer description
- Company name
Simple?
> description.gsub(company_name, 'The Company')
Task: Replace company name with "The Company" in a job offer description
Take
- Job offer description
- Company name
Simple?
Not so much (misspells, custom usages of the company name)
> description.gsub(company_name, 'The Company')
Fuzzy Text Comparison: Definition
Fuzzy - difficult to perceive clearly or understand and explain precisely; indistinct or
vague
Fuzzy text comparison doesn't answer whether phrases match
but defines their similarity
Example: Jaro–Winkler similarity level of:
- 1 means phrases are equal
- 0 means phrases are completely different
- Something in-between means some level of difference
Ad

Recommended

3 issues that made 30 test workers take 40 minutes
3 issues that made 30 test workers take 40 minutes3 issues that made 30 test workers take 40 minutes
3 issues that made 30 test workers take 40 minutesVisuality
 
Czego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówCzego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówVisuality
 
Introduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsIntroduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsVisuality
 
Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Visuality
 
Introduction to Event Storming
Introduction to Event StormingIntroduction to Event Storming
Introduction to Event StormingVisuality
 
Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Visuality
 
SVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateSVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateVisuality
 
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...Visuality
 

More Related Content

More from Visuality

How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiHow to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiVisuality
 
What is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarWhat is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarVisuality
 
Do you really need to reload?
Do you really need to reload?Do you really need to reload?
Do you really need to reload?Visuality
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)Visuality
 
Fantastic stresses and where to find them
Fantastic stresses and where to find themFantastic stresses and where to find them
Fantastic stresses and where to find themVisuality
 
Rfc process in visuality
Rfc process in visualityRfc process in visuality
Rfc process in visualityVisuality
 
GraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsGraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsVisuality
 
Consumer Driven Contracts
Consumer Driven ContractsConsumer Driven Contracts
Consumer Driven ContractsVisuality
 
How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?Visuality
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introductionVisuality
 
Risk in project management
Risk in project managementRisk in project management
Risk in project managementVisuality
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formattersVisuality
 
Proxying api calls
Proxying api callsProxying api calls
Proxying api callsVisuality
 
Gogo Conference 2018
Gogo Conference 2018Gogo Conference 2018
Gogo Conference 2018Visuality
 
Pair programming- Mariusz Kozieł
Pair programming- Mariusz KoziełPair programming- Mariusz Kozieł
Pair programming- Mariusz KoziełVisuality
 
Introduction to R Language
Introduction to R LanguageIntroduction to R Language
Introduction to R LanguageVisuality
 
Dashing, smashing, party crashing
Dashing, smashing, party crashingDashing, smashing, party crashing
Dashing, smashing, party crashingVisuality
 
Progressive Enhancement - Umit Naimian
Progressive Enhancement - Umit NaimianProgressive Enhancement - Umit Naimian
Progressive Enhancement - Umit NaimianVisuality
 
From idea to concept - webinar by Michał Krochecki
From idea to concept - webinar by Michał KrocheckiFrom idea to concept - webinar by Michał Krochecki
From idea to concept - webinar by Michał KrocheckiVisuality
 
Immutability and Javascript - Nadia Miętkiewicz
Immutability and Javascript - Nadia MiętkiewiczImmutability and Javascript - Nadia Miętkiewicz
Immutability and Javascript - Nadia MiętkiewiczVisuality
 

More from Visuality (20)

How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiHow to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
 
What is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarWhat is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak Aybar
 
Do you really need to reload?
Do you really need to reload?Do you really need to reload?
Do you really need to reload?
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)
 
Fantastic stresses and where to find them
Fantastic stresses and where to find themFantastic stresses and where to find them
Fantastic stresses and where to find them
 
Rfc process in visuality
Rfc process in visualityRfc process in visuality
Rfc process in visuality
 
GraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsGraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basics
 
Consumer Driven Contracts
Consumer Driven ContractsConsumer Driven Contracts
Consumer Driven Contracts
 
How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introduction
 
Risk in project management
Risk in project managementRisk in project management
Risk in project management
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formatters
 
Proxying api calls
Proxying api callsProxying api calls
Proxying api calls
 
Gogo Conference 2018
Gogo Conference 2018Gogo Conference 2018
Gogo Conference 2018
 
Pair programming- Mariusz Kozieł
Pair programming- Mariusz KoziełPair programming- Mariusz Kozieł
Pair programming- Mariusz Kozieł
 
Introduction to R Language
Introduction to R LanguageIntroduction to R Language
Introduction to R Language
 
Dashing, smashing, party crashing
Dashing, smashing, party crashingDashing, smashing, party crashing
Dashing, smashing, party crashing
 
Progressive Enhancement - Umit Naimian
Progressive Enhancement - Umit NaimianProgressive Enhancement - Umit Naimian
Progressive Enhancement - Umit Naimian
 
From idea to concept - webinar by Michał Krochecki
From idea to concept - webinar by Michał KrocheckiFrom idea to concept - webinar by Michał Krochecki
From idea to concept - webinar by Michał Krochecki
 
Immutability and Javascript - Nadia Miętkiewicz
Immutability and Javascript - Nadia MiętkiewiczImmutability and Javascript - Nadia Miętkiewicz
Immutability and Javascript - Nadia Miętkiewicz
 

Recently uploaded

H3 Platform CXL Solution_Memory Fabric Forum.pptx
H3 Platform CXL Solution_Memory Fabric Forum.pptxH3 Platform CXL Solution_Memory Fabric Forum.pptx
H3 Platform CXL Solution_Memory Fabric Forum.pptxMemory Fabric Forum
 
The Future of Product, by Founder & CEO, Product School
The Future of Product, by Founder & CEO, Product SchoolThe Future of Product, by Founder & CEO, Product School
The Future of Product, by Founder & CEO, Product SchoolProduct School
 
Bit N Build Poland
Bit N Build PolandBit N Build Poland
Bit N Build PolandGDSC PJATK
 
Enhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for PartnersEnhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for PartnersThousandEyes
 
Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)
Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)
Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)Memory Fabric Forum
 
"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys VasylievFwdays
 
Artificial-Intelligence-in-Marketing-Data.pdf
Artificial-Intelligence-in-Marketing-Data.pdfArtificial-Intelligence-in-Marketing-Data.pdf
Artificial-Intelligence-in-Marketing-Data.pdfIsidro Navarro
 
AWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS Chicago
 
How we think about an advisor tech stack
How we think about an advisor tech stackHow we think about an advisor tech stack
How we think about an advisor tech stackSummit
 
Breaking Barriers & Leveraging the Latest Developments in AI Technology
Breaking Barriers & Leveraging the Latest Developments in AI TechnologyBreaking Barriers & Leveraging the Latest Developments in AI Technology
Breaking Barriers & Leveraging the Latest Developments in AI TechnologySafe Software
 
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!XfilesPro
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17Ana-Maria Mihalceanu
 
Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxMaarten Balliauw
 
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24Umar Saif
 
My sample product research idea for you!
My sample product research idea for you!My sample product research idea for you!
My sample product research idea for you!KivenRaySarsaba
 
Building Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish GuptaBuilding Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish GuptaISPMAIndia
 
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, GoogleISPMAIndia
 
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre..."Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...shaiyuvasv
 
Q1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXL
Q1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXLQ1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXL
Q1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXLMemory Fabric Forum
 
Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?MENGSAYLOEM1
 

Recently uploaded (20)

H3 Platform CXL Solution_Memory Fabric Forum.pptx
H3 Platform CXL Solution_Memory Fabric Forum.pptxH3 Platform CXL Solution_Memory Fabric Forum.pptx
H3 Platform CXL Solution_Memory Fabric Forum.pptx
 
The Future of Product, by Founder & CEO, Product School
The Future of Product, by Founder & CEO, Product SchoolThe Future of Product, by Founder & CEO, Product School
The Future of Product, by Founder & CEO, Product School
 
Bit N Build Poland
Bit N Build PolandBit N Build Poland
Bit N Build Poland
 
Enhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for PartnersEnhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for Partners
 
Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)
Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)
Q1 Memory Fabric Forum: Intel Enabling Compute Express Link (CXL)
 
"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev
 
Artificial-Intelligence-in-Marketing-Data.pdf
Artificial-Intelligence-in-Marketing-Data.pdfArtificial-Intelligence-in-Marketing-Data.pdf
Artificial-Intelligence-in-Marketing-Data.pdf
 
AWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user group
 
How we think about an advisor tech stack
How we think about an advisor tech stackHow we think about an advisor tech stack
How we think about an advisor tech stack
 
Breaking Barriers & Leveraging the Latest Developments in AI Technology
Breaking Barriers & Leveraging the Latest Developments in AI TechnologyBreaking Barriers & Leveraging the Latest Developments in AI Technology
Breaking Barriers & Leveraging the Latest Developments in AI Technology
 
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
 
Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptx
 
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
Progress Report: Ministry of IT under Dr. Umar Saif Aug 23-Feb'24
 
My sample product research idea for you!
My sample product research idea for you!My sample product research idea for you!
My sample product research idea for you!
 
Building Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish GuptaBuilding Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish Gupta
 
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
"The Transformative Power of AI and Open Challenges" by Dr. Manish Gupta, Google
 
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre..."Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
 
Q1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXL
Q1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXLQ1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXL
Q1 Memory Fabric Forum: Memory Processor Interface 2023, Focus on CXL
 
Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?Are Human-generated Demonstrations Necessary for In-context Learning?
Are Human-generated Demonstrations Necessary for In-context Learning?
 

Fuzzy search in Ruby

  • 1. Fuzzy Text Search in Ruby How to find and replace when you don't really know what to look for Paweł Strzałkowski
  • 2. Task: Replace company name with "The Company" in a job offer description Take - Job offer description - Company name
  • 3. Task: Replace company name with "The Company" in a job offer description Take - Job offer description - Company name Simple? > description.gsub(company_name, 'The Company')
  • 4. Task: Replace company name with "The Company" in a job offer description Thank you for your attention Take - Job offer description - Company name Simple? > description.gsub(company_name, 'The Company')
  • 5. Task: Replace company name with "The Company" in a job offer description Take - Job offer description - Company name Simple? Not so much (misspells, custom usages of the company name) > description.gsub(company_name, 'The Company')
  • 6. Fuzzy Text Comparison: Definition Fuzzy - difficult to perceive clearly or understand and explain precisely; indistinct or vague Fuzzy text comparison doesn't answer whether phrases match but defines their similarity Example: Jaro–Winkler similarity level of: - 1 means phrases are equal - 0 means phrases are completely different - Something in-between means some level of difference
  • 7. Fuzzy Text Comparison: Examples > require 'fuzzy-string-match' > # (... create a wrapper as fuzzy_similarity method ...) > fuzzy_similarity "Lorem Ipsum Dorem", "a" => 0.0 > fuzzy_similarity "Lorem Ipsum Dorem", "Visuality Test" => 0.4393162393162393 > fuzzy_similarity "Visuality", "Visuality" => 1.0
  • 8. How to find and replace fuzzy matched phrases in a longer text? Library? - Not found... Best practice? - Not found... Custom solution? - Let's do it!
  • 9. Fuzzy Text Comparison: Assumption #1 - Assumed some level of similarity to be considered "equal" - Didn't know whether it should be 0.7 or 0.99 so went with something in- between and tweaked - It ended up being 0.9 - Whenever it is said that "phrases are equal in fuzzy-matching context", it means that their Jaro-Winkler similarity is more than 0.9
  • 10. Fuzzy Text Comparison: Assumption #2 - Searched phrase may be longer or shorter than the given term - 1 word longer - 2 words longer - 3 words longer > fuzzy_similarity "Lorem Ipsum Dorem", "Lorem Ipsum Dorem Carem" => 0.9791666666666666 > fuzzy_similarity "Lorem Ipsum Dorem", "Lorem Ipsum Dorem Carem Visuarem" => 0.9281462585034014 > fuzzy_similarity "Lorem Ipsum Dorem", "Lorem Ipsum Dorem Carem Visuarem Odolanem" => 0.8865740740740742
  • 11. Fuzzy Text Comparison: Assumption Summary - Phrases are equal if their similarity level is more than 0.9 - Matching phrase might be up to 2 words longer than the searched one
  • 12. Algorithm (at last) Assignment: Take a story, find the name "Mary Joan" and replace it with "The Girl" to make it anonymous. We'll start (and finish) with the story title. Title: Mary S Jane of house Visuality Problem: Somebody has - taken a wrong Mary - used an additional middle initial We now have "Mary S Jane" instead of "Mary Joan" in the story.
  • 13. Algorithm: Step 1 - Break Into Pieces - Searched phrase (Mary Joan) is 2 words long - Maximal matching phrase length is 4 "Mary S Jane of house Visuality".break_into_pieces_of(4) => (N == 1) => ["Mary", "S", "Jane", "of", "house", "Visuality"] (N == 2) => ["Mary S", "S Jane", "Jane of", "of house", "house Visuality"] (N == 3) => ["Mary S Jane", "S Jane of", "of house Visuality"] (N == 4) => ["Mary S Jane of", "S Jane of house", "Jane of house Visuality"]
  • 14. Algorithm: Step 1 - Break Into Pieces (Excercise) - Take some of the created phrases - Check how similar they are to the searched term > fuzzy_similarity "Mary Joan" , "of house Visuality" => 0.4583333333333333 > fuzzy_similarity "Mary Joan" , "Mary S" => 0.86 > fuzzy_similarity "Mary Joan" , "Mary S Jane of" => 0.9156336088154271 > fuzzy_similarity "Mary Joan" , "Mary S Jane" => 0.9305555555555555 << Equal << Equal
  • 15. Algorithm: Step 2 - Choose best results Mary S Jane of S Jane of 0.92 Mary S Jane 0.510.93 S JaneMary S 0.380.86
  • 16. Algorithm: Ta - Daaaaa > FuzzyText.new( "Mary S Jane of house Visuality", "Mary Joan" ).matches => ["Mary S Jane"]
  • 17. Algorithm: Tweaks and Gotchas - Skip characters which make the fuzzy comparison blurry - Punctuation - White characters - Saxon genitives - 's - Common words (when applicable, ie. "is", "are", "was", "were" etc.) - Compare only once - Use a hash table containing the results of every comparison - Cache the results - TDD
  • 18. English is too easy, let's take a bit more challenging language > hero = "Kapitan Ameryka" > description = "Wbrew powszechnej opinii o Kapitanie z Ameryki nie był on pierwszym superbohaterem wykorzystującym tematykę flagi Stanów Zjednoczonych. Poprzedzał go superbohater o pseudonimie Shield czternaście miesięcy wcześniej niż Kapitan Ameryka. Shield nosił na sobie pancerny kostium z kuloodporną tarczą na piersi (zwraca się uwagę na uderzające podobieństwo do wczesnej tarczy Kapitana Ameryki, która w późniejszych wydaniach była już okrągła). Na dodatek obie postacie łączyła podobna geneza: Shield tak jak bohater Marvela zyskał nadludzkie moce po zażyciu serum superżołnierza, którego twórca został zabity przez hitlerowców. Postać Kapitana Ameryki pojawiała się w wielu różnych adaptacjach."
  • 19. English is too easy, let's take a bit more challenging language > hero = "Kapitan Ameryka" > description = "Wbrew powszechnej opinii o Kapitanie z Ameryki nie był on pierwszym superbohaterem wykorzystującym tematykę flagi Stanów Zjednoczonych. Poprzedzał go superbohater o pseudonimie Shield czternaście miesięcy wcześniej niż Kapitan Ameryka. Shield nosił na sobie pancerny kostium z kuloodporną tarczą na piersi (zwraca się uwagę na uderzające podobieństwo do wczesnej tarczy Kapitana Ameryki, która w późniejszych wydaniach była już okrągła). Na dodatek obie postacie łączyła podobna geneza: Shield tak jak bohater Marvela zyskał nadludzkie moce po zażyciu serum superżołnierza, którego twórca został zabity przez hitlerowców. Postać Kapitana Ameryki pojawiała się w wielu różnych adaptacjach." > FuzzyText.new(description, hero).matches => ["Kapitanie z Ameryki", "Kapitan Ameryka", "Kapitana Ameryki", "Kapitana", "Kapitanie", "Kapitan"]
  • 20. Thank you for your attention Questions?