Java Code Examples for org.apache.commons.lang3.StringUtils#normalizeSpace()
The following examples show how to use
org.apache.commons.lang3.StringUtils#normalizeSpace() .
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: GuiParty.java From The-5zig-Mod with MIT License | 5 votes |
@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); } }
Example 2
Source File: WebAppWorkArea.java From cuba with Apache License 2.0 | 5 votes |
@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, "")); }
Example 3
Source File: LoggingHttpServletRequestWrapper.java From servlet-logging-filter with Apache License 2.0 | 5 votes |
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); } }
Example 4
Source File: JunkNormalizer.java From ontopia with Apache License 2.0 | 5 votes |
@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; }
Example 5
Source File: WebTree.java From cuba with Apache License 2.0 | 5 votes |
@Override public String getStyleName() { String styleName = super.getStyleName(); for (String internalStyle : internalStyles) { styleName = styleName.replace(internalStyle, ""); } return StringUtils.normalizeSpace(styleName); }
Example 6
Source File: GuiParty.java From The-5zig-Mod with GNU General Public License v3.0 | 5 votes |
@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); } }
Example 7
Source File: WebScrollBoxLayout.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(SCROLLBOX_STYLENAME, "")); }
Example 8
Source File: WebSearchField.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(SEARCHSELECT_STYLENAME, "")); }
Example 9
Source File: WebListEditor.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(LISTEDITOR_STYLENAME, "")); }
Example 10
Source File: WebButtonsPanel.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(BUTTONS_PANEL_STYLENAME, "")); }
Example 11
Source File: WebFlowBoxLayout.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(FLOWLAYOUT_STYLENAME, "")); }
Example 12
Source File: EntityDescription.java From entity-fishing with Apache License 2.0 | 4 votes |
/** * 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()); }
Example 13
Source File: GenerateArticleTextCorpus.java From entity-fishing with Apache License 2.0 | 4 votes |
/** * 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); }
Example 14
Source File: WebLinkButton.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(ValoTheme.BUTTON_LINK, "")); }
Example 15
Source File: WebTimeZoneIndicator.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(USER_TIMEZONE_LABEL_STYLENAME, "")); }
Example 16
Source File: WebWindow.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(component.getStyleName().replace(C_WINDOW_LAYOUT, "")); }
Example 17
Source File: WebUserActionsButton.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace( super.getStyleName().replace(USERACTIONS_BUTTON_STYLENAME, "")); }
Example 18
Source File: WebLogoutButton.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(LOGOUT_BUTTON_STYLENAME, "")); }
Example 19
Source File: WebNewWindowButton.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(NEW_WINDOW_BUTTON_STYLENAME, "")); }
Example 20
Source File: WebFoldersPane.java From cuba with Apache License 2.0 | 4 votes |
@Override public String getStyleName() { return StringUtils.normalizeSpace(super.getStyleName().replace(C_FOLDERS_PANE, "")); }