All evaluation functions use output parameters of type Value to compute and return their results. ErrorValue is returned if any error occurred during evaluation, such as an access to a feature of the root node. This typically does not cause a run-time error, but simply makes the containing formula evaluate to FALSE. Note that unpredictable results can be produced if an error occurs in a nested term. Therefore an evaluation error always produces a CDG_WARNING message.
Data Structures | |
struct | BadnessStruct |
Static Strings | |
These strings are used so often that we want to pre-compute their addresses. This is the only location where it's really important to have full speed. They are initialized in evalInitialize() | |
String | static_string_chunk_end |
String | static_string_chunk_start |
String | static_string_chunk_type |
String | static_string_from |
String | static_string_id |
String | static_string_info |
String | static_string_to |
String | static_string_word |
Typedefs | |
typedef BadnessStruct * | Badness |
Enumerations | |
enum | EvalMethodType { EMTInterpreted, EMTCompiled } |
Functions | |
Badness | bAdd (Badness b, Number score) |
Badness | bAddBadness (Badness a, Badness b) |
Badness | bClone (Badness b) |
Boolean | bCompare (Badness a, Badness b) |
void | bCopy (Badness dest, Badness src) |
void | bDelete (Badness b) |
Boolean | bEqual (Badness a, Badness b) |
Badness | bestBadness (void) |
Badness | bNew (int no, int hard, Number soft) |
void | bPrint (unsigned long mode, Badness b) |
Badness | bSubtract (Badness b, Number score) |
Badness | bSubtractBadness (Badness a, Badness b) |
Number | evalBinary (LevelValue lva, LevelValue lvb, ConstraintNet net, Vector context, Boolean use_cs_only, Badness b, List *conflicts) |
Boolean | evalBinaryConstraint (Constraint c, ConstraintNet net, Vector context, LevelValue lva, LevelValue lvb) |
Boolean | evalConstraint (Constraint c, ConstraintNet net, Vector context,...) |
void | evalFinalize (void) |
Boolean | evalFormula (Formula f, LexemGraph lg, Vector context) |
Number | evalInContext (Vector LVs, Vector context, Badness b, List *conflicts) |
void | evalInitialize (void) |
Value | evalTerm (Term t, Value val, LexemGraph lg, Vector context) |
Number | evalUnary (LevelValue lv, ConstraintNet net, Vector context, Boolean use_cs_only, Badness b, List *conflicts) |
Boolean | evalUnaryConstraint (Constraint c, ConstraintNet net, Vector context, LevelValue lv) |
Boolean | evalValidateEvalMethod (String name, String value, int *var) |
void | lock_tree (int width) |
Value | peekValue (Value val, List path) |
Boolean | significantlyGreater (Number a, Number b) |
void | unlock_tree (void) |
Badness | worstBadness (void) |
Variables | |
Constraint | evalCurrentConstraint |
Constraint | evalCurrentConstraint = NULL |
Formula | evalCurrentFormula |
Formula | evalCurrentFormula = NULL |
EvalMethodType | evalEvaluationMethod |
EvalMethodType | evalEvaluationMethod = EMTInterpreted |
EvalMethodType | evalPeekValueMethod |
EvalMethodType | evalPeekValueMethod = EMTCompiled |
Boolean | evalSloppySubsumesWarnings |
Boolean | evalSloppySubsumesWarnings = FALSE |
int * | has_cache |
int * | has_cache = NULL |
int | lock_counter |
int | lock_counter = 0 |
int | lock_width |
int | lock_width = 0 |
String | static_string_chunk_end |
String | static_string_chunk_start |
String | static_string_chunk_type |
String | static_string_from |
String | static_string_id |
String | static_string_info |
String | static_string_to |
String | static_string_word |
|
A pointer to a BadnessStruct Definition at line 60 of file eval.h. Referenced by bAdd(), bAddBadness(), bClone(), bCompare(), bCopy(), bDelete(), bEqual(), bestBadness(), bNew(), bPrint(), bSubtract(), bSubtractBadness(), evalBinary(), evalInContext(), evalUnary(), and worstBadness(). |
|
Evaluation method This is the Type of the evaluation method which could be:
Referenced by comApprove(). |
|
Add score to a Badness. This function adds a classical score to a generalized score, i.e. it either increments b->hard or multiplies b->soft by score. Definition at line 258 of file eval.c. References Badness, BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. Referenced by evalBinary(), and evalUnary(). |
|
Add Badness b to a. Definition at line 290 of file eval.c. References Badness, BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. |
|
Create deep copy of a Badness. The result is a new Badness owned by the caller. Definition at line 246 of file eval.c. References Badness, bNew(), BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. |
|
Compare two Badnesses. Returns TRUE if a is properly better than b, FALSE if they are equal. Definition at line 348 of file eval.c. References Badness, FALSE, BadnessStruct::hard, significantlyGreater(), BadnessStruct::soft, and TRUE. Referenced by cmdWriteAnno(). |
|
Copy a Badness. src must have been allocated by the caller. Definition at line 236 of file eval.c. References Badness. |
|
De-allocate a Badness. Definition at line 317 of file eval.c. References Badness. |
|
Test if two badnesses are equal. Definition at line 338 of file eval.c. References Badness, BadnessStruct::hard, and BadnessStruct::soft. |
|
Return new Badness better than any other. The result is owned by the caller. Definition at line 370 of file eval.c. |
|
Allocate a Badness. Definition at line 219 of file eval.c. References Badness, BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. Referenced by bClone(), bestBadness(), and worstBadness(). |
|
Print a badness in canonical form. Definition at line 325 of file eval.c. References Badness, cdgPrintf(), BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. |
|
Subtract score from a Badness. Definition at line 274 of file eval.c. References Badness, BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. |
|
Subtract Badness b from a. Definition at line 302 of file eval.c. References Badness, BadnessStruct::hard, BadnessStruct::no, and BadnessStruct::soft. |
|
Evaluate all constraints on two LVs. This function performs a conceptually simple task: it computes the combined score of two LVs in a constraint net and returns the computed score. This is done by applying evalConstraint() to all known constraints and tallying the scores of all violated constraints. For efficiency reasons, the actual implementation of this function is much more complicated:
Unary constraints are ignored completely. Inactive constraints and constraints from inactive sections are skipped likewise. Of the remaining constraints, only those that may actually fail are evaluated. Hence not all constraints are evaluated, but only those whose signature matches the actual configuration existing between lva and lvb. The List of these constraints is found in the matrix cdgConstraintMatrix[]. In fast mode, if a hard constraint is violated, the result 0.0 is returned immediately. If the parameter context is NULL, context-sensitive constraints will not be evaluated. If the parameter use_cs_only is set, ONLY context-sensitive constraints will be evaluated. See evalInContext() for why this is occasionally necessary.
A double fault can only occur if the LVs match the signature of a constraint in both variants of instantiation. Since every binary constraint signature must explicitly state the two levels it refers to, this is only possible if both LVs belong to the same level and either their configuration is symmetrical, or it is is asymmetrical, but the signature of the constraint subsumes both configurations. To eliminate all double faults, evalBinary() checks for all of these possibilities explicitly.
The parameter net can be NULL, so that LVs can be evaluated even in the absence of a constraint net. In this case no caching is possible. Definition at line 1395 of file eval.c. References bAdd(), Badness, ConstraintNetStruct::cache, CDG_DEBUG, cdgPrintf(), ConstraintNet, cvNew(), evalBinaryConstraint(), FALSE, lock_tree(), NULL, scGetScore(), scSetScore(), scUseCache, TRUE, and unlock_tree(). Referenced by cnBuildEdges(), comCompareAllLvPairs(), comCompareWithContext(), and evalInContext(). |
|
Evaluate one binary constraint on two LVs. This function evaluates a binary constraint. It has the same effect as evalConstraint() used with five arguments, but saves the overhead of accessing the variable argument list. Also, it will call a compiled constraint function rather than evalConstraint() if possible. Definition at line 1188 of file eval.c. References CDG_HOOK, CDG_WARNING, cdgExecHook(), cdgPrintf(), ConstraintNet, ConstraintNetStruct::evalBinary, evalCurrentConstraint, evalEvaluationMethod, evalFormula(), evalTerm(), hkVerbosity, HOOK_EVAL, NULL, and TRUE. Referenced by cvAnalyse(), and evalBinary(). |
|
Evaluate a constraint w.r.t. the specified LVs. Here's the detailed algorithm:
The net is actually only used to record statistics (the fields evalUnary and evalBinary) and can be NULL. The context may be NULL. If it is not NULL it should be a Vector of LVs, each of which must be located at its index as calculated by lvIndex(). This is then passed on to predicates and functions that need to examine the context of an LV to operate. If the constraint c uses such a function or predicate (that is, if it has its is_context_sensitive flag set) and there is no context, then evalConstraint() returns TRUE. This is obviously not always correct, so if you do not provide context to your evaluations and still use context-sensitive constraints, you can miss some conflicts. This function can evaluate constraints of arbitrary arity. The number of LVs passed must equal the arity. Unary and binary constraints can also be evaluated by evalUnaryConstraint() and evalBinaryConstraint(). Those functions are slightly faster than using the general vararg mechanism. Definition at line 1040 of file eval.c. References CDG_HOOK, CDG_WARNING, cdgExecHook(), cdgPrintf(), ConstraintNet, ConstraintNetStruct::evalBinary, evalCurrentConstraint, evalFormula(), evalTerm(), ConstraintNetStruct::evalUnary, FALSE, hkVerbosity, HOOK_EVAL, NULL, and TRUE. |
|
finalize the eval module Definition at line 1666 of file eval.c. References cdgFreeString(), static_string_chunk_end, static_string_chunk_start, static_string_chunk_type, static_string_from, static_string_id, static_string_info, static_string_to, and static_string_word. Referenced by cdgFinalize(). |
|
Evaluate a formula. This function interprets the Boolean formulas defined in the cdg input language. It is basically a comprehensive listing of actions for each possible value of f->type. Each of the different types of formula is evaluated in the expected way. In particular, conjunctions, implications and disjunction are guaranteed to short-circuit in the same way as the corresponding C operators. Binary relations (FTEqual etc.) are evaluated by calling evalTerm() on both halves of the formula. If the two resulting types are not compatible, FALSE is returned with a warning. In general, every type is only compatible with itself. The ErrorValue is not compatible with any type, not even with itself. The various relations are defined as follows:
If f->type is FTConnexion, subsumesConnexion() is called to check whether the specification f->data.connexion.c subsumes the actual configuration of the LVs found in the fields f->data.connexion.var1->levelvalue and f->data.connexion.var2->levelvalue. If f=>type is FTDirection, subsumesDirection() is called to check whether the specification f->data.direction.d subsumes the Direction of the LevelValue structure found in the field f->data.direction.var->levelvalue. Definition at line 434 of file eval.c. References CDG_WARNING, cdgPrintf(), evalCurrentFormula, evalTerm(), FALSE, LexemNode, NULL, and TRUE. Referenced by evalBinaryConstraint(), evalConstraint(), and evalUnaryConstraint(). |
|
Eval context-sensitive constraints only. This function evaluates all LVs in the Vector LVs against each other, using only context-sensitive constraints, and assuming that the context is context. This is useful for methods that cannot normally provide context, e.g. because they operate incrementally. Such methods should use normal evalUnary and evalBinary calls with no context while they are building a structure, and then this function once the structure is complete. Note that LVs and context can be different; one frobbing method actually needs to eval a subset of a structure, but in the global context. Definition at line 1614 of file eval.c. References Badness, evalBinary(), evalUnary(), NULL, and TRUE. |
|
Initialize the eval module Definition at line 1642 of file eval.c. References evalEvaluationMethod, evalPeekValueMethod, evalSloppySubsumesWarnings, evalValidateEvalMethod(), FALSE, NULL, static_string_chunk_end, static_string_chunk_start, static_string_chunk_type, static_string_from, static_string_id, static_string_info, static_string_to, static_string_word, and TRUE. Referenced by cdgInitialize(). |
|
evaluate a CDG Term.
t->type:
References GraphemNodeStruct::arc, LexemNodeStruct::arc, CDG_WARNING, cdgPrintf(), GraphemNodeStruct::chunk, Chunk, chunkerStringOfChunkType(), evalPeekValueMethod, FALSE, ChunkStruct::from, LexemNodeStruct::grapheme, LexemNodeStruct::lexem, LexemNode, LexemGraphStruct::max, peekValue(), static_string_chunk_end, static_string_chunk_start, static_string_chunk_type, static_string_from, static_string_id, static_string_info, static_string_to, static_string_word, and ChunkStruct::to. Referenced by evalBinaryConstraint(), evalConstraint(), evalFormula(), and evalUnaryConstraint(). |
|
Eval unary constraints on LV. This function applies all unary constraints to lv. It uses the Vector cdgConstraintVector in much the same way as evalBinary() uses cdgConstraintMatrix. The same exceptions for deactivated constraints apply as in that function. In addition, evalUnary() stores all violated local constraints in the List lv->constraints. Definition at line 1259 of file eval.c. References bAdd(), Badness, CDG_DEBUG, cdgPrintf(), ConstraintNet, cvNew(), evalUnaryConstraint(), and NULL. Referenced by cnBuildLv(), and evalInContext(). |
|
Evaluate a unary constraint on LV. This function evaluates a unary constraint. It has the same effect as evalConstraint() used with four arguments, but saves the overhead of accessing the variable argument list. Also, it will call a compiled constraint function rather than evalConstraint() if possible. Definition at line 1122 of file eval.c. References CDG_HOOK, CDG_WARNING, cdgExecHook(), cdgPrintf(), ConstraintNet, evalCurrentConstraint, evalEvaluationMethod, evalFormula(), evalTerm(), ConstraintNetStruct::evalUnary, hkVerbosity, HOOK_EVAL, NULL, and TRUE. Referenced by evalUnary(). |
|
This is the validation function for the CDG variable evalmethod. Definition at line 1681 of file eval.c. References CDG_WARNING, cdgPrintf(), FALSE, and TRUE. Referenced by evalInitialize(). |
|
Declare evaluation lock. When many constraints are evaluated on the same dependency tree, it can be worthwhile to cache the result of common subformulas. Therefore we offer the caller the possibility to declare that the dependency tree will not change during the next evaluations. The module eval is then free to reuse the results of previous evaluations until the tree is unlocked again. WIDTH specifies the number of time points in the lexeme graph that will be used in the evaluations. Definition at line 157 of file eval.c. References has_cache, lock_counter, and lock_width. Referenced by evalBinary(). |
|
returns value for a path in a feature matrix Definition at line 611 of file eval.c. References CDG_WARNING, cdgPrintf(), and NULL. Referenced by evalTerm(). |
|
Compare Numbers with some margin for rounding error. Upon removing conflicts and introducing new ones, the score of a structure must frequently be multiplied and divided with constants. Repeated use of this practice may introduce rounding errors. Therefore we use a special function for comparison with some margin for error. The problem of distinguishing rounding errors from very subtle penalties remains unsolved. Definition at line 206 of file eval.c. Referenced by bCompare(). |
|
Release evaluation lock. If lock_tree() was called multiple times, evaluation remains locked onto the current tree until each call been cancelled individually. Definition at line 178 of file eval.c. References CDG_ERROR, cdgPrintf(), has_cache, lock_counter, lock_width, and NULL. Referenced by evalBinary(). |
|
Return new Badness worse than any other. Strictly speaking, this is not the worst Badness that any structure could ever have, but I guess it will do. The result is owned by the caller. Definition at line 383 of file eval.c. |
|
This variable is set to the current Constraint during an evaluation, NULL otherwise. Definition at line 80 of file eval.c. Referenced by evalBinaryConstraint(), evalConstraint(), and evalUnaryConstraint(). |
|
This variable is set to the current Constraint during an evaluation, NULL otherwise. Definition at line 80 of file eval.c. Referenced by evalBinaryConstraint(), evalConstraint(), and evalUnaryConstraint(). |
|
Set to the current Formula during an evaluation, NULL otherwise. Actually this is not strictly true. During evaluation, it is set to the formula whose evaluation was most recently *begun*, which is not at all the same; if we evaluate the formula X@cat = N & X^cat != V Referenced by evalFormula(). |
|
Set to the current Formula during an evaluation, NULL otherwise. Actually this is not strictly true. During evaluation, it is set to the formula whose evaluation was most recently *begun*, which is not at all the same; if we evaluate the formula X@cat = N & X^cat != V Referenced by evalFormula(). |
|
Implements evalmethod. Definition at line 116 of file eval.c. Referenced by cmdCompile(), cmdLoad(), cmdStatus(), comApprove(), comCompareAllLvPairs(), comCompareWithContext(), evalBinaryConstraint(), evalInitialize(), and evalUnaryConstraint(). |
|
Implements evalmethod. Definition at line 116 of file eval.c. Referenced by cmdCompile(), cmdLoad(), cmdStatus(), comApprove(), comCompareAllLvPairs(), comCompareWithContext(), evalBinaryConstraint(), evalInitialize(), and evalUnaryConstraint(). |
|
Implements peekvaluemethod. Definition at line 119 of file eval.c. Referenced by cmdStatus(), evalInitialize(), and evalTerm(). |
|
Implements peekvaluemethod. Definition at line 119 of file eval.c. Referenced by cmdStatus(), evalInitialize(), and evalTerm(). |
|
Implements subsumesWarnings. If a constraint evaluation tries to access lexical information of the root node, the corresponding subexpression unconditionally evaluates to FALSE, and a warning is printed. This flag can be used to turn off the warnings; however the interpretation of the erroneous expression as FALSE remains. It is therefore recommended that you write all constraints so that they will not access features of the root node in the first place. Definition at line 113 of file eval.c. Referenced by cmdStatus(), and evalInitialize(). |
|
Implements subsumesWarnings. If a constraint evaluation tries to access lexical information of the root node, the corresponding subexpression unconditionally evaluates to FALSE, and a warning is printed. This flag can be used to turn off the warnings; however the interpretation of the erroneous expression as FALSE remains. It is therefore recommended that you write all constraints so that they will not access features of the root node in the first place. Definition at line 113 of file eval.c. Referenced by cmdStatus(), and evalInitialize(). |
|
At the moment, only the results of identical has() applications are cached because those are expected to be particularly expensive. In principle, this method could be extended to arbitrary identical subformulas. The result of the application of has() number X at time point T is stored in cell X * lock_width + T. 2 means TRUE, 1 means FALSE, and 0 `unknown'. Definition at line 142 of file eval.c. Referenced by lock_tree(), and unlock_tree(). |
|
At the moment, only the results of identical has() applications are cached because those are expected to be particularly expensive. In principle, this method could be extended to arbitrary identical subformulas. The result of the application of has() number X at time point T is stored in cell X * lock_width + T. 2 means TRUE, 1 means FALSE, and 0 `unknown'. Definition at line 142 of file eval.c. Referenced by lock_tree(), and unlock_tree(). |
|
Notes whether evaluation is locked. Since locks can be nested, this counter can rise above 1; any value higher than 0 means that cached results are still valid. Definition at line 126 of file eval.c. Referenced by lock_tree(), and unlock_tree(). |
|
Notes whether evaluation is locked. Since locks can be nested, this counter can rise above 1; any value higher than 0 means that cached results are still valid. Definition at line 126 of file eval.c. Referenced by lock_tree(), and unlock_tree(). |
|
The number of time points in the lexeme graph that will be used in the evaluations Definition at line 131 of file eval.c. Referenced by lock_tree(), and unlock_tree(). |
|
The number of time points in the lexeme graph that will be used in the evaluations Definition at line 131 of file eval.c. Referenced by lock_tree(), and unlock_tree(). |
|
static string "chunk_end" Definition at line 74 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "chunk_end" Definition at line 74 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "chunk_start" Definition at line 73 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "chunk_start" Definition at line 73 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "chunk_type" Definition at line 75 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "chunk_type" Definition at line 75 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "from" Definition at line 70 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "from" Definition at line 70 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "id" Definition at line 68 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "id" Definition at line 68 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "info" Definition at line 72 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "info" Definition at line 72 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "to" Definition at line 71 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "to" Definition at line 71 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "word" Definition at line 69 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |
|
static string "word" Definition at line 69 of file eval.c. Referenced by evalFinalize(), evalInitialize(), and evalTerm(). |