com.hankcs.hanlp.utility
类 TextUtility

java.lang.Object
  继承者 com.hankcs.hanlp.utility.TextUtility

public class TextUtility
extends Object

文本工具类


字段摘要
static int CT_CHINESE
          中文字符
static int CT_DELIMITER
          分隔符"!
static int CT_INDEX
          序号
static int CT_LETTER
          字母
static int CT_NUM
          数字
static int CT_OTHER
          其他
static int CT_SINGLE
          单字节
 
构造方法摘要
TextUtility()
           
 
方法摘要
static int charType(char c)
           
static int charType(String str)
          判断字符类型
static int cint(String str)
          把表示数字含义的字符串转你成整形
static int count(String keyword, String srcText)
          统计 keyword 在 srcText 中的出现次数
static String exceptionToString(Exception e)
          将异常转为字符串
static int getCharCount(String charSet, String word)
          得到字符集的字符在字符串中出现的次数
static int getUnsigned(byte b)
          获取字节对应的无符号整型数
static boolean isAllChinese(String str)
          是否全是中文
static boolean isAllChineseNum(String word)
          是否全是中国数字
static boolean isAllDelimiter(byte[] sString)
          是否全是分隔符
static boolean isAllIndex(byte[] sString)
          是否全是序号
static boolean isAllLetter(String text)
          是否全为英文
static boolean isAllLetterOrNum(String text)
          是否全为英文或字母
static boolean isAllNonChinese(byte[] sString)
          是否全部不是中文
static boolean isAllNum(String str)
          是否全是数字
static boolean isAllSingleByte(String str)
          是否全是单字节
static boolean isBlank(CharSequence cs)
          判断字符串是否为空(null和空格)
static boolean isChinese(char c)
          判断某个字符是否为汉字
static boolean isDBCCase(String str)
          判断该字符串是否是半角字符
static boolean isDelimiter(String str)
          判断是否是一个连字符(分隔符)
static boolean isInAggregate(String aggr, String str)
          判断一个字符串的所有字符是否在另一个字符串集合中
static boolean isSBCCase(String str)
          判断该字符串是否是全角字符
static boolean isUnknownWord(String word)
           
static boolean isYearTime(String snum)
          判断字符串是否是年份
static String join(String delimiter, Collection<String> stringCollection)
           
static char[] long2char(long x)
          转换long型为char数组
static String long2String(long x)
          转换long类型为string
static double nonZero(double frequency)
          防止频率为0发生除零错误
static void writeString(String s, DataOutputStream out)
          简单好用的写String方式
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

CT_SINGLE

public static final int CT_SINGLE
单字节

另请参见:
常量字段值

CT_DELIMITER

public static final int CT_DELIMITER
分隔符"!,.?()[]{}+=

另请参见:
常量字段值

CT_CHINESE

public static final int CT_CHINESE
中文字符

另请参见:
常量字段值

CT_LETTER

public static final int CT_LETTER
字母

另请参见:
常量字段值

CT_NUM

public static final int CT_NUM
数字

另请参见:
常量字段值

CT_INDEX

public static final int CT_INDEX
序号

另请参见:
常量字段值

CT_OTHER

public static final int CT_OTHER
其他

另请参见:
常量字段值
构造方法详细信息

TextUtility

public TextUtility()
方法详细信息

charType

public static int charType(char c)

charType

public static int charType(String str)
判断字符类型

参数:
str -
返回:

isAllChinese

public static boolean isAllChinese(String str)
是否全是中文

参数:
str -
返回:

isAllNonChinese

public static boolean isAllNonChinese(byte[] sString)
是否全部不是中文

参数:
sString -
返回:

isAllSingleByte

public static boolean isAllSingleByte(String str)
是否全是单字节

参数:
str -
返回:

cint

public static int cint(String str)
把表示数字含义的字符串转你成整形

参数:
str - 要转换的字符串
返回:
如果是有意义的整数,则返回此整数值。否则,返回-1。

isAllNum

public static boolean isAllNum(String str)
是否全是数字

参数:
str -
返回:

isAllIndex

public static boolean isAllIndex(byte[] sString)
是否全是序号

参数:
sString -
返回:

isAllLetter

public static boolean isAllLetter(String text)
是否全为英文

参数:
text -
返回:

isAllLetterOrNum

public static boolean isAllLetterOrNum(String text)
是否全为英文或字母

参数:
text -
返回:

isAllDelimiter

public static boolean isAllDelimiter(byte[] sString)
是否全是分隔符

参数:
sString -
返回:

isAllChineseNum

public static boolean isAllChineseNum(String word)
是否全是中国数字

参数:
word -
返回:

getCharCount

public static int getCharCount(String charSet,
                               String word)
得到字符集的字符在字符串中出现的次数

参数:
charSet -
word -
返回:

getUnsigned

public static int getUnsigned(byte b)
获取字节对应的无符号整型数

参数:
b -
返回:

isYearTime

public static boolean isYearTime(String snum)
判断字符串是否是年份

参数:
snum -
返回:

isInAggregate

public static boolean isInAggregate(String aggr,
                                    String str)
判断一个字符串的所有字符是否在另一个字符串集合中

参数:
aggr - 字符串集合
str - 需要判断的字符串
返回:

isDBCCase

public static boolean isDBCCase(String str)
判断该字符串是否是半角字符

参数:
str -
返回:

isSBCCase

public static boolean isSBCCase(String str)
判断该字符串是否是全角字符

参数:
str -
返回:

isDelimiter

public static boolean isDelimiter(String str)
判断是否是一个连字符(分隔符)

参数:
str -
返回:

isUnknownWord

public static boolean isUnknownWord(String word)

nonZero

public static double nonZero(double frequency)
防止频率为0发生除零错误

参数:
frequency -
返回:

long2char

public static char[] long2char(long x)
转换long型为char数组

参数:
x -

long2String

public static String long2String(long x)
转换long类型为string

参数:
x -
返回:

exceptionToString

public static String exceptionToString(Exception e)
将异常转为字符串

参数:
e -
返回:

isChinese

public static boolean isChinese(char c)
判断某个字符是否为汉字

参数:
c - 需要判断的字符
返回:
是汉字返回true,否则返回false

count

public static int count(String keyword,
                        String srcText)
统计 keyword 在 srcText 中的出现次数

参数:
keyword -
srcText -
返回:

writeString

public static void writeString(String s,
                               DataOutputStream out)
                        throws IOException
简单好用的写String方式

参数:
s -
out -
抛出:
IOException

isBlank

public static boolean isBlank(CharSequence cs)
判断字符串是否为空(null和空格)

参数:
cs -
返回:

join

public static String join(String delimiter,
                          Collection<String> stringCollection)


Copyright © 2014–2015 鐮佸啘鍦�/a>. All rights reserved.