public class NetricsCharmap
extends java.lang.Object
When matching data it is usually advantageous to perform certain character normalizations before matching. These include things such as mapping all letters to a common letter case, normalizing white space, stripping out certain special characters. A character map defines the set of rules to be applied. The TIBCO Patterns Engine has a default character map that is appropriate for most cases. It maps all letters to lower case, strips all diacritic marks from letters, maps all punctuation and special characters to a blank, maps all whitespace to blanks, and compresses out all repeated blanks. There is also a second predefined character map that is similar to the standard map except that punctuation and special characters are left unchanged. For those cases where neither of these are appropriate the user can define their own character mapping rules. This class is the means by which these character mapping rules are defined.
Terms such as "letter" and "whitespace" are as defined in the unicode standard. The exception is that "punctuation" or "special characters" is a little broader than the unicode standard. Within the ASCII range this includes all characters that are not letters, digits or whitespace.
The first 16 bits of the full unicode character set are supported. This includes all commonly used code pages, including the Chinese and Japanese characters.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
Punctuation
The name of the predefined punctuation sensitive character map.
|
static java.lang.String |
Standard
The name of the predefined default character map.
|
| Constructor and Description |
|---|
NetricsCharmap(java.lang.String name)
Specify the name of the character map.
|
| Modifier and Type | Method and Description |
|---|---|
void |
foldCase()
Equate all letter cases to lower case.
|
void |
foldDiacritics()
Equate characters with diacritics with their normal cognates.
|
void |
mapChars(char[] fromchars,
char[] tochars)
Use this method to equate any character with any other.
|
void |
mapPunctuation(char c)
Map all punctuation characters to a specific character.
|
void |
mapWhitespace(char c)
Map all whitespace characters to a specific character.
|
public static final java.lang.String Standard
public static final java.lang.String Punctuation
public NetricsCharmap(java.lang.String name)
name - Name of the character map.public void foldCase()
public void foldDiacritics()
public void mapWhitespace(char c)
This adds a rule that maps all whitespace characters to a common character.
Note: mapping whitespace to any character other than the standard blank character will significantly alter the scoring of data as all data will be considered a single token.
c - The character to map topublic void mapPunctuation(char c)
This is often used to equate hyphen, slash, period, comma, etc to the space character. This ignores all punctuation and special characters except that they are considered token separators. If desired they can be mapped to a different character. In this case all punctuation and special characters would be considered equivalent, but they would not act as token separators.
c - The character to map topublic void mapChars(char[] fromchars,
char[] tochars)
A character at index x in the from array will be mapped to the character at index x in the to array. Each pair of characters will be considered equivalent for the purposes of matching.
Mappings defined here will supersede the character class mappings defined by foldCase, foldDiacritics, mapWhitespace and mapPunctuation. Thus if you wanted to map all punctuation marks except the pound (#) character you could do so by calling mapPunctuation and mapChars with the pound character mapped to itself.
fromchars - The characters to map from.tochars - The characters to map to