CWB
Data Structures | Defines | Typedefs | Functions

feature_maps.h File Reference

#include "../cl/cl.h"

Data Structures

Defines

Typedefs

Functions


Define Documentation

#define MAXBLOCKS   10

Typedef Documentation

Underlying structure for the FMS object.

typedef feature_maps_t* FMS

FMS : feature map handle.

typedef struct vstack_t vstack_t

Data structure for the vstack member of the FMS object.

See also:
FMS

Function Documentation

void best_path ( FMS  fms,
int  f1,
int  l1,
int  f2,
int  l2,
int  beam_width,
int  verbose,
int *  steps,
int **  out1,
int **  out2,
int **  out_quality 
)

Finds the best alignment path for the given regions of sentences in source and target corpus.

This function does a beamed dynamic programming search for the best path aligning the sentence regions (f1,l1) in the source corpus and (f2,l2) in the target corpus.

Allowed alignments are 1:0 0:1 1:1 2:1 1:2.

The results are returned in the vectors out1 and out2, which each contain a number of valid entries (alignment points) equal to {steps}.

Alignment points are given as sentence numbers and correspond to the start points of the sentences. At the end-of-region alignment point, sentence numbers will be l1 + 1 and l2 + 1, which must be considered by the caller if l1 (or l2) is the last sentence in the corpus!

The similarity measures of aligned regions are returned in the vector out_quality.

Memory allocated for the return vectors (out1, out2, out_quality) is managed by best_path() and must not be freed by the caller. Calling best_path() overwrites the results of the previous search.

Example usage:

best_path(FMS, f1, l1, f2, l2, beam_width, 0/1, &steps, &out1, &out2, &out_quality);

Parameters:
fmsThe FMS to use.
f1Index of first sentence in source region.
l1Index of last sentence in source region
f2Index of first sentence in target region.
l2Index of last sentence in target region.
beam_widthParameter for the beam search.
verboseBoolean: iff true, prints progress messages on STDOUT.
stepsPut output here (see function description).
out1Put output here (see function description).
out2Put output here (see function description).
out_qualityPut output here (see function description).

References BAR_delete(), BAR_new(), BAR_read(), BAR_write(), beam_width, and feature_match().

Referenced by align_do_alignment().

void check_fvectors ( FMS  fms)

Prints a message about the vector stack of the given FMS.

If it finds a non-zero-count, it prints a message to STDERR. If it doesn't, it prints a message to STDOUT with the count of feature vectors.

Parameters:
fmsThe FMS to check.

References vstack_t::fcount, feature_maps_t::n_features, vstack_t::next, and feature_maps_t::vstack.

FMS create_feature_maps ( char **  config,
int  config_lines,
Attribute w_attr1,
Attribute w_attr2,
Attribute s_attr1,
Attribute s_attr2 
)

Creates feature maps for a source/target corpus pair.

Example usage:

FMS = create_feature_maps(config_data, nr_of_config_lines, source_word, target_word, source_s, target_s);

Parameters:
configpointer to a list of strings representing the feature map configuration.
config_linesthe number of configuration items stored in config_data.
w_attr1The p-attribute in the first corpus to link.
w_attr2The p-attribute in the second corpus to link.
s_attr1The s-attribute in the first corpus to link.
s_attr2The s-attribute in the second corpus to link.
Returns:
the new FMS object.

References feature_maps_t::att1, feature_maps_t::att2, char_map, char_map_range, cl_id2freq(), cl_id2str(), cl_id2strlen(), cl_max_id(), cl_str2id(), config_lines, feature_maps_t::fweight, init_char_map(), feature_maps_t::n_features, feature_maps_t::s1, feature_maps_t::s2, feature_maps_t::vstack, feature_maps_t::w2f1, feature_maps_t::w2f2, word1, and word2.

Referenced by main().

int feature_match ( FMS  fms,
int  f1,
int  l1,
int  f2,
int  l2 
)
int* get_fvector ( FMS  fms)

Feature count vector handling (used internally by feature_match).

References vstack_t::fcount, feature_maps_t::n_features, vstack_t::next, and feature_maps_t::vstack.

Referenced by feature_match().

void release_fvector ( int *  fvector,
FMS  fms 
)

Inserts a new vstack_t at the start of the vstack member of the given FMS.

{That's what it looks like it does, not sure how the function name fits with that... ???? - AH}

References feature_maps_t::vstack.

Referenced by feature_match().

void show_features ( FMS  fms,
int  which,
char *  word 
)

Prints the features in an FMS to STDOUT.

Usage: show_feature(FMS, 1/2, "word");

This will print all features listed in FMS for the token "word"; "word" is looked up in the source corpus if the 2nd argument == 1, and in the target corpus otherwise.

Parameters:
fmsThe FMS to print from.
whichWhich corpus to look up? (See function description)
wordThe token to look up.

References feature_maps_t::att1, feature_maps_t::att2, feature_maps_t::fweight, get_id_of_string, feature_maps_t::w2f1, and feature_maps_t::w2f2.