Normalize prefixes, suffixes and other to make matching original to returned easier.
335670
def _normalize(self, address):
        
        normalized_address = []
        if self.logger: self.logger.debug("Normalizing Address: {0}".format(address))
        for token in address.split():
            if token.upper() in self.parser.suffixes.keys():
                normalized_address.append(self.parser.suffixes[token.upper()].lower())
            elif token.upper() in self.parser.suffixes.values():
                normalized_address.append(token.lower())
            elif token.upper().replace('.', '') in self.parser.suffixes.values():
                normalized_address.append(token.lower().replace('.', ''))
            elif token.lower() in self.parser.prefixes.keys():
                normalized_address.append(self.parser.prefixes[token.lower()].lower())
            elif token.upper() in self.parser.prefixes.values():
                normalized_address.append(token.lower()[:-1])
            elif token.upper() + '.' in self.parser.prefixes.values():
                normalized_address.append(token.lower())
            else:
                normalized_address.append(token.lower())
        return normalized_address
494911
def _normalize(self, string):
		'''  '''

		string = super(VerbixFr, self)._normalize(string)
		string = string.replace('il; elle', 'il/elle')
		string = string.replace('ils; elles', 'ils/elles')
		string = string.strip()
		return string
658593
function replaceWithSurround(text, find, prefix, suffix) {
  const escapedString = escapeRegex(find);
  const re = new RegExp(escapedString, 'gi');
  return text.replace(re, matched => prefix + matched + suffix);
}
930712
def normalize_names(names):
    """"""
    if isinstance(names, basestring):
        names = names.split(',')
    names = listify(names)
    return [str(name).strip() for name in names]
418765
function unPrefix(s, prefix) {
  s = str(s);
  if (!prefix) return s;
  if (s.slice(0, prefix.length) === prefix) return s.slice(prefix.length);
  return s;
}
1216263
def normalize(rendered):
    """"""
    out = ''.join([line.strip()
                   for line in rendered.splitlines()
                   if line.strip()])
    out = out.replace(', ', ',')
    return out
907768
def suffix(tokens, operator_table):
    """"""
    operator, matched_tokens = operator_table.suffix.match(tokens)
    if operator:
        return TokenMatch(operator, None, matched_tokens)
255266
function normalizeExtensions(list) {
  if (!Array.isArray(list)) list = [ list ];

  return list.map(function (ext) {
    return ext[0] === "." ? ext : "." + ext;
  });
}
121356
function normalize(keywords, options) {
  var opts = _.extend({inflect: false}, options);

  keywords = _.union(keywords, chop(keywords));
  var omit = exclude(opts.omit);

  var res = keywords.map(function (keyword, i) {
    if (options && options.normalize) {
      return options.normalize(keywords, i, keywords);
    }
    return properize(keyword, options);
  }).sort();

  return _.uniq(_.difference(res, omit));
}
1267190
def strip_required_suffix(string, suffix):
    
    if string.endswith(suffix):
        return string[:-len(suffix)]
    raise AssertionError('String ends with %r, not %r' % (string[-len(suffix):], suffix))
1015978
public void normalizeCase() {
        // Scheme and host should be lowercase
        String scheme = uri.getScheme();
        String host = uri.getHost();
        String rURI = toString();
        if (scheme != null) {
            String lc = scheme.toLowerCase();
            if (!scheme.equals(lc)){
                rURI = rURI.replaceFirst(scheme, lc);
            }
        }
        if (host != null) {
            String lc = host.toLowerCase();
            if (!host.equals(lc)){
                rURI = rURI.replaceFirst(host, lc);
            }
        }

        // Percent-encoded characters should be uppercase
        if (rURI.indexOf('%') != -1) {
            Matcher m = PERCENT_ENCODED.matcher(rURI);

            StringBuffer sb = new StringBuffer();
            int lastEnd = 0;
            while(m.find()) {
                sb.append(rURI,lastEnd, m.start());
                sb.append(m.group().toUpperCase());
                lastEnd = m.end();
            }
            sb.append(rURI, lastEnd, rURI.length());
            rURI = sb.toString();
        }
        uri = URI.create(rURI);
    }
242472
def normalize_string(mac_type, resource, content_hash):
    """"""

    normalized = [
        'hawk.' + str(HAWK_VER) + '.' + mac_type,
        normalize_header_attr(resource.timestamp),
        normalize_header_attr(resource.nonce),
        normalize_header_attr(resource.method or ''),
        normalize_header_attr(resource.name or ''),
        normalize_header_attr(resource.host),
        normalize_header_attr(resource.port),
        normalize_header_attr(content_hash or '')
    ]

    # The blank lines are important. They follow what the Node Hawk lib does.

    normalized.append(normalize_header_attr(resource.ext or ''))

    if resource.app:
        normalized.append(normalize_header_attr(resource.app))
        normalized.append(normalize_header_attr(resource.dlg or ''))

    # Add trailing new line.
    normalized.append('')

    normalized = '\n'.join(normalized)

    return normalized
697846
def normalize_locale(locale):
        
        import re
        match = re.match(r'^[a-z]+', locale.lower())
        if match:
            return match.group()
110037
def normalize_fulltext(fulltext):
    """"""
    # We recognize keywords by the spaces. We need these to match the
    # first and last words of the document.
    fulltext = " " + fulltext + " "

    # Replace some weird unicode characters.
    fulltext = replace_undesirable_characters(fulltext)
    # Replace the greek characters by their name.
    fulltext = _replace_greek_characters(fulltext)

    washing_regex = get_washing_regex()

    # Apply the regular expressions to the fulltext.
    for regex, replacement in washing_regex:
        fulltext = regex.sub(replacement, fulltext)

    return fulltext
979876
def _clean_suffix(string, suffix):
    
    suffix_len = len(suffix)

    if len(string) < suffix_len:
        # the string param was shorter than the suffix
        raise ValueError("A suffix can not be bigger than string argument.")
    if string.endswith(suffix):
        # return from the beginning up to
        # but not including the first letter
        # in the suffix
        return string[0:-suffix_len]
    else:
        # leave unharmed
        return string
246171
def normalize(self, decl_string, arg_separator=None):
        """"""
        if not self.has_pattern(decl_string):
            return decl_string
        name, args = self.split(decl_string)
        for i, arg in enumerate(args):
            args[i] = self.normalize(arg)
        return self.join(name, args, arg_separator)
710178
def normalise_string(string):
    
    string = (string.strip()).lower()
    return re.sub(r'\W+', '_', string)