Java Reference
In-Depth Information
Type: PERSON Entity: [Joe] Score: -Infinity
Type: ORGANIZATION Entity: [Fred] Score: -Infinity
Type: LOCATION Entity: [Boston] Score: -Infinity
Type: PERSON Entity: [McKenzie] Score: -Infinity
Type: PERSON Entity: [Joe] Score: -Infinity
Type: ORGANIZATION Entity: [Vermont] Score: -Infinity
Type: ORGANIZATION Entity: [IBM] Score: -Infinity
Type: ORGANIZATION Entity: [Fred] Score: -Infinity
Using the ExactDictionaryChunker class
The ExactDictionaryChunker class provides an easy way to create a dictionary of
entities and their types, which can be used to find them later in text. It uses a MapDic-
tionary object to store entries and then the ExactDictionaryChunker class is
used to extract chunks based on the dictionary.
The AbstractDictionary interface supports basic operations for entities, categories,
and scores. The score is used in the matching process. The MapDictionary and
TrieDictionary classes implement the AbstractDictionary interface. The
TrieDictionary class stores information using a character trie structure. This ap-
proach uses less memory when it is a concern. We will use the MapDictionary class
for our example.
To illustrate this approach, we start with a declaration of the MapDictionary class:
private MapDictionary<String> dictionary;
The dictionary will contain the entities that we are interested in finding. We need to ini-
tialize the model as performed in the following initializeDictionary method.
The DictionaryEntry constructor used here accepts three arguments:
String : The name of the entity
String : The category of the entity
Double : Represent a score for the entity
The score is used when determining matches. A few entities are declared and added to the
dictionary.
private static void initializeDictionary() {
dictionary = new MapDictionary<String>();
Search WWH ::




Custom Search