AbstractStringFeature Class Reference

#include <AbstractString.h>

Inheritance diagram for AbstractStringFeature:

PersistantFeature Feature AbstractStringListFeature ActiveWindowFeature GSMCellFeature WlanActiveEssidFeature WlanActiveMacAddressFeature BluetoothPeersFeature SystemCommandStringListFeature WlanPeersFeature List of all members.

Public Types

enum  ComparatorType { None, Levenshtein }

Public Member Functions

virtual double getPosition () const
virtual double getDistance (Feature *f) const
virtual void moveTowards (Feature *f, double factor)
virtual string serialize () const
virtual void unserialize (string value)
virtual featureparams write () const
virtual void read (featureparams *param)
virtual Featureclone () const
virtual void aggregate (aggregatelist samples)
virtual FeatureType getType () const
virtual const string getName () const
const string & getVal () const
const unsigned long getCodeVal () const
 
const stringcodegetCode ()
 
virtual string toString () const

Protected Member Functions

 AbstractStringFeature (ComparatorType comp, stringcode *code, long *maxlen)
 AbstractStringFeature (ComparatorType comp, stringcode *code, long *maxlen, const string &name)
unsigned long getCodeForName (const string &name)

Protected Attributes

long * maxlength
stringcodecode
char * position
unsigned long codeval

Related Functions

(Note that these are not member functions.)

static long levenshtein (char **x, const char *t, double *factor)

Detailed Description

Baseclass for features providing string values

A feature of type nominal which has character strings as values. For comparing values of this feature, either the normal string comparion with the number of different characters (Manhattan distance) or the Levenshtein distance can be used.


Member Enumeration Documentation

enum AbstractStringFeature::ComparatorType
 

The distance metric to use


Constructor & Destructor Documentation

AbstractStringFeature::AbstractStringFeature ComparatorType  comp,
stringcode code,
long *  maxlen
[protected]
 

Feature constructor

This constructor initializes the feature as prototypes value. For creating a specific sample of a feature, the sample constructor should be used.

Parameters:
comp The distance metric that should be used.
code A reference to a static variable (it must be same for all created objects of _one_ feature) for persistantly storing the code table.
maxlen A reference to a static variable (it must be same for all created objects of _one_ feature) for persistantly storing the maximum string length.

AbstractStringFeature::AbstractStringFeature ComparatorType  comp,
stringcode code,
long *  maxlen,
const string &  name
[protected]
 

Sample constructor

This constructor initializes the feature with a specific value and should thus be used for samples.

Parameters:
comp The distance metric that should be used.
code A reference to a static variable (it must be same for all created objects of _one_ feature) for persistantly storing the code table.
maxlen A reference to a static variable (it must be same for all created objects of _one_ feature) for persistantly storing the maximum string length.
name The string representation of the sample value.


Member Function Documentation

void AbstractStringFeature::aggregate aggregatelist  samples  )  [virtual]
 

Aggregate a sample values from other sources

Parameters:
samples A list of <timestamp, sample> tuples.

Implements Feature.

Feature * AbstractStringFeature::clone  )  const [virtual]
 

Clone a feature

A feature must be able to clone itself. This is typically implemented with a copy constructor, but should return a new object.

Implements Feature.

Reimplemented in AbstractStringListFeature.

unsigned long AbstractStringFeature::getCodeForName const string &  name  )  [protected]
 

Get a code value for a given string

A helper function to return the respective code for a given string. If the string is encountered the first time a new code is allocated.

Parameters:
name The string to code
Returns:
A code value

double AbstractStringFeature::getDistance Feature f  )  const [virtual]
 

Todo:
implement a better 'get string for code'

Implements Feature.

Reimplemented in AbstractStringListFeature.

virtual const string AbstractStringFeature::getName  )  const [inline, virtual]
 

Query a features name

Returns:
Name of the Feature in the format "Featureprovider.Feature"

Implements Feature.

Reimplemented in AbstractStringListFeature, ActiveWindowFeature, BluetoothPeersFeature, GSMCellFeature, SystemCommandStringListFeature, WlanActiveEssidFeature, WlanActiveMacAddressFeature, and WlanPeersFeature.

double AbstractStringFeature::getPosition  )  const [virtual]
 

Query a features position

Returns:
The distance to the origin. Every implementation must take care that only values in the interval [0; 1] are returned.
Remarks:
This function is only for the purpose of internal search operations and visualisation and should not be used in any other context.

Implements Feature.

Reimplemented in AbstractStringListFeature.

virtual FeatureType AbstractStringFeature::getType  )  const [inline, virtual]
 

Query a features type

Returns:
The type of the Feature.

Implements Feature.

const string& AbstractStringFeature::getVal  )  const [inline]
 

Query the string values

Returns:
Values list

void AbstractStringFeature::moveTowards Feature f,
double  factor
[virtual]
 

Todo:
implement a better 'get string for code'

Implements Feature.

Reimplemented in AbstractStringListFeature.

void AbstractStringFeature::read featureparams param  )  [virtual]
 

Load feature from persistant data

Initializes the persistant feature data from the given representation.

Parameters:
param Persistant feature data.
See also:
write

Implements PersistantFeature.

string AbstractStringFeature::serialize  )  const [virtual]
 

Serialize a samples data to a string

Returns:
String representation of the samples data.

Implements Feature.

Reimplemented in AbstractStringListFeature.

string AbstractStringFeature::toString  )  const [virtual]
 

Get feature as string

Note:
This is only for testing.
Returns:
Feature as string.

Implements Feature.

Reimplemented in AbstractStringListFeature, ActiveWindowFeature, BluetoothPeersFeature, GSMCellFeature, SystemCommandStringListFeature, WlanActiveEssidFeature, WlanActiveMacAddressFeature, and WlanPeersFeature.

void AbstractStringFeature::unserialize string  value  )  [virtual]
 

Unserialize a samples data from a string

Parameters:
value String representation of the samples data.

Implements Feature.

Reimplemented in AbstractStringListFeature.

featureparams AbstractStringFeature::write  )  const [virtual]
 

Externalize feature

Returns:
Persistant feature data.
See also:
read

Implements PersistantFeature.


Friends And Related Function Documentation

static long levenshtein char **  x,
const char *  t,
double *  factor
[related]
 

Modified Levenshtein algorithm

This function implements a slightly modified version of the Levenshtein algorithm to not only calculate the distance of two strings but also modify the string x towards the string t with the propability factor. In other words, every transformation operation found by the algorithm is performed on the string x with the propability factor.

Parameters:
x Input string.
t String to compare the input string to.
factor Propability with witch transformations are performed. Has to be a value out of the intervall [0; 1].
Returns:
The levenshtein distance between x and t.
Todo:
alloc once


Member Data Documentation

stringcode* AbstractStringFeature::code [protected]
 

A reference to the static, persistant code table of strings seen so far.

unsigned long AbstractStringFeature::codeval [protected]
 

The coded value of the feature

See also:
name

code

long* AbstractStringFeature::maxlength [protected]
 

A reference to the static, persistant maximum length of strings seen so far.

char* AbstractStringFeature::position [protected]
 

Only for internal usage in moveTowards and getDistance.


The documentation for this class was generated from the following files:
Generated on Mon Jun 5 10:20:49 2006 for Intelligence.kdevelop by  doxygen 1.4.6