CWB
Data Structures | Macros | Typedefs | Functions
context_descriptor.h File Reference
#include "attlist.h"

Data Structures

struct  _context_description_block
 ContextDescriptor object: a bundle of CQP options describing how a list of corpus positions is to be displayed in a concordance: with left context, with right context, with what attributes, etc. More...
 

Macros

#define CHAR_CONTEXT   -1
 Context width measured in characters. More...
 
#define WORD_CONTEXT   -2
 Context width measured in tokens. More...
 
#define STRUC_CONTEXT   -3
 Context width measured in terms of an s-attribute. More...
 
#define ALIGN_CONTEXT   -4
 Context width measured in terms of an a-attribute - that is, alignment blocks as the unit of context. More...
 

Typedefs

typedef struct
_context_description_block 
ContextDescriptor
 ContextDescriptor object: a bundle of CQP options describing how a list of corpus positions is to be displayed in a concordance: with left context, with right context, with what attributes, etc. More...
 

Functions

int verify_context_descriptor (Corpus *corpus, ContextDescriptor *cd, int remove_illegal_entries)
 Verify the current context settings against the current corpus: check whether structures are still valid, and reset them to defaults if not. More...
 
int initialize_context_descriptor (ContextDescriptor *cd)
 Initialises the member variables of a ContextDescriptor object to zero. More...
 
int update_context_descriptor (Corpus *corpus, ContextDescriptor *cd)
 Imports lists of attributes (p-, s-, and a-) from a Corpus record into a ContextDescriptor record (where they can then be used as concordance display info). More...
 
ContextDescriptorNewContextDescriptor (void)
 Creates (and initialises) a ContextDescriptor object. More...
 
void PrintContextDescriptor (ContextDescriptor *cdp)
 Prints the contents of a ContextDescriptor either to stdout or a pager (NB this uses its own internal stream). More...
 

Macro Definition Documentation

#define ALIGN_CONTEXT   -4

Context width measured in terms of an a-attribute - that is, alignment blocks as the unit of context.

Referenced by compose_kwic_line(), print_option_value(), PrintContextDescriptor(), and verify_context_descriptor().

#define CHAR_CONTEXT   -1
#define STRUC_CONTEXT   -3
#define WORD_CONTEXT   -2

Typedef Documentation

ContextDescriptor object: a bundle of CQP options describing how a list of corpus positions is to be displayed in a concordance: with left context, with right context, with what attributes, etc.

It is passed around between different print functions so that they know what to do!

Note that the options contained here are settable by the user. This is in contrast to the "options" held in the PrintDecriptionRecord, which are built-in for each print style; the user can choose among modes but cannot modify the settings individually.

TODO This object is confusingly named, as it DOES NOT merely specify the "Context" size; it also specifies which attributes get printed, and so on.

(It would be better called a "concordance line co-text configuration object".)

See also
PrintDescriptionRecord

TODO why is it necessary for concordance-printing options to be spread across two separate objects?

Function Documentation

int initialize_context_descriptor ( ContextDescriptor cd)

Initialises the member variables of a ContextDescriptor object to zero.

Initial settings are: no attributes for printing, no right context, no left context, no cpos printing.

TODO since this should never be called except when a new context descriptor is being created (structure names can memleak if it is called on one already used, it would make sense ot merge this into the NewC.D. function. (it is, in fact, used in options.c to set up the static global variable CD, which is not malloc'd - perhaps change this to modularise the ContextDescirptor object better?)

See also
ContextDescriptor

References _context_description_block::alignedCorpora, _context_description_block::attributes, CHAR_CONTEXT, _context_description_block::left_structure, _context_description_block::left_structure_name, _context_description_block::left_type, _context_description_block::left_width, _context_description_block::print_cpos, _context_description_block::printStructureTags, _context_description_block::right_structure, _context_description_block::right_structure_name, _context_description_block::right_type, _context_description_block::right_width, and _context_description_block::strucAttributes.

Referenced by init_align_module(), NewContextDescriptor(), printAlignedStrings(), and set_default_option_values().

ContextDescriptor* NewContextDescriptor ( void  )

Creates (and initialises) a ContextDescriptor object.

References cl_malloc(), and initialize_context_descriptor().

void PrintContextDescriptor ( ContextDescriptor cdp)
int update_context_descriptor ( Corpus corpus,
ContextDescriptor cd 
)

Imports lists of attributes (p-, s-, and a-) from a Corpus record into a ContextDescriptor record (where they can then be used as concordance display info).

Parameters
corpusThe source of the settings.
cdThe destination of the settings.
Returns
Always 1.

References _context_description_block::alignedCorpora, ATT_ALIGN, ATT_POS, ATT_STRUC, _context_description_block::attributes, find_attribute, _attlist::list, _attrbuf::name, NewAttributeList(), _attrbuf::next, _context_description_block::printStructureTags, RecomputeAL(), RemoveNameFromAL(), _context_description_block::strucAttributes, and structure_has_values.

Referenced by printAlignedStrings(), and set_current_corpus().

int verify_context_descriptor ( Corpus corpus,
ContextDescriptor cd,
int  remove_illegal_entries 
)