代码及注释格式化;
This commit is contained in:
parent
56f23a9027
commit
6ef4798752
@ -32,34 +32,61 @@ package org.wltea.analyzer.core;
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class Lexeme implements Comparable<Lexeme> {
|
||||
//英文
|
||||
/**
|
||||
* 英文
|
||||
*/
|
||||
static final int TYPE_ENGLISH = 1;
|
||||
//数字
|
||||
/**
|
||||
* 数字
|
||||
*/
|
||||
static final int TYPE_ARABIC = 2;
|
||||
//英文数字混合
|
||||
/**
|
||||
* 英文数字混合
|
||||
*/
|
||||
static final int TYPE_LETTER = 3;
|
||||
//中文词元
|
||||
/**
|
||||
* 中文词元
|
||||
*/
|
||||
static final int TYPE_CNWORD = 4;
|
||||
//中文单字
|
||||
/**
|
||||
* 中文单字
|
||||
*/
|
||||
static final int TYPE_CNCHAR = 64;
|
||||
//日韩文字
|
||||
/**
|
||||
* 日韩文字
|
||||
*/
|
||||
static final int TYPE_OTHER_CJK = 8;
|
||||
//中文数词
|
||||
/**
|
||||
* 中文数词
|
||||
*/
|
||||
static final int TYPE_CNUM = 16;
|
||||
//中文量词
|
||||
/**
|
||||
* 中文量词
|
||||
*/
|
||||
static final int TYPE_COUNT = 32;
|
||||
//中文数量词
|
||||
/**
|
||||
* 中文数量词
|
||||
*/
|
||||
static final int TYPE_CQUAN = 48;
|
||||
|
||||
//词元的起始位移
|
||||
/**
|
||||
* 词元的起始位移
|
||||
*/
|
||||
private int offset;
|
||||
//词元的相对起始位置
|
||||
/**
|
||||
* 词元的相对起始位置
|
||||
*/
|
||||
private int begin;
|
||||
//词元的长度
|
||||
/**
|
||||
* 词元的长度
|
||||
*/
|
||||
private int length;
|
||||
//词元文本
|
||||
/**
|
||||
* 词元文本
|
||||
*/
|
||||
private String lexemeText;
|
||||
//词元类型
|
||||
/**
|
||||
* 词元类型
|
||||
*/
|
||||
private int lexemeType;
|
||||
|
||||
|
||||
@ -120,7 +147,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
// this.length < other.getLength()
|
||||
return Integer.compare(other.getLength(), this.length);
|
||||
|
||||
}else{//this.begin > other.getBegin()
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -136,8 +163,10 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
int getBegin() {
|
||||
return begin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取词元在文本中的起始位置
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getBeginPosition() {
|
||||
@ -150,6 +179,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
|
||||
/**
|
||||
* 获取词元在文本中的结束位置
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getEndPosition() {
|
||||
@ -158,6 +188,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
|
||||
/**
|
||||
* 获取词元的字符长度
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getLength() {
|
||||
@ -173,6 +204,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
|
||||
/**
|
||||
* 获取词元的文本内容
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getLexemeText() {
|
||||
@ -194,6 +226,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
|
||||
/**
|
||||
* 获取词元类型
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int getLexemeType() {
|
||||
@ -202,6 +235,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
|
||||
/**
|
||||
* 获取词元类型标示字符串
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getLexemeTypeString() {
|
||||
@ -235,7 +269,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
return "TYPE_CQUAN";
|
||||
|
||||
default:
|
||||
return "UNKONW";
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,6 +280,7 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
|
||||
/**
|
||||
* 合并两个相邻的词元
|
||||
*
|
||||
* @return boolean 词元是否成功合并
|
||||
*/
|
||||
boolean append(Lexeme l, int lexemeType) {
|
||||
@ -258,9 +293,10 @@ public class Lexeme implements Comparable<Lexeme>{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ToString 方法
|
||||
*
|
||||
* @return 字符串输出
|
||||
*/
|
||||
public String toString() {
|
||||
return this.getBeginPosition() + "-" + this.getEndPosition() +
|
||||
|
Loading…
x
Reference in New Issue
Block a user