org.jscience.linguistics.search
Class BNDMWildcards

java.lang.Object
  extended by org.jscience.linguistics.search.StringSearch
      extended by org.jscience.linguistics.search.BNDM
          extended by org.jscience.linguistics.search.BNDMWildcards

public class BNDMWildcards
extends BNDM

An implementation of the BNDM algorithm with wildcards ("don't care" symbols). The wildcard character is initially '?', but any character can be used through the processChars(char[],char) and the (byte[], byte) methods.

This algorithm is around five times faster than ShiftOrWildcards.

 Preprocessing: O(2m + ∑) time

See Also:
processBytes(byte[],byte), processChars(char[],char), BNDM

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jscience.linguistics.search.StringSearch
StringSearch.Dispatch, StringSearch.ReflectionDispatch
 
Field Summary
static char wildcard
          The wildcard character (initially '?').
 
Fields inherited from class org.jscience.linguistics.search.StringSearch
activeDispatch, useNative
 
Constructor Summary
BNDMWildcards()
          Constructor for BNDMWildcards.
 
Method Summary
 java.lang.Object processBytes(byte[] pattern)
          Pre-processing of the pattern.
 java.lang.Object processBytes(byte[] pattern, byte w)
          Pre-processing of the pattern.
 java.lang.Object processChars(char[] pattern)
          Pre-processes the pattern.
 java.lang.Object processChars(char[] pattern, char w)
          Pre-processes the pattern.
 java.lang.Object processString(java.lang.String pattern, char w)
          Pre-processes the pattern.
 
Methods inherited from class org.jscience.linguistics.search.BNDM
searchBytes, searchChars
 
Methods inherited from class org.jscience.linguistics.search.StringSearch
createCharIntMap, createCharIntMap, equals, hashCode, index, processString, searchBytes, searchBytes, searchBytes, searchBytes, searchBytes, searchChars, searchChars, searchChars, searchChars, searchChars, searchString, searchString, searchString, searchString, searchString, searchString, toString, toStringBuffer, usesNative, usesReflection
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

wildcard

public static char wildcard
The wildcard character (initially '?').

Constructor Detail

BNDMWildcards

public BNDMWildcards()
Constructor for BNDMWildcards. Note that it is not required to create multiple instances.

Method Detail

processBytes

public java.lang.Object processBytes(byte[] pattern)
Pre-processing of the pattern. The pattern may not exceed 32 bytes in length. If it does, only it's first 32 bytes are processed which might lead to unexpected results. The wildcard character is obtained from the static wildcard field.

Overrides:
processBytes in class BNDM
Parameters:
pattern - DOCUMENT ME!
Returns:
DOCUMENT ME!
See Also:
StringSearch.processBytes(byte[]), processBytes(byte[],byte)

processBytes

public java.lang.Object processBytes(byte[] pattern,
                                     byte w)
Pre-processing of the pattern. The pattern may not exceed 32 bytes in length. If it does, only it's first 32 bytes are processed which might lead to unexpected results. Returns an int array.

Parameters:
pattern - the byte array containing the pattern, may not be null
w - the wildcard byte character
Returns:
an int array

processChars

public java.lang.Object processChars(char[] pattern)
Pre-processes the pattern. The pattern may not exceed 32 characters in length. If it does, only it's first 32 bytes are processed which might lead to unexpected results. The wildcard character is obtained from the static wildcard field.

Overrides:
processChars in class BNDM
Parameters:
pattern - the char array containing the pattern, may not be null
Returns:
a CharIntMap
See Also:
StringSearch.processChars(char[]), processChars(char[],char)

processChars

public java.lang.Object processChars(char[] pattern,
                                     char w)
Pre-processes the pattern. The pattern may not exceed 32 characters in length. If it does, only it's first 32 bytes are processed which might lead to unexpected results. Returns a CharIntMap.

Parameters:
pattern - the char array containing the pattern, may not be null
w - the wildcard character
Returns:
a CharIntMap.

processString

public java.lang.Object processString(java.lang.String pattern,
                                      char w)
Pre-processes the pattern. The pattern may not exceed 32 characters in length. If it does, only it's first 32 bytes are processed which might lead to unexpected results. Returns a CharIntMap.

Parameters:
pattern - the String array containing the pattern, may not be null
w - the wildcard character
Returns:
a CharIntMap.