此方法会去除字符串首尾的空白字符，然后把中间的多个连续的换行符替换为一个换行符号

@param text
@return
482732
public static String reduceLineBreaks(String text) {
        if (isEmpty(text)) {
            return text;
        }
        String textTrimed = trimWhitespace(text);
        return textTrimed.replaceAll("(\\r\\n|\\r|\\n)+", "\n");
    }
1036593
public T html(final String text) {
        if (TextUtils.isEmpty(text)) {
            return text("");
        }
        if (text.contains("<") && text.contains(">")) {
            if (view instanceof TextView)
                ((TextView)view).setMovementMethod(LinkMovementMethod.getInstance());
            return text(Html.fromHtml(text));

        } else {
            return text(text);
        }
    }
608787
public T text(CharSequence text, boolean goneIfEmpty) {

        if (goneIfEmpty && (text == null || text.length() == 0)) {
            return gone();
        } else {
            return text(text);
        }
    }
1319421
public static String getSurname(String text){
        if(is(text)){
            //优先识别复姓
            if(isSurname(text.substring(0, 2))){
                return text.substring(0, 2);
            }
            if(isSurname(text.substring(0, 1))){
                return text.substring(0, 1);
            }
        }
        return "";
    }
1055683
public static String getBoldHTMLText(final String text) {
        String boldStr = null;
        if (text != null) {
            final StringBuilder updatedMsg = new StringBuilder("<b>");
            updatedMsg.append(text);
            updatedMsg.append("</b>");
            boldStr = updatedMsg.toString();
        }
        return boldStr;
    }
514366
public synchronized List<Token> tokens(String text) {
        requireValidHandle();
        List<Token> allTokens = new ArrayList<Token>();
        int lastStart = 0;
        for (int i = indexOfSpecialUnknown(text, 0); i != -1; i = indexOfSpecialUnknown(text, i + 1)) {
            allTokens.addAll(tokensNonNull(text.substring(lastStart, i), lastStart));
            allTokens.add(new Token(TokenType.UNKNOWN, Character.toString(text.charAt(i)), i));
            lastStart = i + 1;
        }
        allTokens.addAll(tokensNonNull(text.substring(lastStart), lastStart));
        return allTokens;
    }
1098055
public static String trimAndNullIfEmpty(final String text) {
        if (text != null && !text.trim().isEmpty()) {
            return text.trim();
        }
        return null;
    }
194499
public static int getLineCount(final String text) {
    final Matcher matcher = LINE_FINDER.matcher(text);
    int i = 0;

    while (matcher.find()) {
      i++;
    }

    return i;
  }
1100280
private ArrayList<ArrayList<String>> parseString(String text) {

        ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
        StringTokenizer linetoken = new StringTokenizer(text, "\n");
        StringTokenizer token;
        String current;
        while (linetoken.hasMoreTokens()) {
            current = linetoken.nextToken();
            if (current.contains(",")) {
                token = new StringTokenizer(current, ",");
            } else {
                token = new StringTokenizer(current);
            }
            ArrayList<String> line = new ArrayList<String>();
            while (token.hasMoreTokens()) {
                line.add(token.nextToken());
            }
            result.add(line);
        }
        return result;
    }
660391
private static Long parseLong(final String text) {
		if (text.length() == 0) {
			return null;
		} else {
			try {
				return Long.parseLong(text);
			} catch (NumberFormatException ex) {
				return null;
			}
		}
	}
1157365
public <V> V convertFrom(final char[] text) {
        if (text == null) return null;
        return (V) convertFrom(text, 0, text.length);
    }
840903
protected List<String> getTokens(String text){
		String[] tokens = text.toLowerCase().split("[\\s\\p{Punct}]");
		List<String> tokenList = new ArrayList<String>(tokens.length);
		for (int i = 0; i < tokens.length; i++){
			if (tokens[i].trim().length() < 1){
				continue;
			}
			tokenList.add(tokens[i].trim());
		}
		return tokenList;
	}
244400
public String process(String text){
		String ret = text;
		
		//Pipeline
		ret = convertor.convert(ret);
		ret = senSegment(ret);
		ret = senTokenize(ret);
		ret = wordSegment(ret);
		ret = postProcessing(ret);
		ret = posTagging(ret);
		return ret;
	}
395221
public static int countsForBigram(String text, String pattern) {
        int count = 0;
        int index = -1;
        while (true) {
            index = text.indexOf(pattern, index + 1);
            if (index > -1) {
                LOG.debug("模式: " + pattern + " 出现在文本中的位置：" + index);
                count++;
            } else {
                break;
            }
        }
        return count;
    }
464093
public static String normalize( String text ) {
        CheckArg.isNotNull(text, "text");
        // This could be much more efficient.
        return NORMALIZE_PATTERN.matcher(text).replaceAll(" ").trim();
    }
1221172
public List<String> tokenize(String text) {
		List<String> tokens = new ArrayList<String>();
		text = text.toLowerCase();
		char[] array = text.toCharArray();
		
		//convert all apostrophes to 0x27
		for(int i = 0; i < array.length; i++) {
			if(isApostrofe(array[i])) array[i] = 0x27;
		}
		
		int pos = 0;
		
		//term cycle
		while(pos < array.length) {
			//scan to the start of the term
			while(pos < array.length  && !Character.isLetterOrDigit(array[pos])) pos++;
			int start = pos;
			if(start == array.length) break;
			//scan to the end of the term
			while(pos < array.length  && isLetterOrDigitOrApostrofe(array[pos])) pos++;
			int newpos = pos;
			while(newpos > start && isApostrofe(array[newpos - 1])) newpos--;
			if(newpos > start) tokens.add(new String(array, start, newpos - start));
		}
		return tokens;
	}
499472
public static List<String> asList(String text) {
        if (StringUtils.isBlank(text)) {
            return Collections.emptyList();
        } else {
            try {
                return IOUtils.readLines(new StringReader(text));
            } catch (IOException e) {
                throw new RuntimeException("Cannot get lines", e);
            }
        }
    }