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

📄 dictionary.java

📁 垃圾邮件过滤器Java源码 本软件基于朴素贝叶斯算法
💻 JAVA
字号:
/*
 * Dictionary.java
 *
 * Created on 2008年12月2日, 下午12:01
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package newpackage;

// 中文分词词典类
// Class for Dictionary
//
import java.util.*;
import java.io.*;
import java.lang.*;
/**
 *
 * @author Administrator
 */
public class Dictionary
{
        HashMap hm;		//a word set

        public Dictionary()
        {
                hm = new HashMap();
        }

        public Dictionary(String fileName)
        {
                hm = new HashMap();
                Load(fileName);
        }

        public void Load(String fileName)    //装载汉语字典
        {
                try
                {
                        BufferedReader in=
                                new BufferedReader(
                                        new FileReader(fileName) );

                        String s;
                        String []words;
                        while((s = in.readLine()) != null)
                        {
                                words = s.split("\t");
                                hm.put(words[0],new Integer(0));
                        }
                }
                catch(IOException e)
                {
                        System.out.println("Error: " + e);
                }
        }

        public boolean Find(String word)    //从字典里查询词
        {
                return hm.containsKey(word);
        }


}

⌨️ 快捷键说明

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