CWB
|
typedef struct _mapping MappingRecord |
The Mapping object.
A Mapping consists of a bundle of SingleMappings. Each SingleMapping represents a class within the mapping, and each class maps to a number of different tokens on a particular p-attribute in a particular corpus.
Classes are mutually exclusive, i.e. a single token cannot be a member of more than one class in the same Mapping.
NB: "Mapping" is the pointer (class); MappingRecord is the underlying structure.
typedef struct _single_mapping * SingleMapping |
typedef struct _single_mapping SingleMappingRecord |
The SingleMapping object.
This object represents a simple many-to-one mapping between one "class" and a number of different tokens (represented by integer ID codes).
The tokens are values that occur on a particular attribute in a particular corpus. (Note: positional attributes, not other types!) [?? -- is this correct? -- AH]
int drop_mapping | ( | Mapping * | map | ) |
Deletes a Mapping object.
map | Address of the object to delete. |
References cl_free.
Referenced by read_mapping().
SingleMapping find_mapping | ( | Mapping | map, |
char * | name | ||
) |
Find a class within this mapping.
map | The Mapping to look in. |
name | The class to look for. |
References _single_mapping::class_name, _mapping::classes, and _mapping::nr_classes.
Referenced by read_mapping().
int* map_class_to_tokens | ( | SingleMapping | map, |
int * | nr_tokens | ||
) |
Gets the location of the token IDs in this class.
map | The SingleMapping representing the class in question. |
nr_tokens | Address of an integer, which will be set to the number of tokens in this class. |
References _single_mapping::nr_tokens, and _single_mapping::tokens.
int map_id_to_class_number | ( | Mapping | map, |
int | id | ||
) |
Gets the number of the class that contains a particular token in the given Mapping.
map | The Mapping to look in. |
id | The token to look for, identified by its integer ID. |
References _mapping::classes, member_of_class_i(), and _mapping::nr_classes.
Referenced by get_position_values(), and map_token_to_class_number().
SingleMapping map_token_to_class | ( | Mapping | map, |
char * | token | ||
) |
Gets the SingleMapping that contains a particular token in the given Mapping.
map | The Mapping to look in. |
token | The token to look for, identified by string. |
References _mapping::classes, and map_token_to_class_number().
Referenced by read_mapping().
int map_token_to_class_number | ( | Mapping | map, |
char * | token | ||
) |
Gets the number of the class that contains a particular token in the given Mapping.
map | The Mapping to look in. |
token | The token to look for, identified by string. |
References _mapping::attribute, CDA_OK, cderrno, get_id_of_string, and map_id_to_class_number().
Referenced by map_token_to_class().
int member_of_class_i | ( | Mapping | map, |
SingleMapping | class, | ||
int | id | ||
) |
Checks whether a token is a member of a class in a Mapping.
map | The mapping to look in. |
class | The class to check. |
id | The token to look for (identified by its integer ID). |
References intcompare().
Referenced by map_id_to_class_number(), and member_of_class_s().
int member_of_class_s | ( | Mapping | map, |
SingleMapping | class, | ||
char * | token | ||
) |
Checks whether a token is a member of a class in a Mapping.
The token is identified by its
map | The mapping to look in. |
class | The class to check. |
token | The token to look for (identified by its actual string). |
References _mapping::attribute, CDA_OK, cderrno, get_id_of_string, and member_of_class_i().
int number_of_classes | ( | Mapping | map | ) |
Gets the number of classes possessed by this Mapping.
References _mapping::nr_classes.
int number_of_tokens | ( | SingleMapping | map | ) |
Gets the number of tokens possessed by this Mapping.
References _single_mapping::nr_tokens.
void print_mapping | ( | Mapping | map | ) |
Writes a description of a Mapping object to STDERR.
References _Attribute::any, _mapping::attribute, _single_mapping::class_name, _mapping::classes, _mapping::corpus, get_string_of_id, _mapping::mapping_name, _mapping::nr_classes, _single_mapping::nr_tokens, TCorpus::registry_name, and _single_mapping::tokens.
Creates a Mapping from a file.
Each line in the file results in a SingleMapping (unless it begins in #, in which case it either indicates the name of the mapping or is a comment).
Within a single line, the first white-space delimited token represents the name of the class, and the other tokens are attribute values.
Any parse failure in the file will stop the entire Mapping-creation process and result in NULL being returned.
corpus | The corpus for which the Mapping is valid (pointer). |
attr_name | String naming the attribute for which the mapping is valid. |
file_name | The filename of the map spec. |
error_string | A char * (not char[]), which is set to an error string, or to NULL if all is OK. |
References ATT_POS, _mapping::attribute, CDA_OK, cderrno, cl_malloc(), CL_MAX_LINE_LENGTH, cl_realloc(), cl_strdup(), _single_mapping::class_name, CLASS_REALLOC_THRESHOLD, _mapping::classes, corpus, _mapping::corpus, drop_mapping(), find_attribute, find_mapping(), get_id_of_string, intcompare(), map_token_to_class(), _mapping::mapping_name, NAME_TOKEN, _mapping::nr_classes, _single_mapping::nr_tokens, TOKEN_REALLOC_THRESHOLD, and _single_mapping::tokens.