original_docstring: Generate and rank the homoglyph replacements in the domain name.
  
          Parameters:
          domain      The domain name being analyzed
          naked       The "naked" domain name (name without the TLD) being analyzed
          tld         The top level domain (TLD) of the domain name being analyzed
          
docstring: Generate and rank the homoglyph replacements in the domain name.
  Parameters:
  domain      The domain name being analyzed
  naked       The "naked" domain name (name without the TLD) being analyzed
  tld         The top level domain (TLD) of the domain name being analyzed
docstring_tokens: Generate and rank the homoglyph replacements in the domain name . Parameters : domain The domain name being analyzed naked The " naked " domain name ( name without the TLD ) being analyzed tld The top level domain ( TLD ) of the domain name being analyzed
code: def generate_homoglyphs(self,domain,naked,tld):
          """Generate and rank the homoglyph replacements in the domain name.
  
          Parameters:
          domain      The domain name being analyzed
          naked       The "naked" domain name (name without the TLD) being analyzed
          tld         The top level domain (TLD) of the domain name being analyzed
          """
          # Replacements with rankings
          replacers = [
              ('rn','m',1.0), # rn and m are high!
              ('l','t',1.0),  # l and t are high!
              ('r','i',0.6),  # r and i are medium, if you squint!
              ('n','m',0.6),  # n and m are medium
              ('d','cl',0.6), # d and cl are medium, spacing stands out
              ('vv','w',0.6), # vv and w are medium, spacing stands out
              ('l','i',0.3),  # l and i are medium/low, l is too tall and stands out
              ('j','i',0.3),  # j and i are low, j sticks out below
              ('l','1',0.3),  # l and 1 are low, 1 stands out due to width 
              ('o','c',0.3),  # o and c are low
              ('u','v',0.3),  # u and v are low
              ('nn','m',0.3), # nn and m are low
          ]
          # Favor replacements that occur towards the middle of the domain
          # Ddd the quadrant rank to the replacement rank to favor the ranking
          # Quadrant rank order: 3rd, 2nd, 4th, 1st
          quadrant_rank = {
              1:0.01,
              2:0.03,
              3:0.04,
              4:0.02,
          }
          domains = []
          replacements = []
          # Find all the candidate replacements
          for search,replace,rank in replacers:
              for pos in list(self.find_all(search,naked)):
                  replacements.append((search,replace,pos,rank))
              for pos in list(self.find_all(replace,naked)):
                  replacements.append((replace,search,pos,rank))
          # First pass of single replacements
          for find,replace,pos,rank in replacements:
              candidate = naked[:pos] + replace + naked[pos+len(find):]
              final_rank = rank + quadrant_rank[self.quadrantize(pos,naked)]
              domains.append(('%s.%s' % (candidate,tld),final_rank))
          # TODO: second pass of multiple replacements to provide more quantity
          # We could also do alternate TLDs with single pass
          return domains
code_tokens: def generate_homoglyphs ( self , domain , naked , tld ) : replacers = [ ( 'rn' , 'm' , 1.0 ) , ( 'l' , 't' , 1.0 ) , ( 'r' , 'i' , 0.6 ) , ( 'n' , 'm' , 0.6 ) , ( 'd' , 'cl' , 0.6 ) , ( 'vv' , 'w' , 0.6 ) , ( 'l' , 'i' , 0.3 ) , ( 'j' , 'i' , 0.3 ) , ( 'l' , '1' , 0.3 ) , ( 'o' , 'c' , 0.3 ) , ( 'u' , 'v' , 0.3 ) , ( 'nn' , 'm' , 0.3 ) , ] quadrant_rank = { 1 : 0.01 , 2 : 0.03 , 3 : 0.04 , 4 : 0.02 , } domains = [ ] replacements = [ ] for search , replace , rank in replacers : for pos in list ( self . find_all ( search , naked ) ) : replacements . append ( ( search , replace , pos , rank ) ) for pos in list ( self . find_all ( replace , naked ) ) : replacements . append ( ( replace , search , pos , rank ) ) for find , replace , pos , rank in replacements : candidate = naked [ : pos ] + replace + naked [ pos + len ( find ) : ] final_rank = rank + quadrant_rank [ self . quadrantize ( pos , naked ) ] domains . append ( ( '%s.%s' % ( candidate , tld ) , final_rank ) ) return domains
short_docstring: Generate and rank the homoglyph replacements in the domain name.
short_docstring_tokens: Generate and rank the homoglyph replacements in the domain name .
comment: """Generate and rank the homoglyph replacements in the domain name.
  
          Parameters:
          domain      The domain name being analyzed
          naked       The "naked" domain name (name without the TLD) being analyzed
          tld         The top level domain (TLD) of the domain name being analyzed
          """$SEP$# Replacements with rankings$SEP$# rn and m are high!$SEP$# l and t are high!$SEP$# r and i are medium, if you squint!$SEP$# n and m are medium$SEP$# d and cl are medium, spacing stands out$SEP$# vv and w are medium, spacing stands out$SEP$# l and i are medium/low, l is too tall and stands out$SEP$# j and i are low, j sticks out below$SEP$# l and 1 are low, 1 stands out due to width $SEP$# o and c are low$SEP$# u and v are low$SEP$# nn and m are low$SEP$# Favor replacements that occur towards the middle of the domain$SEP$# Ddd the quadrant rank to the replacement rank to favor the ranking$SEP$# Quadrant rank order: 3rd, 2nd, 4th, 1st$SEP$# Find all the candidate replacements$SEP$# First pass of single replacements$SEP$# TODO: second pass of multiple replacements to provide more quantity$SEP$# We could also do alternate TLDs with single pass