nodes: 0, module; 1, function_definition; 2, function_name:WRatio; 3, parameters; 4, block; 5, identifier:s1; 6, identifier:s2; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, if_statement; 13, comment:# should we look at partials?; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, comment:# if strings are similar length, don't use partials; 20, if_statement; 21, comment:# if one string is much much shorter than the other; 22, if_statement; 23, if_statement; 24, identifier:force_ascii; 25, True; 26, identifier:full_process; 27, True; 28, comment:"""
      Return a measure of the sequences' similarity between 0 and 100, using different algorithms.
  
      **Steps in the order they occur**
  
      #. Run full_process from utils on both strings
      #. Short circuit if this makes either string empty
      #. Take the ratio of the two processed strings (fuzz.ratio)
      #. Run checks to compare the length of the strings
          * If one of the strings is more than 1.5 times as long as the other
            use partial_ratio comparisons - scale partial results by 0.9
            (this makes sure only full results can return 100)
          * If one of the strings is over 8 times as long as the other
            instead scale by 0.6
  
      #. Run the other ratio functions
          * if using partial ratio functions call partial_ratio,
            partial_token_sort_ratio and partial_token_set_ratio
            scale all of these by the ratio based on length
          * otherwise call token_sort_ratio and token_set_ratio
          * all token based comparisons are scaled by 0.95
            (on top of any partial scalars)
  
      #. Take the highest value from these results
         round it and return it as an integer.
  
      :param s1:
      :param s2:
      :param force_ascii: Allow only ascii characters
      :type force_ascii: bool
      :full_process: Process inputs, used here to avoid double processing in extract functions (Default: True)
      :return:
      """; 29, identifier:full_process; 30, block; 31, else_clause; 32, not_operator; 33, block; 34, not_operator; 35, block; 36, assignment; 37, assignment; 38, assignment; 39, assignment; 40, assignment; 41, comparison_operator:len_ratio < 1.5; 42, block; 43, comparison_operator:len_ratio > 8; 44, block; 45, identifier:try_partial; 46, block; 47, else_clause; 48, expression_statement; 49, expression_statement; 50, block; 51, call; 52, return_statement; 53, call; 54, return_statement; 55, identifier:try_partial; 56, True; 57, identifier:unbase_scale; 58, float:.95; 59, identifier:partial_scale; 60, float:.90; 61, identifier:base; 62, call; 63, identifier:len_ratio; 64, binary_operator:float(max(len(p1), len(p2))) / min(len(p1), len(p2)); 65, identifier:len_ratio; 66, float:1.5; 67, expression_statement; 68, identifier:len_ratio; 69, integer:8; 70, expression_statement; 71, expression_statement; 72, expression_statement; 73, expression_statement; 74, return_statement; 75, block; 76, assignment; 77, assignment; 78, expression_statement; 79, expression_statement; 80, attribute; 81, argument_list; 82, integer:0; 83, attribute; 84, argument_list; 85, integer:0; 86, identifier:ratio; 87, argument_list; 88, call; 89, call; 90, assignment; 91, assignment; 92, assignment; 93, assignment; 94, assignment; 95, call; 96, expression_statement; 97, expression_statement; 98, return_statement; 99, identifier:p1; 100, call; 101, identifier:p2; 102, call; 103, assignment; 104, assignment; 105, identifier:utils; 106, identifier:validate_string; 107, identifier:p1; 108, identifier:utils; 109, identifier:validate_string; 110, identifier:p2; 111, identifier:p1; 112, identifier:p2; 113, identifier:float; 114, argument_list; 115, identifier:min; 116, argument_list; 117, identifier:try_partial; 118, False; 119, identifier:partial_scale; 120, float:.6; 121, identifier:partial; 122, binary_operator:partial_ratio(p1, p2) * partial_scale; 123, identifier:ptsor; 124, binary_operator:partial_token_sort_ratio(p1, p2, full_process=False) \
              * unbase_scale * partial_scale; 125, identifier:ptser; 126, binary_operator:partial_token_set_ratio(p1, p2, full_process=False) \
              * unbase_scale * partial_scale; 127, attribute; 128, argument_list; 129, assignment; 130, assignment; 131, call; 132, attribute; 133, argument_list; 134, attribute; 135, argument_list; 136, identifier:p1; 137, identifier:s1; 138, identifier:p2; 139, identifier:s2; 140, call; 141, call; 142, call; 143, call; 144, identifier:partial_scale; 145, binary_operator:partial_token_sort_ratio(p1, p2, full_process=False) \
              * unbase_scale; 146, identifier:partial_scale; 147, binary_operator:partial_token_set_ratio(p1, p2, full_process=False) \
              * unbase_scale; 148, identifier:partial_scale; 149, identifier:utils; 150, identifier:intr; 151, call; 152, identifier:tsor; 153, binary_operator:token_sort_ratio(p1, p2, full_process=False) * unbase_scale; 154, identifier:tser; 155, binary_operator:token_set_ratio(p1, p2, full_process=False) * unbase_scale; 156, attribute; 157, argument_list; 158, identifier:utils; 159, identifier:full_process; 160, identifier:s1; 161, keyword_argument; 162, identifier:utils; 163, identifier:full_process; 164, identifier:s2; 165, keyword_argument; 166, identifier:max; 167, argument_list; 168, identifier:len; 169, argument_list; 170, identifier:len; 171, argument_list; 172, identifier:partial_ratio; 173, argument_list; 174, call; 175, line_continuation:\; 176, identifier:unbase_scale; 177, call; 178, line_continuation:\; 179, identifier:unbase_scale; 180, identifier:max; 181, argument_list; 182, call; 183, identifier:unbase_scale; 184, call; 185, identifier:unbase_scale; 186, identifier:utils; 187, identifier:intr; 188, call; 189, identifier:force_ascii; 190, identifier:force_ascii; 191, identifier:force_ascii; 192, identifier:force_ascii; 193, call; 194, call; 195, identifier:p1; 196, identifier:p2; 197, identifier:p1; 198, identifier:p2; 199, identifier:partial_token_sort_ratio; 200, argument_list; 201, identifier:partial_token_set_ratio; 202, argument_list; 203, identifier:base; 204, identifier:partial; 205, identifier:ptsor; 206, identifier:ptser; 207, identifier:token_sort_ratio; 208, argument_list; 209, identifier:token_set_ratio; 210, argument_list; 211, identifier:max; 212, argument_list; 213, identifier:len; 214, argument_list; 215, identifier:len; 216, argument_list; 217, identifier:p1; 218, identifier:p2; 219, keyword_argument; 220, identifier:p1; 221, identifier:p2; 222, keyword_argument; 223, identifier:p1; 224, identifier:p2; 225, keyword_argument; 226, identifier:p1; 227, identifier:p2; 228, keyword_argument; 229, identifier:base; 230, identifier:tsor; 231, identifier:tser; 232, identifier:p1; 233, identifier:p2; 234, identifier:full_process; 235, False; 236, identifier:full_process; 237, False; 238, identifier:full_process; 239, False; 240, identifier:full_process; 241, False
code: def WRatio(s1, s2, force_ascii=True, full_process=True):
      """
      Return a measure of the sequences' similarity between 0 and 100, using different algorithms.
  
      **Steps in the order they occur**
  
      #. Run full_process from utils on both strings
      #. Short circuit if this makes either string empty
      #. Take the ratio of the two processed strings (fuzz.ratio)
      #. Run checks to compare the length of the strings
          * If one of the strings is more than 1.5 times as long as the other
            use partial_ratio comparisons - scale partial results by 0.9
            (this makes sure only full results can return 100)
          * If one of the strings is over 8 times as long as the other
            instead scale by 0.6
  
      #. Run the other ratio functions
          * if using partial ratio functions call partial_ratio,
            partial_token_sort_ratio and partial_token_set_ratio
            scale all of these by the ratio based on length
          * otherwise call token_sort_ratio and token_set_ratio
          * all token based comparisons are scaled by 0.95
            (on top of any partial scalars)
  
      #. Take the highest value from these results
         round it and return it as an integer.
  
      :param s1:
      :param s2:
      :param force_ascii: Allow only ascii characters
      :type force_ascii: bool
      :full_process: Process inputs, used here to avoid double processing in extract functions (Default: True)
      :return:
      """
  
      if full_process:
          p1 = utils.full_process(s1, force_ascii=force_ascii)
          p2 = utils.full_process(s2, force_ascii=force_ascii)
      else:
          p1 = s1
          p2 = s2
  
      if not utils.validate_string(p1):
          return 0
      if not utils.validate_string(p2):
          return 0
  
      # should we look at partials?
      try_partial = True
      unbase_scale = .95
      partial_scale = .90
  
      base = ratio(p1, p2)
      len_ratio = float(max(len(p1), len(p2))) / min(len(p1), len(p2))
  
      # if strings are similar length, don't use partials
      if len_ratio < 1.5:
          try_partial = False
  
      # if one string is much much shorter than the other
      if len_ratio > 8:
          partial_scale = .6
  
      if try_partial:
          partial = partial_ratio(p1, p2) * partial_scale
          ptsor = partial_token_sort_ratio(p1, p2, full_process=False) \
              * unbase_scale * partial_scale
          ptser = partial_token_set_ratio(p1, p2, full_process=False) \
              * unbase_scale * partial_scale
  
          return utils.intr(max(base, partial, ptsor, ptser))
      else:
          tsor = token_sort_ratio(p1, p2, full_process=False) * unbase_scale
          tser = token_set_ratio(p1, p2, full_process=False) * unbase_scale
  
          return utils.intr(max(base, tsor, tser))