module EmailDomainTypoFinder

Overview

Find email addresses whose domain looks like a typo of a common mailbox domain.

Defined in:

email_domain_typo_finder.cr

Constant Summary

DEFAULT_DOMAINS = ["gmail.com", "yahoo.com", "outlook.com", "hotmail.com", "icloud.com", "aol.com", "proton.me", "live.com", "msn.com"] of ::String
MIN_LENGTH_FOR_DISTANCE_2 = 6

A domain shorter than this only counts as a typo at distance 1.

VERSION = "1.0.0"

Class Method Summary

Class Method Detail

def self.check(text : String, extra : Array(String) = [] of String) : Result #

[View source]
def self.distance(a : String, b : String) : Int32 #

Levenshtein edit distance (insert, delete, substitute; each costs 1).


[View source]
def self.parse_domains(text : String) : Array(String) #

Reads a list of domains, one per line. Blank lines are skipped.


[View source]
def self.render(result : Result) : String #

[View source]
def self.suggest(domain : String, known : Array(String)) : Tuple(String, Int32) | Nil #

The one known domain this domain is a typo of, with its distance, or nil.


[View source]