org.apache.commons.lang3.StringUtils#normalizeSpace ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#normalizeSpace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: The-5zig-Mod   文件: GuiParty.java
@Override
protected void actionPerformed(IButton button) {
	if (button.getId() == 1) {
		The5zigMod.getVars().displayScreen(new GuiPartyInviteMembers(this));
	} else if (button.getId() == 2) {
		The5zigMod.getVars().displayScreen(new GuiPartyInvitations(this));
	} else if (button.getId() == 3) {
		The5zigMod.getVars().displayScreen(new GuiPartyManageMembers(this, The5zigMod.getPartyManager().getParty()));
	} else if (button.getId() == 4) {
		The5zigMod.getPartyManager().setParty(null);
		The5zigMod.getNetworkManager().sendPacket(new PacketPartyStatus(PacketPartyStatus.Action.DELETE));
		The5zigMod.getScheduler().postToMainThread(new Runnable() {
			@Override
			public void run() {
				initGui0();
			}
		}, true);
	} else if (button.getId() == 100) {
		if (!The5zigMod.getNetworkManager().isConnected())
			return;
		Party party = The5zigMod.getPartyManager().getParty();
		if (party == null) {
			return;
		}
		Conversation conversation = party.getPartyConversation();
		ITextfield textfield = getTextfieldById(1);
		String text = textfield.callGetText();
		text = StringUtils.normalizeSpace(text);
		if (text == null || text.isEmpty())
			return;
		The5zigMod.getNetworkManager().sendPacket(new PacketPartyStatus(PacketPartyStatus.Action.CHAT, text));
		Message message = new Message(conversation, 0, The5zigMod.getDataManager().getColoredName(), text, System.currentTimeMillis(), Message.MessageType.RIGHT);
		conversation.addLastSentMessage(text);
		The5zigMod.getPartyManager().addMessage(message);
		textfield.callSetText("");
		getButtonById(100).setEnabled(false);
	}
}
 
源代码2 项目: The-5zig-Mod   文件: GuiParty.java
@Override
protected void actionPerformed(IButton button) {
	if (button.getId() == 1) {
		The5zigMod.getVars().displayScreen(new GuiPartyInviteMembers(this));
	} else if (button.getId() == 2) {
		The5zigMod.getVars().displayScreen(new GuiPartyInvitations(this));
	} else if (button.getId() == 3) {
		The5zigMod.getVars().displayScreen(new GuiPartyManageMembers(this, The5zigMod.getPartyManager().getParty()));
	} else if (button.getId() == 4) {
		The5zigMod.getPartyManager().setParty(null);
		The5zigMod.getNetworkManager().sendPacket(new PacketPartyStatus(PacketPartyStatus.Action.DELETE));
		The5zigMod.getScheduler().postToMainThread(new Runnable() {
			@Override
			public void run() {
				initGui0();
			}
		}, true);
	} else if (button.getId() == 100) {
		if (!The5zigMod.getNetworkManager().isConnected())
			return;
		Party party = The5zigMod.getPartyManager().getParty();
		if (party == null) {
			return;
		}
		Conversation conversation = party.getPartyConversation();
		ITextfield textfield = getTextfieldById(1);
		String text = textfield.getText();
		text = StringUtils.normalizeSpace(text);
		if (text == null || text.isEmpty())
			return;
		The5zigMod.getNetworkManager().sendPacket(new PacketPartyStatus(PacketPartyStatus.Action.CHAT, text));
		Message message = new Message(conversation, 0, The5zigMod.getDataManager().getColoredName(), text, System.currentTimeMillis(), Message.MessageType.RIGHT);
		conversation.addLastSentMessage(text);
		The5zigMod.getPartyManager().addMessage(message);
		textfield.setText("");
		getButtonById(100).setEnabled(false);
	}
}
 
源代码3 项目: cuba   文件: WebTree.java
@Override
public String getStyleName() {
    String styleName = super.getStyleName();
    for (String internalStyle : internalStyles) {
        styleName = styleName.replace(internalStyle, "");
    }
    return StringUtils.normalizeSpace(styleName);
}
 
源代码4 项目: ontopia   文件: JunkNormalizer.java
@Override
public String normalize(String term) {
  // strip out repeated whitespace characters
  term = StringUtils.normalizeSpace(term);
  // drop 's endings
  if (term.length() >= 2 && term.endsWith("'s")) {
    term = term.substring(0, term.length()-2);
  }
  return term;
}
 
public String getContent() {
	try {
		if (this.parameterMap.isEmpty()) {
			content = IOUtils.toByteArray(delegate.getInputStream());
		} else {
			content = getContentFromParameterMap(this.parameterMap);
		}
		String requestEncoding = delegate.getCharacterEncoding();
		String normalizedContent = StringUtils.normalizeSpace(new String(content, requestEncoding != null ? requestEncoding : StandardCharsets.UTF_8.name()));
		return StringUtils.isBlank(normalizedContent) ? "[EMPTY]" : normalizedContent;
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
源代码6 项目: cuba   文件: WebAppWorkArea.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName()
            .replace(MODE_TABBED_STYLENAME, "")
            .replace(MODE_SINGLE_STYLENAME, "")
            .replace(STATE_INITIAL_STYLENAME, "")
            .replace(STATE_WINDOWS_STYLENAME, ""));
}
 
源代码7 项目: cuba   文件: WebWindow.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(component.getStyleName().replace(C_WINDOW_LAYOUT, ""));
}
 
/**
 * Normalise wikimedia texts according to embedding training requirements which
 * is a simple sequence of words.
 */
