Java Code Examples for org.apache.commons.text.WordUtils#capitalizeFully()

The following examples show how to use org.apache.commons.text.WordUtils#capitalizeFully() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VehicleNameUtils.java    From istio-fleetman with MIT License 4 votes vote down vote up
public static String prettifyName(String originalName) {
	return WordUtils.capitalizeFully(originalName.replaceAll("_", " "));
}
 
Example 2
Source File: VehicleNameUtils.java    From k8s-fleetman with MIT License 4 votes vote down vote up
public static String prettifyName(String originalName) {
	return WordUtils.capitalizeFully(originalName.replaceAll("_", " "));
}
 
Example 3
Source File: ProviderDistributionUIConfig.java    From blackduck-alert with Apache License 2.0 4 votes vote down vote up
private LabelValueSelectOption convertToLabelValueOption(ProviderNotificationType providerContentType) {
    String notificationType = providerContentType.getNotificationType();
    String notificationTypeLabel = WordUtils.capitalizeFully(notificationType.replace("_", " "));
    return new LabelValueSelectOption(notificationTypeLabel, notificationType);
}
 
Example 4
Source File: NerdEngine.java    From entity-fishing with Apache License 2.0 4 votes vote down vote up
/**
 * Try to find the best KB Labels from a normalized string. In practice, this method has
 * a huge impact on performance, as it can maximize the chance to have the right entity
 * in the list of candidates.
 */
public static List<Label> bestLabels(String normalisedString, LowerKnowledgeBase wikipedia, String lang) {
	List<Label> labels = new ArrayList<Label>();
	//String normalisedString = entity.getNormalisedName();
	if (isEmpty(normalisedString))
		return null;

	// normalised mention following case as it appears
	Label bestLabel = new Label(wikipedia.getEnvironment(), normalisedString);
	labels.add(bestLabel);

	// try case variants
	//if (!bestLabel.exists())
	{
		// first letter upper case
		Label label = new Label(wikipedia.getEnvironment(), WordUtils.capitalize(normalisedString.toLowerCase()));
		if (label.exists())
				labels.add(label);

		// full upper or lower case
		if (StringProcessor.isAllUpperCase(normalisedString)) {
			label = new Label(wikipedia.getEnvironment(), normalisedString.toLowerCase());
			if (label.exists())
				labels.add(label);
		}
		else if (StringProcessor.isAllLowerCase(normalisedString)) {
			label = new Label(wikipedia.getEnvironment(), normalisedString.toUpperCase());
			if (label.exists())
				labels.add(label);
		} else {
			label = new Label(wikipedia.getEnvironment(), normalisedString.toLowerCase());
			if (label.exists())
				labels.add(label);

			label = new Label(wikipedia.getEnvironment(), normalisedString.toUpperCase());
			if (label.exists())
				labels.add(label);
		}

		label = new Label(wikipedia.getEnvironment(), WordUtils.capitalizeFully(normalisedString.toLowerCase()));
		if (label.exists())
			labels.add(label);

		// more aggressive
		label = new Label(wikipedia.getEnvironment(),
				WordUtils.capitalizeFully(normalisedString.toLowerCase(), ProcessText.delimiters.toCharArray()));
		if (label.exists())
			labels.add(label);

		// only first word capitalize
		if (normalisedString.length()>1) {
			label = new Label(wikipedia.getEnvironment(), normalisedString.toLowerCase().substring(0, 1).toUpperCase() +
				normalisedString.toLowerCase().substring(1));
			if (label.exists())
				labels.add(label);
		}

		// try variant cases
		if (StringProcessor.isAllUpperCase(normalisedString)) {
			// a usual pattern in all upper case that is missed above is a combination of
			// acronym + normal term, e.g. NY RANGERS -> NY Rangers
			List<LayoutToken> localTokens = GrobidAnalyzer.getInstance().tokenizeWithLayoutToken(normalisedString, new Language(lang, 1.0));
			for(int i=0; i<localTokens.size(); i++) {
				LayoutToken token = localTokens.get(i);
				if (token.getText().length() == 2) {
					StringBuilder newLabel = new StringBuilder();
					for(int j=0; j<localTokens.size(); j++) {
						if ( j!= i)
							newLabel.append(WordUtils.capitalize(localTokens.get(j).getText().toLowerCase()));
						else
							newLabel.append(token);
					}
					label = new Label(wikipedia.getEnvironment(), newLabel.toString());
					if (label.exists())
						labels.add(label);
				}
			}
		}
	}

	return labels;
}
 
Example 5
Source File: PTextWord.java    From jphp with Apache License 2.0 4 votes vote down vote up
@Signature
public PTextWord capitalizeFully(Environment env, @Optional(type = HintType.STRING) String delimiters) {
    return new PTextWord(env, WordUtils.capitalizeFully(text, delimiters.isEmpty() ? null : delimiters.toCharArray()));
}
 
Example 6
Source File: HyperiumBind.java    From Hyperium with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Returns the key description, this will be capitalized if the capitalize
 * method returns true (see {@link #capitalizeDescription()})
 *
 * @return the keys description
 */
public String getKeyDescription() {
    String message = description;
    if (capitalizeDescription()) message = WordUtils.capitalizeFully(message);
    return message;
}
 
Example 7
Source File: ProfileUtils.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Convert a string to propercase. ie This Is Proper Text
 * @param input		string to be formatted
 * @return
 */
public static String toProperCase(String input) {
	return WordUtils.capitalizeFully(input);
}
 
Example 8
Source File: ProfileUtils.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Convert a string to propercase. ie This Is Proper Text
 * @param input		string to be formatted
 * @return
 */
public static String toProperCase(String input) {
	return WordUtils.capitalizeFully(input);
}