net.sf.jabb.util.text.word
Class Dictionary

java.lang.Object
  extended by net.sf.jabb.util.text.word.Dictionary

public class Dictionary
extends Object

词典。

Dictionary of words.

Author:
Zhengmao HU (James)

Field Summary
protected  javolution.util.FastMap<String,Word> words
           
 
Constructor Summary
Dictionary()
           
Dictionary(Dictionary original)
          创建一个实例,其内容是拷贝自另一个实例。
 
Method Summary
 void addWord(Word newWord)
          加入一个新词条,如果这个词条在词典中已经存在,则合并。 词条对象不会被复制,而是会被引用。
 void addWord(Word newWord, boolean makeCopy)
          加入一个新词条,如果这个词条在词典中已经存在,则合并。
 Map<String,Word> getWords()
           
 void loadWords(InputStream is, int wordType)
          从流中载入一批指定类型的词条。如果某个词条在词典中已经存在,则合并。
 void merge(Dictionary dict)
          将另一个字典的内容合并进来。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

words

protected javolution.util.FastMap<String,Word> words
Constructor Detail

Dictionary

public Dictionary()

Dictionary

public Dictionary(Dictionary original)
创建一个实例,其内容是拷贝自另一个实例。

Create an instance which is a copy of another instance.

Parameters:
original -
Method Detail

merge

public void merge(Dictionary dict)
将另一个字典的内容合并进来。

Merge the words from another dictionary into this one.

Parameters:
dict - 将要被合并进来的另一个字典
The other dictionary that will be merged into this one.

addWord

public void addWord(Word newWord,
                    boolean makeCopy)
加入一个新词条,如果这个词条在词典中已经存在,则合并。

Add a new word, if this word already exists in the dictionary then the new definition will be merged into existing one.

Parameters:
newWord -
makeCopy - 是否复制词条对象,而非引用
Whether or not to copy the Word object, rather than to refer it.

addWord

public void addWord(Word newWord)
加入一个新词条,如果这个词条在词典中已经存在,则合并。 词条对象不会被复制,而是会被引用。

Add a new word, if this word already exists in the dictionary then the new definition will be merged into existing one. The Word object will not be copied, it will be referenced.

Parameters:
newWord -

loadWords

public void loadWords(InputStream is,
                      int wordType)
               throws IOException
从流中载入一批指定类型的词条。如果某个词条在词典中已经存在,则合并。

Load a batch of word of specified type from stream. If any word already exists in the dictionary, then the new definition will be merged into existing one.

Parameters:
is - 输入流
The stream to read from.
wordType - 类型,定义在Word类中
Type of the word, which is defined in the class Word.
Throws:
IOException

getWords

public Map<String,Word> getWords()
Returns:
the words


Copyright © 2012. All Rights Reserved.