⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dictvalue.java

📁 这是关于中文分词的有关程序
💻 JAVA
字号:
/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * Created on 2005-12-28
 * author 谢骋超
 * 
 */
package cn.edu.zju.dartsplitter.data;

import org.apache.commons.lang.builder.HashCodeBuilder;

import cn.edu.zju.dartsplitter.exceptions.DartSplitterException;

/**
 * 词库中的一个词,包装之后用于将它拆散后放到树状词库
 * @author xiecc
 * @email xieccy@gmail.com xieccy@yahoo.com
 * homepage:  http://blog.itpub.net/xiecc
 * projectpage: http://ccnt.zju.edu.cn/projects
 */
public class DictValue {
	private String value;

	// private Reader reader;
	private int curPos = 0;

	private int useCount;

	public DictValue(String value) {
		super();
		// TODO Auto-generated constructor stub
		this.value = value;
	}

	/**
	 * @return Returns the curPos.
	 */
	public int getCurPos() {
		return curPos;
	}

	/**
	 * @param curPos
	 *            The curPos to set.
	 */
	public void setCurPos(int curPos) {
		this.curPos = curPos;
	}

	/**
	 * @return Returns the useCount.
	 */
	public int getUseCount() {
		return useCount;
	}

	/**
	 * @param useCount
	 *            The useCount to set.
	 */
	public void setUseCount(int useCount) {
		this.useCount = useCount;
	}

	/**
	 * @return Returns the value.
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value
	 *            The value to set.
	 */
	public void setValue(String value) {
		this.value = value;
	}

	// private Reader getReader(){
	// if (null!=reader){
	// return reader;
	// }
	// reader=new StringReader(getValue());
	// return this.reader;
	// }

	public String nextValue() {
		if (!isEnd()) {
			curPos++;
			return this.value.substring(curPos - 1, curPos);

		} else {
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.String#length()
	 */
	public int length() {
		return value.length();
	}

	public boolean isEnd() {
		return this.curPos == this.value.length();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(" dict value is " + getValue());
		sb.append(" dict curpos is " + getCurPos());
		sb.append(" dict useCount is " + getUseCount());
		sb.append(" dict isEnd is " + isEnd());
		return sb.toString();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof DictValue)) {
			throw new DartSplitterException("要比较的对象不是DictValue类型!");
		}
		if (null == obj) {
			return false;
		}

		if (this == obj) {
			return true;
		}

		DictValue compareValue = (DictValue) obj;

		if (this.getValue().equals(compareValue.getValue())) {
			return true;
		} else {
			return false;
		}

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(15, 19).append(getValue()).toHashCode();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -