dictionary.java

来自「基于词库的中文分词组件」· Java 代码 · 共 45 行

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

import java.util.TreeMap;

import org.solol.mmseg.core.IDictionary;
import org.solol.mmseg.core.IWord;

/**
 * @author solo L
 * 
 */
public final class Dictionary implements IDictionary {

	private TreeMap dictionary = new TreeMap();

	public boolean isMatched(String value) {
		return dictionary.containsKey(value);
	}

	public void addWord(String value,int type) {
		dictionary.put(value, new Word(value,type));
	}

	public void addWord(String value, int frequency,int type) {
		dictionary.put(value, new Word(value, frequency,type));
	}

	public IWord getWord(String value) {
		return (IWord) dictionary.get(value);
	}

	public void removeWord(String value) {
		dictionary.remove(value);
	}

	public int getLength() {
		return dictionary.size();

	}

}

⌨️ 快捷键说明

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