This file contains structures for representing sets of discrete features, where each feature_set has n features, and each feature is of type unsigned int.
| Classes, functions, and variables in this file | |
|---|---|
| struct | feature_set |
| bool | init (feature_set & set, unsigned int feature_count) |
| bool | init (feature_set & set, const feature_set & src) |
| bool | operator == (const feature_set & first, const feature_set & second) |
| struct | feature_set_sorter |
| bool | less_than (const FeatureSet & first, const FeatureSet & second, const feature_set_sorter & sorter) |
| struct | weighted_feature_set |
| bool | init (weighted_feature_set< V > & set, unsigned int feature_count) |
| bool | init (weighted_feature_set< V > & set, const feature_set & src, V log_probability) |
| bool | operator < (const weighted_feature_set< V > & first, const weighted_feature_set< V > & second) |
| double | log_probability (const weighted_feature_set< V > & set) |
This struct represents a sequence of features, with length feature_set::feature_count, each feature having type unsigned int.
The native array that stores the feature values.
The number of features and the length of feature_set::features, feature_set::excluded_counts, and the first dimension of feature_set::excluded.
A two-dimensional array containing excluded feature values. That is, excluded[i] contains the set of excluded feature values for the feature at index i. Each excluded[i] is a sorted array of unsigned int feature values containing distinct elements. The length of excluded[i] is given by feature_set::excluded_counts[i]. For each j such that feature_set::excluded_counts[j] == 0, excluded[j] is NULL.
An array that stores the length of each feature_set::excluded[i].
Initializes this feature set with the given feature_count. Each element in feature_set::features is uninitialized, whereas feature_set::excluded_counts is initialized to all zeros.
| const feature_set & | src | ) |
Initializes this feature set by copying from the given feature_set src.
Returns the feature value at the given index.
Returns the feature value at the given index.
Sets the feature value at the given index.
Returns true if the given feature value is excluded from the feature at the given index. Otherwise, this function returns false.
Checks that the excluded array at feature_set::excluded[index] has sufficient capacity. If that array is NULL, this function will initialize it (leaving its elements uninitialized).
Initializes the excluded array at feature_set::excluded[index] and copies the contents from src. This function assumes feature_set::excluded[index] is previously uninitialized.
Excludes the given item from the feature at the given index, without sorting the excluded array feature_set::excluded[index]. feature_set::excluded_counts[index] is also incremented. This function assumes the excluded array does not already contain item and has sufficient capacity.
Sorts the excluded array at feature_set::excluded[index]. This function assumes the excluded array is not NULL.
Evaluates the hash function for the given feature_set set.
Moves the feature_set in src to dst. Note that this function does not initialize the fields in dst and copy the contents from the corresponding fields in src into dst. Rather, this function simply copies the pointers.
Swaps the underlying pointers in the feature_sets src and dst.
Returns whether feature_set::features is NULL in the given set.
Sets feature_set::features to NULL in the given set.
Sets feature_set::features to NULL in every element of the given array sets.
Frees the underlying arrays in the given feature_set set.
Initializes the given feature_set set with the given feature_count. Each element in feature_set::features is uninitialized, whereas feature_set::excluded_counts is initialized to all zeros.
Initializes the given feature_set set by copying from the given feature_set src.
Returns whether the feature_set in first is equivalent to the one in second. For equivalence, the feature sets must have the same sequence of features, as well as the same set of excluded features at every index.
A sorter for feature sets that enables lexicographical sorting according to the sequence of feature values.
| Public members | |
|---|---|
| feature_set_sorter (unsigned int depth) | |
Initializes the feature_set_sorter with the given depth. This feature_set_sorter sorts feature set objects that have length depth - 1.
| const FeatureSet & | first, | |
| const FeatureSet & | second, | |
| const feature_set_sorter & | sorter | ) |
first and second using the feature_set_sorter sorter.| FeatureSet | a feature set type that implements the function |
| V | satisfies is_arithmetic. |
| Public members | |
|---|---|
| feature_set | features |
| V | log_probability |
| unsigned int | get_feature (unsigned int index) const |
| void | set_feature (unsigned int index, unsigned int feature) |
| bool | ensure_excluded_capacity (unsigned int index, unsigned int capacity) |
| bool | set_excluded (unsigned int index, const unsigned int * src, unsigned int count) |
| void | exclude_unsorted (unsigned int index, unsigned int item) |
| void | sort_excluded (unsigned int index) |
| V | get_probability () const |
| void | set_probability (V probability) |
| static void | move (const weighted_feature_set< V > & src, weighted_feature_set< V > & dst) |
| static void | swap (weighted_feature_set< V > & first, weighted_feature_set< V > & second) |
| static void | free (weighted_feature_set< V > & set) |
The underlying feature_set.
The weight of weighted_feature_set::features.
Returns the feature value at the given index.
Sets the feature value at the given index to feature.
Checks that the excluded array at feature_set::excluded[index] in weighted_feature_set::features has sufficient capacity. If that array is NULL, this function will initialize it (leaving its elements uninitialized).
| unsigned int | index, | |
| const unsigned int * | src, | |
| unsigned int | count | ) |
Initializes the excluded array at feature_set::excluded[index] in weighted_feature_set::features and copies the contents from src. This function assumes feature_set::excluded[index] is previously uninitialized.
Excludes the given item from the feature at the given index, without sorting the excluded array feature_set::excluded[index] in weighted_feature_set::features. feature_set::excluded_counts[index] is also incremented. This function assumes the excluded array does not already contain item and has sufficient capacity.
Sorts the excluded array at feature_set::excluded[index] in weighted_feature_set::features. This function assumes the excluded array is not NULL.
Returns the natural exponent of the weight weighted_feature_set::log_probability.
Sets the weight weighted_feature_set::log_probability to the natural logarithm of the given probability.
| const weighted_feature_set< V > & | src, | |
| weighted_feature_set< V > & | dst | ) |
Moves the given weighted_feature_set in src into dst.
| weighted_feature_set< V > & | first, | |
| weighted_feature_set< V > & | second | ) |
Swaps the weighted_feature_set structures in first and second.
Frees the given weighted_feature_set set.
Initializes the given weighted_feature_set set with the given feature_count. Each element in feature_set::features in weighted_feature_set::features is uninitialized, whereas feature_set::excluded_counts is initialized to all zeros. The weight weighted_feature_set::log_probability is uninitialized.
| weighted_feature_set< V > & | set, | |
| const feature_set & | src, | |
| V | log_probability | ) |
Initializes the given weighted_feature_set set with the given feature_set src and weight log_probability.
| const weighted_feature_set< V > & | first, | |
| const weighted_feature_set< V > & | second | ) |
Returns whether weighted_feature_set::log_probability of first is greater than that of second.
Returns the weight weighted_feature_set::log_probability of set.