private static String normaliseDescription(String wikiText, boolean lowercase, boolean removePunctuation, String lang) {
    String text = MediaWikiParser.getInstance().toTextOnly(wikiText, lang);
    text = text.replace("\t", " ");

    /* following fastText-type string normalisation: 
       1. All punctuation-and-numeric. Things in this bucket get
          their numbers flattened, to prevent combinatorial explosions.
          They might be specific numbers, prices, etc.
          -> all numerical chars are actually all transformed to '0'
          punctuations are removed if parameter removePunctuation is true
       2. All letters: case-flattened if parameter lowercase is true.
       3. Mixed letters and numbers: e.g. a product ID? Flatten case if 
          parameter lowercase is true and transform numbers digit to 0.
    */

    // unicode normalization
    text = UnicodeUtil.normaliseText(text);

    // wikipedia unicode encoding to Java encoding
    // <U+00AD> -> \u00AD
    //text.replaceAll();

    // remove all xml scories
    text = text.replaceAll("<[^>]+>", " ");

    // remove all punctuation
    if (removePunctuation)
        text = text.replaceAll("\\p{P}", " ");

    // flatten numerical chars
    text = text.replaceAll("\\d", "0");

    text = text.replaceAll("\\|", " ");

    // lower case everything 
    if (lowercase)  
        text = text.toLowerCase();

    // collapse spaces amd clean
    text = StringUtils.normalizeSpace(text);
    text = text.replace("()", "");

    // remove stopword - this could be made optional, depending on the task
    // tokenize
    /*List<String> tokens = GrobidAnalyzer.getInstance().tokenize(text, new Language(lang, 1.0));
    StringBuilder textBuilder = new StringBuilder();
    for(String word : tokens) {
        try {
            if (!Stopwords.getInstance().isStopword(word, lang))
                textBuilder.append(word).append(" ");
        } catch(Exception e) {
            LOGGER.warn("Problem getting Stopwords instance", e);
            textBuilder.append(word).append(" ");
        }
    }*/

    //return textBuilder.toString().replaceAll("( )*"," ").trim();
    return StringUtils.normalizeSpace(text);
}
 
源代码9 项目: cuba   文件: WebScrollBoxLayout.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(SCROLLBOX_STYLENAME, ""));
}
 
源代码10 项目: cuba   文件: WebSearchField.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(SEARCHSELECT_STYLENAME, ""));
}
 
源代码11 项目: cuba   文件: WebListEditor.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(LISTEDITOR_STYLENAME, ""));
}
 
源代码12 项目: cuba   文件: WebButtonsPanel.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(BUTTONS_PANEL_STYLENAME, ""));
}
 
源代码13 项目: cuba   文件: WebFlowBoxLayout.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(FLOWLAYOUT_STYLENAME, ""));
}
 
源代码14 项目: entity-fishing   文件: EntityDescription.java
/**
 * Normalise wikimedia texts according to embedding training requirements which
 * is a simple sequence of words.
 */
private static String normaliseDescription(String wikitext, String lang) {
	String text = MediaWikiParser.getInstance().toTextOnly(wikitext, lang);
	text = text.replace("\t", " ");

	// following fastText string normalisation: 
	// 1. All punctuation-and-numeric. Things in this bucket get
       // 	  their numbers flattened, to prevent combinatorial explosions.
       //    They might be specific numbers, prices, etc.
       //    -> all numerical chars are actually all transformed to '0'
   	// 2. All letters: case-flattened.
  	    // 3. Mixed letters and numbers: a product ID? Flatten case and leave
   	//    numbers alone.

	// unicode normalization
	text = UnicodeUtil.normaliseText(text);

	// wikipedia unicode encoding to Java encoding
	// <U+00AD> -> \u00AD
	//text.replaceAll();

   	// remove all xml scories
	text = text.replaceAll("<[^>]+>", " ");

	// remove all punctuation
	text = text.replaceAll("\\p{P}", " ");

	// flatten numerical chars
	text = text.replaceAll("\\d", "0");

	text = text.replaceAll("\\|", " ");

	// lower case everything (to be evaluated!)
	text = text.toLowerCase();

	// collapse spaces
	text = StringUtils.normalizeSpace(text);

	// remove stopword
	// tokenize
	List<String> tokens = GrobidAnalyzer.getInstance().tokenize(text, new Language(lang, 1.0));
	StringBuilder textBuilder = new StringBuilder();
	for(String word : tokens) {
		try {
			if (!Stopwords.getInstance().isStopword(word, lang))
				textBuilder.append(word).append(" ");
		} catch(Exception e) {
			LOGGER.warn("Problem getting Stopwords instance", e);
			textBuilder.append(word).append(" ");
		}
	}

	//return textBuilder.toString().replaceAll("( )*"," ").trim();
	return StringUtils.normalizeSpace(textBuilder.toString());
}
 
源代码15 项目: cuba   文件: WebLinkButton.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(ValoTheme.BUTTON_LINK, ""));
}
 
源代码16 项目: cuba   文件: WebTimeZoneIndicator.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(USER_TIMEZONE_LABEL_STYLENAME, ""));
}
 
源代码17 项目: cuba   文件: WebUserActionsButton.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(
            super.getStyleName().replace(USERACTIONS_BUTTON_STYLENAME, ""));
}
 
源代码18 项目: cuba   文件: WebLogoutButton.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(LOGOUT_BUTTON_STYLENAME, ""));
}
 
源代码19 项目: cuba   文件: WebNewWindowButton.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(NEW_WINDOW_BUTTON_STYLENAME, ""));
}
 
源代码20 项目: cuba   文件: WebFoldersPane.java
@Override
public String getStyleName() {
    return StringUtils.normalizeSpace(super.getStyleName().replace(C_FOLDERS_PANE, ""));
}
 
 同类方法