English sentence formatter. 

    First letter is always upper case. Example:
    "Do you want to build a snow man?"

    **中文文档**

    句子格式。每句话的第一个单词第一个字母大写。
323326
def fmt_sentence(text):
    
    text = text.strip()
    if len(text) == 0:  # if empty string, return it
        return text
    else:
        text = text.lower()  # lower all char
        # delete redundant empty space
        chunks = [chunk for chunk in text.split(" ") if len(chunk) >= 1]
        chunks[0] = chunks[0][0].upper() + chunks[0][1:]
        return " ".join(chunks)
851483
public static String getFirstUpperLetter(String text, String separator) throws Exception {
		PinyinFormat format = new PinyinFormat();
		format.setUpperFormat(PinyinUpperFormat.UPPER_FIRST_LETTER);
		format.setToneFormat(PinyinTONEFormat.TONE_NONE);
		if ($.notNull(separator)) {
			format.setSeparator(separator);
		}
		return getPinyin(text, format);
	}
826144
def _ToCamelCase(name):
  """"""
  capitalize_next = False
  result = []

  for c in name:
    if c == '_':
      if result:
        capitalize_next = True
    elif capitalize_next:
      result.append(c.upper())
      capitalize_next = False
    else:
      result += c

  # Lower-case the first letter.
  if result and result[0].isupper():
    result[0] = result[0].lower()
  return ''.join(result)
776371
function toCamelCase (str, upper) {
  str = str.toLowerCase().replace(/(?:(^.)|(\s+.)|(-.))/g, function (match) {
    return match.charAt(match.length - 1).toUpperCase()
  })
  if (upper) {
    return str
  }
  return str.charAt(0).toLowerCase() + str.substr(1)
}
1156828
public function upperCaseFirst()
    {
        $first = UTF8::substr($this->scalarString, 0, 1, $this->encoding);

        $rest = UTF8::substr
        (
            $this->scalarString,
            1,
            $this->getLength() - 1,
            $this->encoding
        );

        return $this->newSelf(UTF8::strtoupper($first, $this->encoding).$rest);
    }
918036
def case_name_parts(self):
        
        if not self.is_mixed_case():
            self.honorific = self.honorific.title() if self.honorific else None
            self.nick = self.nick.title() if self.nick else None

            if self.first:
                self.first = self.first.title()
                self.first = self.capitalize_and_punctuate_initials(self.first)

            if self.last:
                self.last = self.last.title()
                self.last = self.uppercase_the_scots(self.last)

            self.middle = self.middle.title() if self.middle else None

            if self.suffix:
                # Title case Jr/Sr, but uppercase roman numerals
                if re.match(r'(?i).*[js]r', self.suffix):
                    self.suffix = self.suffix.title()
                else:
                    self.suffix = self.suffix.upper()

        return self
29430
function toPascalCase(name) {
  return name.charAt(0).toUpperCase() + name.replace(/-(.)?/g, (match, c) => c.toUpperCase()).slice(1);
}
1010840
public static String capitalizeFirst( String s )
    {
        if (StringUtil.isEmpty( s )) return s;

        StringBuilder sb = new StringBuilder();
        sb.append( s.substring( 0, 1 ).toUpperCase() );
        sb.append( s.substring( 1 ) );
        return sb.toString();
    }
1125970
public static String getAllFirstLetter(String chinese) {
		if (StrUtil.isBlank(chinese)) {
			return StrUtil.EMPTY;
		}

		int len = chinese.length();
		final StrBuilder strBuilder = new StrBuilder(len);
		for (int i = 0; i < len; i++) {
			strBuilder.append(getFirstLetter(chinese.charAt(i)));
		}

		return strBuilder.toString();
	}
474739
def _capitalize_first_letter(word):
    
    if word[0].isalpha():
        # These two cases are necessary in order to get a regex pattern
        # starting with '[xX]' and not '[Xx]'. This allows to check for
        # colliding regex afterwards.
        if word[0].isupper():
            return "[" + word[0].swapcase() + word[0] + "]" + word[1:]
        else:
            return "[" + word[0] + word[0].swapcase() + "]" + word[1:]
    return word
1272721
function ucFirst( str ) {
		str += '';
		var f = str.charAt( 0 ).toUpperCase();
		return f + str.substr( 1 );
	}
68102
public function upperCaseFirst()
	{
		trigger_error('Function ' . __METHOD__ . ' not implemented yet');

		$first = \mb_substr($this->str, 0, 1, $this->encoding);
		$rest = \mb_substr($this->str, 1, $this->length() - 1, $this->encoding);

		$str = \mb_strtoupper($first, $this->encoding) . $rest;

		return static::create($str, $this->encoding);
	}
1149862
private static function formatter(string $name, bool $firstUpper = true): string
    {
        // 将表名中的下划线转换为大写字母
        $words = explode('_', $name);
        foreach ($words as $k => $w) {
            $words [$k] = ucfirst($w);
        }

        // 合并
        $name = implode('', $words);

        // 如果明确要求首字母小写
        if (!$firstUpper) {
            $name = lcfirst($name);
        }

        // 返回名字
        return $name;
    }
592292
@Transformer
    public static String capitalizeWords(Object o) {
        if (null == o) return "";
        String source = o.toString();
        char prevc = ' '; // first char of source is capitalized
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < source.length(); i++) {
            char c = source.charAt(i);
            if (c != ' ' && !isDigitsOrAlphabetic(prevc)) {
                sb.append(Character.toUpperCase(c));
            } else {
                sb.append(c);
            }
            prevc = c;
        }
        return sb.toString();
    }
710972
def string_format(msg, method):
    
    if method == "uppercase":
        return msg.upper()
    elif method == "lowercase":
        return msg.lower()
    elif method == "sentence":
        return msg.capitalize()
    elif method == "formal":
        return string.capwords(msg)
529056
private void toPrettyString(int indentLevel, StringBuilder buf) {
    for (int i = 0; i < indentLevel; i++) {
      buf.append("  ");
    }
    buf.append(shortName).append(": ").append(targetPatterns);
    for (GrammaticalRelation child : children) {
      buf.append('\n');
      child.toPrettyString(indentLevel + 1, buf);
    }
  }
887325
public static String toCapCase( final String string )
    {
        if ( string == null )
        {
            return null;
        }

        if( string.length() == 1 )
        {
            return string.toUpperCase();
        }

        return Character.toUpperCase( string.charAt( 0 ) ) + string.substring( 1 ).toLowerCase();
    }