Normalize the input so that it matches the stored format.
184254
public function normalizeZip($zip) {
        if (strlen($zip) === 6) {
            $zip = substr($zip, 0, 4) . ' ' . strtoupper(substr($zip, 4, 2));
        }

        return $zip;
    }
174749
def normalize_value(values)
      Array.wrap(values).map do |value|
        value.is_a?(String) ? value.gsub("\n", "") : value
      end
    end
1000150
def sanitize(value):
    """"""

    value = unicodedata.normalize('NFKD', value)
    value = value.strip()
    value = re.sub('[^./\w\s-]', '', value)
    value = re.sub('[-\s]+', '-', value)

    return value
1170081
def normalize_val(self, value=_nothing):
        
        if isinstance(value, basestring):
            value = self.normalize_text(value)
        if self.ignore_empty_slots and self.value_is_empty(value):
            value = _nothing
        return value
83833
def _normalize(self, tokens):
        """"""
        if self.case_sensitive:
            return ' '.join(self.lexicon[t].normalized for t in tokens)
        else:
            return ' '.join(self.lexicon[t].lower for t in tokens)
474260
def normalize(name):
    """"""

    # Name should not contain some specials chars (issue #1068)
    ret = name.replace(':', '')
    ret = ret.replace('%', '')
    ret = ret.replace(' ', '_')

    return ret
41148
def normalize_result(result, default, threshold=0.2):
    """"""
    if result is None:
        return default
    if result.get('confidence') is None:
        return default
    if result.get('confidence') < threshold:
        return default
    return normalize_encoding(result.get('encoding'),
                              default=default)
552948
def normalize(self, text, cleaned=False, **kwargs):
        """"""
        if not cleaned:
            text = self.clean(text, **kwargs)
        return ensure_list(text)
127922
function normalizeInput (data, field) {
    // replace empty strings with undefined
    if ((field.inputType === 'text' || field.inputType === 'select') && data[field.property] === '') {
        data[field.property] = undefined
    }
    // convert checkbox value to boolean
    else if (field.inputType === 'checkbox') {
        data[field.property] = data[field.property] ? true : false
    }
    // nested array input
    else if (field.nested && field.array) {
        // if input has property then remove last row if it is all empty
        if (Array.isArray(data[field.property])) {
            // get last row in array
            var item = data[field.property][data[field.property].length - 1]
            // flag set to true if any values found
            var hasValues = false
            // check all properties of item to see if any have non empty values
            _.each(item, value => {
                if (!hasValues && typeof value === 'string' && value.length) {
                    hasValues = true
                }
            })
            // if there are no values then remove last item from array
            if (!hasValues) {
                data[field.property].pop()
            }
        }
        // otherwise set property as empty array
        else {
            data[field.property] = []
        }
    }
}
1318915
function normalize(result) {
  return {
    relevance: result.relevance || 0,
    language: result.language || null,
    value: result.value || []
  }
}
298098
def format_value(self, value):
        
        if value == '' or value is None:
            return None
        return formats.localize_input(value, self.format)
599422
def normalize(self):
        """"""
        length = self.length()
        if length > 0:
            self.X /= length
            self.Y /= length
        else:
            print "Length 0, cannot normalize."
32232
def normalizeUnicode(text, encoding='humanascii'):
    
    if text == "":
	return ""

    unicodeinput = True
    if not isinstance(text, unicode):
        text = unicode(text, 'utf-8')
        unicodeinput = False

    res = ''
    global allowed, allowedid
    if encoding == 'humanascii' or encoding == 'identifier':
        enc = 'ascii'
    else:
        enc = encoding
    for ch in text:
        if (encoding == 'humanascii') and (ch in allowed):
            # ASCII chars, digits etc. stay untouched
            res += ch
            continue
        if (encoding == 'identifier') and (ch in allowedid):
            # ASCII chars, digits etc. stay untouched
            res += ch
            continue
        else:
            try:
                ch.encode(enc,'strict')
                if encoding == 'identifier':
                    res += '_'
                else:
                    res += ch
            except UnicodeEncodeError:
                ordinal = ord(ch)
                if mapping.has_key(ordinal):
                    # try to apply custom mappings
                    res += mapping.get(ordinal)
                elif decomposition(ch) or len(normalize('NFKD',ch)) > 1:
                    normalized = filter(lambda i: not combining(i), normalize('NFKD', ch)).strip()
                    # normalized string may contain non-letter chars too. Remove them
                    # normalized string may result to  more than one char
                    if encoding == 'identifier':
                        res += ''.join([c for c in normalized if c in allowedid])
                    else:
                        res += ''.join([c for c in normalized if c in allowed])
                else:
                    # hex string instead of unknown char
                    res += "%x" % ordinal
    if encoding == 'identifier':
        res = res.strip('_').replace('_____','_').replace('____','_').replace('___','_').replace('__','_')
        if not res.strip('_')[0] in string.ascii_letters:
            res = '_' + res
    if unicodeinput:
        return res
    else:
        return res.encode('utf-8')
1127343
def _normalize(self, flags):
        """"""
        norm = None
        if isinstance(flags, MessageFlags):
            norm = flags.bytes
        elif isinstance(flags, bytearray):
            norm = binascii.hexlify(flags)
        elif isinstance(flags, int):
            norm = bytes([flags])
        elif isinstance(flags, bytes):
            norm = binascii.hexlify(flags)
        elif isinstance(flags, str):
            flags = flags[0:2]
            norm = binascii.hexlify(binascii.unhexlify(flags.lower()))
        elif flags is None:
            norm = None
        else:
            _LOGGER.warning('MessageFlags with unknown type %s: %r',
                            type(flags), flags)
        return norm
985944
public static String normalizeExponents(String input) {
        Matcher m = eExp.matcher(input);
        if (m.find()) {

            Float number = Float.parseFloat(m.group(1));
            int exp = Integer.parseInt(m.group(3));
            boolean negative = m.group(2) != null && m.group(2).equals("-");
            if (negative)
                exp *= -1;

            return FORMATTER.format(number * Math.pow(10, exp));
        }

        // TODO refactor into 1
        m = xExp.matcher(input);
        if (m.find()) {

            Float number = Float.parseFloat(m.group(1));
            int exp = Integer.parseInt(m.group(3));
            boolean negative = m.group(2) != null && m.group(2).equals("-");
            if (negative)
                exp *= -1;

            String s = FORMATTER.format(number * Math.pow(10, exp));
            return s;
        }

        return input;
    }
924829
def normalize(x, min_value, max_value):
    """"""
    x = (x - min_value) / (max_value - min_value)
    return clip(x, 0, 1)
1285518
function normalizeField(input) {
  assert(input.name, 'fields must have a name');

  var ret = clone(input);

  var cls = normalizeClass(input.class);
  if (cls) ret.class = cls;

  return ret;
}