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

📄 dictionary.java

📁 基于词典和最大匹配算法的的中文分词组件
💻 JAVA
字号:
/**
 * 
 */
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -