word.java

来自「使用最大正向匹配算法」· Java 代码 · 共 74 行

JAVA
74
字号
/**
 * 
 */
package org.solol.mmseg.internal;

import org.solol.mmseg.core.IWord;

/**
 * @author solo L
 * 
 */
public class Word implements IWord {

	private String value = "";

	private int frequency = 0;

	private int length = 0;
	
	private int type = UNRECOGNIZED;	

	public Word(String value, int type) {
		this.value = value;
		this.type = type;
		this.length = value.length();
	}

	public Word(String value, int frequency, int type) {
		this(value, type);
		this.frequency = frequency;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.solol.mmseg.core.IWord#getLength()
	 */
	public int getLength() {
		return length;
	}

	public boolean equals(Object anObject) {
		if (this == anObject) {
			return true;
		}
		if (anObject instanceof IWord) {
			IWord anotherWord = (IWord) anObject;
			return anotherWord.getValue().equalsIgnoreCase(value);
		}
		return false;
	}

	public int hashCode() {
		return value.hashCode();
	}

	public String getValue() {
		return value;
	}

	public int getFrequency() {
		return frequency;
	}
	
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

}

⌨️ 快捷键说明

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