Adjust capitalization of formatted result for display context
972036
private String adjustForContext(String result) {
        if (result != null && result.length() > 0 && UCharacter.isLowerCase(result.codePointAt(0))) {
            DisplayContext capitalization = getContext(DisplayContext.Type.CAPITALIZATION);
            if (  capitalization==DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
                  (capitalization == DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU && capitalizationForListOrMenu) ||
                  (capitalization == DisplayContext.CAPITALIZATION_FOR_STANDALONE && capitalizationForStandAlone) ) {
                if (capitalizationBrkIter == null) {
                    // should only happen when deserializing, etc.
                    capitalizationBrkIter = BreakIterator.getSentenceInstance(locale);
                }
                return UCharacter.toTitleCase(locale, result, capitalizationBrkIter,
                                UCharacter.TITLECASE_NO_LOWERCASE | UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT);
            }
        }
        return result;
    }
1145841
function capitalize(str) {
    let result = str.trim();
    return result.substring(0, 1).toUpperCase() + result.substring(1);
  }
1211965
def camelise(text, capital_first=True):
    """"""

    def camelcase():
        if not capital_first:
            yield str.lower
        while True:
            yield str.capitalize

    if istype(text, 'unicode'):
        text = text.encode('utf8')
    c = camelcase()
    return "".join(next(c)(x) if x else '_' for x in text.split("_"))
71996
function capitalize (text) {
  return text
    .replace (/^([^A-Za-z]*)([a-z])/, function (m, g1, g2) { return g1 + g2.toUpperCase() })
    .replace (/([\.\!\?]\s*)([a-z])/g, function (m, g1, g2) { return g1 + g2.toUpperCase() })
}
672191
def _clean_result(self, text):
        """"""
        text = re.sub('\s\s+', ' ', text)
        text = re.sub('\.\.+', '.', text)
        text = text.replace("'", "\\'")
        return text
646280
def format_field_by_match(self, value, match):
        """"""
        groups = match.groups()
        fill, align, sign, sharp, zero, width, comma, prec, type_ = groups
        if not comma and not prec and type_ not in list('fF%'):
            return None
        if math.isnan(value) or math.isinf(value):
            return None
        locale = self.numeric_locale
        # Format number value.
        prefix = get_prefix(sign)
        if type_ == 'd':
            if prec is not None:
                raise ValueError('precision not allowed in '
                                 'integer format specifier')
            string = format_number(value, 0, prefix, locale)
        elif type_ in 'fF%':
            format_ = format_percent if type_ == '%' else format_number
            string = format_(value, int(prec or DEFAULT_PREC), prefix, locale)
        else:
            # Don't handle otherwise.
            return None
        if not comma:
            # Formatted number always contains group symbols.
            # Remove the symbols if not required.
            string = remove_group_symbols(string, locale)
        if not (fill or align or zero or width):
            return string
        # Fix a layout.
        spec = ''.join([fill or u'', align or u'>',
                        zero or u'', width or u''])
        return format(string, spec)
1206206
def capitalize(text):
    
    text = nativestring(text)
    if EXPR_CAPITALS.match(text):
        return text
    return text.capitalize()
976649
def fix_e225(self, result):
        """"""
        target = self.source[result['line'] - 1]
        offset = result['column'] - 1
        fixed = target[:offset] + ' ' + target[offset:]

        # Only proceed if non-whitespace characters match.
        # And make sure we don't break the indentation.
        if (
            fixed.replace(' ', '') == target.replace(' ', '') and
            _get_indentation(fixed) == _get_indentation(target)
        ):
            self.source[result['line'] - 1] = fixed
        else:
            return []
1150220
function capitalize(val) {
    if (!is_1.isValue(val))
        return null;
    val = val.toLowerCase();
    return "" + val.charAt(0).toUpperCase() + val.slice(1);
}
301986
def format_results(self, results):
        
        if not results:
            return None
        userdn = results[0][0]
        userobj = results[0][1]
        userobj['dn'] = userdn

        keymap = self.config.get('KEY_MAP')
        if keymap:
            return {key:scalar(userobj.get(value)) for key, value in keymap.items() if _is_utf8(scalar(userobj.get(value))) }
        else:
            return {key:scalar(value) for key, value in userobj.items() if _is_utf8(scalar(value)) }
567694
@Override
    public void setContext(DisplayContext context) {
        super.setContext(context);
        if (!capitalizationInfoIsSet &&
              (context==DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU || context==DisplayContext.CAPITALIZATION_FOR_STANDALONE)) {
            initCapitalizationContextInfo(locale);
            capitalizationInfoIsSet = true;
        }
        if (capitalizationBrkIter == null && (context==DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
              (context==DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU && capitalizationForListOrMenu) ||
              (context==DisplayContext.CAPITALIZATION_FOR_STANDALONE && capitalizationForStandAlone) )) {
            capitalizationBrkIter = BreakIterator.getSentenceInstance(locale);
        }
    }
1046269
private StringBuffer format(Calendar cal, DisplayContext capitalizationContext,
            StringBuffer toAppendTo, FieldPosition pos, List<FieldPosition> attributes) {
        // Initialize
        pos.setBeginIndex(0);
        pos.setEndIndex(0);

        // Careful: For best performance, minimize the number of calls
        // to StringBuffer.append() by consolidating appends when
        // possible.

        Object[] items = getPatternItems();
        for (int i = 0; i < items.length; i++) {
            if (items[i] instanceof String) {
                toAppendTo.append((String)items[i]);
            } else {
                PatternItem item = (PatternItem)items[i];
                int start = 0;
                if (attributes != null) {
                    // Save the current length
                    start = toAppendTo.length();
                }
                if (useFastFormat) {
                    subFormat(toAppendTo, item.type, item.length, toAppendTo.length(),
                              i, capitalizationContext, pos, cal);
                } else {
                    toAppendTo.append(subFormat(item.type, item.length, toAppendTo.length(),
                                                i, capitalizationContext, pos, cal));
                }
                if (attributes != null) {
                    // Check the sub format length
                    int end = toAppendTo.length();
                    if (end - start > 0) {
                        // Append the attribute to the list
                        DateFormat.Field attr = patternCharToDateFormatField(item.type);
                        FieldPosition fp = new FieldPosition(attr);
                        fp.setBeginIndex(start);
                        fp.setEndIndex(end);
                        attributes.add(fp);
                    }
                }
            }
        }
        return toAppendTo;

    }
1261542
def format_results(self, results, request):
        
        self.prepare_sorting_fields()
        if self._sorting_fields:
            results = self.sort_results(results)

        if request.accepted_renderer.format == 'html':
            # Makes the the results available to the template context by transforming to a dict
            results = {'data': results}

        return results
1182611
function capitalize(string) {
    return (/[a-z]/.test(string) ? string : string.toLowerCase())
        .replace(/[\s\-_]*([^\s\-_])([^\s\-_]+)/g, replacer)
        .replace(/[A-Z]/g, ' $&')
        .trim();
}
388037
def format_title(text):
    
    text = text.strip()
    # if empty string, return ""
    if len(text) == 0:
        return text
    else:
        text = text.lower()  # lower all char

        # Change to in single space format
        words = [word for word in text.strip().split(" ") if len(word) >= 1]

        # Capitalize all words except function word
        words_new = list()
        for word in words:
            if word not in FUNCTION_WORD:
                word = word[0].upper() + word[1:]
            words_new.append(word)

        # Make sure first word always be capitalized
        words_new[0] = words_new[0][0].upper() + words_new[0][1:]

        return " ".join(words_new)
1198153
function (command) {
          var align = command.substring(7);

          if (align == 'full') {
            align = 'justify';
          }

          // Remove all other alignments first
          each('left,center,right,justify'.split(','), function (name) {
            if (align != name) {
              formatter.remove('align' + name);
            }
          });

          if (align != 'none') {
            toggleFormat('align' + align);
          }
        }
1086545
@Override
	public String formatName(Result result) {
		String formatted;
		JexlContext context = new MapContext();

		this.populateContext(context, result);
		try {
			formatted = (String) this.parsedExpr.evaluate(context);
		} catch (JexlException jexlExc) {
			LOG.error("error applying JEXL expression to query results", jexlExc);
			formatted = null;
		}

		return formatted;
	}