當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.indexOfAny方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.StringUtils.indexOfAny方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.indexOfAny方法的具體用法?Java StringUtils.indexOfAny怎麽用?Java StringUtils.indexOfAny使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.indexOfAny方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBriefFromCommentText

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
protected String getBriefFromCommentText(String commentText) {
	int index = StringUtils.indexOf(commentText, '\n');
	if (index != -1) {
		commentText = StringUtils.substring(commentText, 0, index);
	}
	index = StringUtils.indexOfAny(commentText, ".!?。!?…");
	if (index > 0) {
		commentText = StringUtils.substring(commentText, 0, index);
	}
	if (StringUtils.length(commentText) > 8) {
		commentText = StringUtils.substring(commentText, 0, 8) + "…";
	}
	return commentText;
}
 
開發者ID:WinRoad-NET,項目名稱:wrdocletbase,代碼行數:15,代碼來源:AbstractDocBuilder.java

示例2: uncapitalizeShortMessages

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static void uncapitalizeShortMessages(String[] paragraphs) throws Exception {
    if (paragraphs.length > 1)
        return ;
     
    // Verify whether this is a short message by looking at sentence separators.
    int firstIdx = StringUtils.indexOfAny(paragraphs[0], LangDictionary.getInstance().getSentenceSeparators());
    
    if ((firstIdx < 0) || (firstIdx == paragraphs[0].length()))
    {
        float firstCapRatio = 0.0F;
        float allCapsRatio = 0.0F;
        RefSupport<Float> refVar0 = new RefSupport<Float>();
        RefSupport<Float> refVar1 = new RefSupport<Float>();
        ratioOfCapitalizedWords(paragraphs[0],refVar0,refVar1);
        allCapsRatio = refVar0.getValue();
        firstCapRatio = refVar1.getValue();
        
        if (Math.max(allCapsRatio,firstCapRatio) > MaxCapitalizedRatio)
            paragraphs[0] = lowercaseCapitalizedWords(paragraphs[0],1);
         
    }
     
}
 
開發者ID:datancoffee,項目名稱:sirocco,代碼行數:24,代碼來源:StructuredSplitter.java

示例3: ratioOfCapitalizedWords

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static void ratioOfCapitalizedWords(String sentence, RefSupport<Float> allCapsRatio, RefSupport<Float> firstCapRatio) throws Exception {
    Integer numFirstCapitalEntities = 0;
    Integer numAllCapitalEntities = 0;
    Integer numLowerCaseEntities = 0;
    Integer idx = 0;
    while ((idx < sentence.length()) && (idx > 0))
    {
        String tailOfsentence = sentence.substring(idx);
    	Integer idxInTail = StringUtils.indexOfAny(tailOfsentence, LangDictionary.getInstance().getWordSeparators());
    	
        if (idxInTail == 0)
        	idx = 0;
        else
        {
        	idx=idx+idxInTail;
            if (Character.isUpperCase(sentence.charAt(idx + 1)))
            {
                // just check one next character (for performance reasons)
                if ((idx + 2) < sentence.length())
                    if (Character.isUpperCase(sentence.charAt(idx + 2)))
                        numAllCapitalEntities++;
                    else
                        numFirstCapitalEntities++; 
                else
                    numFirstCapitalEntities++; 
            }
            else if (Character.isLowerCase(sentence.charAt(idx + 1)))
            	numLowerCaseEntities++;
              
        }
         
    }
    Integer numAllEntities = numAllCapitalEntities + numFirstCapitalEntities + numLowerCaseEntities;
    if (numAllEntities == 0)
    {
    	firstCapRatio.setValue(0.0F);
        allCapsRatio.setValue(0.0F);
    }
    else
    {
        allCapsRatio.setValue(((float)numAllCapitalEntities / (float)numAllEntities));
        firstCapRatio.setValue(((float)numFirstCapitalEntities / (float)numAllEntities));
    } 
}
 
開發者ID:datancoffee,項目名稱:sirocco,代碼行數:45,代碼來源:StructuredSplitter.java


注:本文中的org.apache.commons.lang.StringUtils.indexOfAny方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。