CWB
Defines | Functions

eval.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <sys/types.h>
#include "../cl/globals.h"
#include "../cl/macros.h"
#include "../cl/corpus.h"
#include "../cl/attributes.h"
#include "../cl/cdaccess.h"
#include "../cl/special-chars.h"
#include "cqp.h"
#include "ranges.h"
#include "options.h"
#include "tree.h"
#include "symtab.h"
#include "corpmanag.h"
#include "regex2dfa.h"
#include "eval.h"
#include "builtins.h"
#include "output.h"
#include "matchlist.h"

Defines

Functions


Define Documentation

#define no_match   -1
#define RED_THRESHOLD   0.01

Referenced by matchfirstpattern().


Function Documentation

Boolean calculate_initial_matchlist ( Constrainttree  ctptr,
Matchlist matchlist,
CorpusList corpus 
)

Wrapper around calculate_initial_matchlist1, qv.

See also:
calculate_initial_matchlist1

References calculate_initial_matchlist_1(), Complement, _Matchlist::is_inverted, mark_offrange_cells(), Reduce, and Setop().

Referenced by cqp_run_tab_query(), eval_mu_tree(), and matchfirstpattern().

Boolean calculate_initial_matchlist_1 ( Constrainttree  ctptr,
Matchlist matchlist,
CorpusList corpus 
)
int check_alignment_constraints ( Matchlist ml)
void cqp_run_mu_query ( int  keep_old_ranges,
int  cut_value 
)
void cqp_run_query ( int  cut,
int  keep_old_ranges 
)

This function wraps round simulate_dfa (the only other thing it does is enforce the hard_cut limit).

See also:
hard_cut
simulate_dfa

References eep, hard_cut, and simulate_dfa().

Referenced by do_StandardQuery().

void cqp_run_tab_query ( int  implode)
Boolean eval_bool ( Constrainttree  ctptr,
RefTab  rt,
int  corppos 
)
Boolean eval_constraint ( AVS  avs,
int  corppos,
RefTab  labelrefs,
RefTab  target_labelrefs 
)
int eval_mu_tree ( Evaltree  et,
Matchlist ml 
)
int free_environment ( int  thisenv)

Frees an evaluation environment.

The environment must be one currently occupied within the global array.

See also:
Environment
eep
Parameters:
thisenvThe eval environment to free.
Returns:
Boolean: true if the deletion went OK; false if the environment to be freed was not occupied (will print an error message).

References Anchor, ctxtsp::attrib, cl_delete_regex(), cl_free, delete_symbol_table(), ctxtsp::direction, eep, Environment, False, free_booltree(), free_dfa(), free_evaltree(), evalenv::gconstraint, evalenv::has_target_indicator, evalenv::labels, leftright, MatchAll, evalenv::MaxPatIndex, NoField, Pattern, evalenv::patternlist, evalenv::query_corpus, evalenv::search_context, ctxtsp::size, Tag, dfa::TransTable, ctxtsp::type, cl::type, and word.

Referenced by free_environments().

void free_environments ( void  )

Frees all eval environments in the global array, and sets the eep pointer to -1.

References eep, and free_environment().

Referenced by in_UnnamedCorpusCommand(), and prepare_input().

int get_corpus_positions ( Attribute attribute,
char *  wordform,
Matchlist matchlist 
)

Gets a list of corpus positions where the given p-attribute has the specified form.

Positions are placed into the "start" array of the matchlist.

Parameters:
attributeThe p-attribute to search.
wordformThe form to search for.
matchlistWhere to put the results.
Returns:
The size of the resulting matchlist table (also stored in its tabsize member).

References CDA_OK, cl_errno, cl_idlist2cpos, cl_str2id(), initial_matchlist_debug, _Matchlist::matches_whole_corpus, silent, _Matchlist::start, and _Matchlist::tabsize.

Referenced by calculate_initial_matchlist_1().

int get_label_referenced_position ( LabelEntry  label,
RefTab  rt,
int  corppos 
)
Boolean get_leaf_value ( Constrainttree  ctptr,
RefTab  rt,
int  corppos,
DynCallResult dcr,
int  deliver_strings 
)
int get_matched_corpus_positions ( Attribute attribute,
char *  regstr,
int  canonicalize,
Matchlist matchlist,
int *  restrictor_list,
int  restrictor_size 
)

Get corpus positions matching a regular expression on a given attribute.

get_matched_corpus_positions looks in a corpus which is to be loaded for a regular expression 'regstr' of a given p-attribute and returns the table of matching start indices (start_table) and the tablesize (tabsize).

Parameters:
attributeThe attribute to search on. May be NULL, in which case DEFAULT_ATT_NAME is used.
regstrString containing the regular expression.
canonicalizeFlags to be passed to the CL regex engine.
matchlistLocation where the list of matches will be placed.
restrictor_listPassed to cl_idlist2cpos_oldstyle
restrictor_sizePassed to cl_idlist2cpos_oldstyle
Returns:
The number of matches found.

References ATT_POS, cl_free, cl_idlist2cpos_oldstyle(), cl_malloc(), cl_max_cpos(), cl_max_id(), cl_new_attribute_oldstyle(), cl_regex2id(), cl::corpus, DEFAULT_ATT_NAME, eval_debug, initial_matchlist_debug, _Matchlist::is_inverted, _Matchlist::matches_whole_corpus, evalenv::query_corpus, cl::range, silent, cl::size, _Matchlist::start, STREQ, and _Matchlist::tabsize.

Referenced by calculate_initial_matchlist_1(), and matchfirstpattern().

static int intcompare ( const void *  i,
const void *  j 
) [static]

Comparison function used when calling qsort().

Referenced by eval_bool().

int mark_offrange_cells ( Matchlist matchlist,
CorpusList corpus 
)
Boolean matchfirstpattern ( AVS  pattern,
Matchlist matchlist,
CorpusList corpus 
)
int meet_mu ( Matchlist list1,
Matchlist list2,
int  lw,
int  rw,
Attribute struc 
)
int next_environment ( void  )
int nr_positions ( CorpusList cp)

Counts the number of token positions encompassed by all members of the ->range array of the CorpusList argument.

That is, in oher words, it tells you the size of this corpus.

References _Range::end, cl::range, cl::size, and _Range::start.

Referenced by compose_kwic_line(), red_factor(), and remember_this_position().

float red_factor ( CorpusList cp,
int *  nr_pos 
)
void set_corpus_matchlists ( CorpusList cp,
Matchlist matchlist,
int  nr_lists,
int  keep_old_ranges 
)
void show_environment ( int  thisenv)

Prints the contents of an EvalEnvironment object to STDOUT.

Which bits of information are printed depends on which of a group of debugging-variables are set to true.

The EvalEnvironment to print is specified as an index into the global array (Environment).

See also:
Environment
Parameters:
thisenvIndex into Environment indicating which EvalEnvironment should be displayed.

References eep, Environment, print_booltree(), print_evaltree(), show_compdfa, show_complete_dfa(), show_evaltree, show_gconstraints, show_patlist, and show_patternlist().

Referenced by debug_output().

void simulate ( Matchlist matchlist,
int *  cut,
int  start_state,
int  start_offset,
int *  state_vector,
int *  target_vector,
RefTab reftab_vector,
RefTab reftab_target_vector,
int  start_transition 
)
void simulate_dfa ( int  envidx,
int  cut,
int  keep_old_ranges 
)