Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

Constraintnet - maintainance of constraint nets


Detailed Description

Author:
Ingo Schroeder
Date:
6/3/97


Data Structures

struct  ConstraintEdgeStruct
struct  ConstraintNetStruct
struct  ConstraintNodeStruct
struct  ConstraintViolationStruct
struct  NodeBindingStruct

Typedefs

typedef ConstraintEdgeStructConstraintEdge
typedef ConstraintEdgeStruct ConstraintEdgeStruct
typedef ConstraintNetStructConstraintNet
typedef ConstraintNodeStructConstraintNode
typedef ConstraintViolationStructConstraintViolation
typedef NodeBindingStructNodeBinding

Enumerations

enum  CnEdgesType { cnEdgesOn, cnEdgesOff, cnEdgesFew, cnEdgesAll }

Functions

ConstraintNet cnBuild (Lattice lat, Boolean buildLVs)
void cnBuildEdges (ConstraintNet net)
ConstraintNet cnBuildFinal (ConstraintNet net, Boolean buildLVs)
ConstraintNet cnBuildInit ()
Boolean cnBuildIter (ConstraintNet net, GraphemNode gn, Boolean buildLVs)
void cnBuildLevelValues (ConstraintNode node, Level level, GraphemNode modifier, GraphemNode modifiee)
void cnBuildLv (ConstraintNode node, List modifiers, Level level, String label, List modifiees)
Boolean cnBuildNodes (ConstraintNet net, Boolean buildLVs)
Boolean cnBuildTriple (ConstraintNet net, int a, int b, int levelno)
Boolean cnBuildUpdateArcs (ConstraintNet net, List listArcs)
void cnCallback (String name, float *var)
Boolean cnCompareViolation (ConstraintViolation a, ConstraintViolation b)
Boolean cnConnectedByArc (ConstraintNode a, ConstraintNode b)
void cnDelete (ConstraintNet net)
void cnDeleteAllLVs (ConstraintNet net)
void cnDeleteBinding (NodeBinding nb)
void cnDeleteEdge (ConstraintEdge edge)
void cnDeleteNode (ConstraintNode node)
ConstraintNet cnFindNet (String id)
ConstraintNode cnFindNode (ConstraintNet net, LevelValue lv)
GraphemNode cnGetGraphemNodeFromArc (ConstraintNet net, Arc arc)
Lattice cnGetLattice (ConstraintNet cn)
void cnInitialize ()
Boolean cnIsEndNode (ConstraintNode n)
Boolean cnIsStartNode (ConstraintNode n)
Boolean cnNodeComparePrio (ConstraintNode a, ConstraintNode b)
Boolean cnNodeCompareSmallest (ConstraintNode a, ConstraintNode b)
int cnOptimizeNet (ConstraintNet net)
int cnOptimizeNode (ConstraintNet net, ConstraintNode node)
void cnPrint (long unsigned int mode, ConstraintNet net)
void cnPrintActiveLVs (ConstraintNet net)
void cnPrintEdge (long unsigned int mode, ConstraintEdge e)
void cnPrintInfo (ConstraintNet net)
void cnPrintNode (long unsigned int mode, ConstraintNode cn)
void cnPrintParses (ConstraintNet net)
Boolean cnRenew (ConstraintNet net)
void cnSortLVs (ConstraintNet net)
void cnSortNodes (ConstraintNet net)
Boolean cnTag (ConstraintNet net, Lattice lat)
void cnUnaryPruning (ConstraintNode node)
Boolean cnUnaryPruningCompare (LevelValue a, LevelValue b)
void cnUndeleteAllLVs (ConstraintNet net)
int countValidValues (ConstraintNet net)
void cvAnalyse (ConstraintViolation cv, Vector context)
ConstraintViolation cvClone (ConstraintViolation cv)
Boolean cvCompare (ConstraintViolation a, ConstraintViolation b)
Boolean cvCompareNatural (ConstraintViolation a, ConstraintViolation b)
Boolean cvContains (List conflicts, ConstraintViolation cv)
void cvDelete (ConstraintViolation cv)
ConstraintViolation cvNew (Constraint c, LevelValue lva, LevelValue lvb)
void cvPrint (unsigned long mode, ConstraintViolation cv)

Variables

int cnCounter
int cnCounter = 0
CnEdgesType cnEdgesFlag
CnEdgesType cnEdgesFlag = cnEdgesOff
ConstraintNet cnMostRecentlyCreatedNet
ConstraintNet cnMostRecentlyCreatedNet = NULL
Boolean cnShowDeletedFlag
Boolean cnShowDeletedFlag = FALSE
int cnSortNodesMethod
int cnSortNodesMethod = 0
Number cnUnaryPruningFraction
Number cnUnaryPruningFraction = 1.0
Boolean cnUseNonSpec
Boolean cnUseNonSpec = FALSE


Typedef Documentation

typedef ConstraintEdgeStruct* ConstraintEdge
 

Pointer to the ConstraintEdgeStruct Definition at line 125 of file constraintnet.h.

Referenced by cmdEdges(), cnBuildEdges(), cnDelete(), cnDeleteEdge(), and cnPrintEdge().

typedef struct ConstraintEdgeStruct ConstraintEdgeStruct
 

Models an edge between the two constraint nodes start and stop. These two fields are shallow copies of the nodes in the corresponding constraint net.

typedef ConstraintNetStruct* ConstraintNet
 

Pointer to the ConstraintNetStruct Definition at line 74 of file constraintnet.h.

Referenced by cdgDeleteComputed(), cmdDistance(), cmdEdges(), cmdISearch(), cmdNet(), cmdNetdelete(), cmdNetsearch(), cmdNewnet(), cmdPrintParses(), cmdRenewnet(), cmdWriteAnno(), cmdWriteNet(), cmdWriteParses(), cnBuild(), cnBuildEdges(), cnBuildFinal(), cnBuildInit(), cnBuildIter(), cnBuildLevelValues(), cnBuildLv(), cnBuildNodes(), cnBuildTriple(), cnBuildUpdateArcs(), cnDelete(), cnDeleteAllLVs(), cnFindNet(), cnFindNode(), cnGetGraphemNodeFromArc(), cnGetLattice(), cnOptimizeNet(), cnOptimizeNode(), cnPrint(), cnPrintActiveLVs(), cnPrintInfo(), cnPrintParses(), cnRenew(), cnSortLVs(), cnSortNodes(), cnTag(), cnUndeleteAllLVs(), comApprove(), comCompareAllLvPairs(), comCompareAllLvs(), comCompareNets(), comCompareWithContext(), comFindComparableLv(), countValidValues(), evalBinary(), evalBinaryConstraint(), evalConstraint(), evalUnary(), and evalUnaryConstraint().

typedef ConstraintNodeStruct* ConstraintNode
 

Pointer to the ConstraintNodeStruct Definition at line 99 of file constraintnet.h.

Referenced by cmdEdges(), cnBuildEdges(), cnBuildFinal(), cnBuildIter(), cnBuildLevelValues(), cnBuildLv(), cnBuildTriple(), cnBuildUpdateArcs(), cnConnectedByArc(), cnDelete(), cnDeleteNode(), cnFindNode(), cnIsEndNode(), cnIsStartNode(), cnNodeComparePrio(), cnNodeCompareSmallest(), cnOptimizeNet(), cnOptimizeNode(), cnPrint(), cnPrintActiveLVs(), cnPrintInfo(), cnPrintNode(), cnRenew(), cnSortLVs(), cnSortNodes(), cnUnaryPruning(), and comCompareNets().

typedef ConstraintViolationStruct* ConstraintViolation
 

Pointer to the ConstraintViolationStruct Definition at line 165 of file constraintnet.h.

Referenced by cnCompareViolation(), comCompareAllLvPairs(), comCompareWithContext(), cvAnalyse(), cvClone(), cvCompare(), cvCompareNatural(), cvContains(), cvDelete(), cvNew(), and cvPrint().

typedef NodeBindingStruct* NodeBinding
 

Pointer to the NodeBindingStruct Definition at line 138 of file constraintnet.h.

Referenced by cnDeleteBinding().


Enumeration Type Documentation

enum CnEdgesType
 

The types of a constraintnet edge Definition at line 33 of file constraintnet.h.

Referenced by cmdIncrementalCompletion().


Function Documentation

ConstraintNet cnBuild Lattice  lat,
Boolean  buildLVs
 

Build a constraint net from LAT.

This function returns a new constraint net for a word graph. This function uses cnBuildInit(), cnBuildNodes(), and cnBuildFinal(). The resulting net contains no edges. The function performs these initializations:

  • id is set to net<cnCounter>
  • the lexemgraph is built
  • state is set to NSCreated

If BUILDLVS is set, the nodes in the constraint net will be filled with LVs, otherwise the net will contain only constraint nodes, no LVs. Definition at line 250 of file constraintnet.c.

References CDG_WARNING, cdgCtrlCTrapped, cdgPrintf(), cnBuildFinal(), cnBuildInit(), cnBuildNodes(), cnDelete(), cnMostRecentlyCreatedNet, cnTag(), ConstraintNet, and NULL.

Referenced by cmdNewnet(), and comApprove().

void cnBuildEdges ConstraintNet  net  ) 
 

builds edges in a constraint net

This function computes all edges in a constraint net:

  • The Vector edges is allocated.
  • A constraint edge is built for every pair of constraint nodes and inserted into edges.
  • The fields isMarked and scores are allocated for each edge.
  • All pairs of LVs from the two constraint nodes are evaluated jointly and the result is store in the matrix scores. The result will be~0 if the LVs are no lvCompatible(), otherwise it is the product of the combined binary score and the two unary scores.
  • A mapping from all edges to their reverses is computed and stored in the field reverse.

C-c interrupts this function, deletes all partial results, and displays the total time elapsed as a CDG_PROFILE message. Definition at line 1328 of file constraintnet.c.

References CDG_DEBUG, CDG_PROFILE, cdgCtrlCTrapped, cdgFlush(), cdgPrintf(), cdgXCDG, cnConnectedByArc(), cnEdgesFlag, ConstraintEdge, ConstraintNet, ConstraintNode, ConstraintNetStruct::edges, evalBinary(), FALSE, ConstraintEdgeStruct::isMarked, ConstraintNodeStruct::level, ConstraintNetStruct::lexemgraph, ConstraintNetStruct::nodes, LexemGraphStruct::nodes, NULL, ConstraintEdgeStruct::reverse, ConstraintEdgeStruct::scores, smDelete(), smNew(), smSetFlag(), smSetScore(), ConstraintEdgeStruct::start, ConstraintEdgeStruct::stop, Timer, timerElapsed(), timerFree(), timerNew(), TRUE, and ConstraintNodeStruct::values.

Referenced by cnBuildFinal().

ConstraintNet cnBuildFinal ConstraintNet  net,
Boolean  buildLVs
 

Final improvements: optimize, sort, unary pruning, score cache and edges

This function performs various clean-up operations on a net for which all constraint nodes have been built:

  • It removes unnecessary structures from the net using cnOptimizeNet().
  • If cnSortNodes is set, it sorts the constraint nodes using cnSortNodes().
  • It applies cnUnaryPruning() to each constraint node.
  • If scUseCache is set, it initializes net->cache to a new cache returned by scNew().
  • If cnEdgesFlag is not cnEdgesOff, it applies cnBuildEdges() to build the edges of the constraint net.

The function returns FALSE iff any of the subsidiary functions returned FALSE. Definition at line 163 of file constraintnet.c.

References ConstraintNetStruct::cache, CDG_WARNING, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), cnBuildEdges(), cnDelete(), cnEdgesFlag, cnOptimizeNet(), cnSortLVs(), cnSortNodes(), cnSortNodesMethod, cnUnaryPruning(), cnUseNonSpec, ConstraintNet, ConstraintNode, ConstraintNetStruct::edges, FALSE, ConstraintNetStruct::isBuilt, ConstraintNetStruct::lexemgraph, LexemGraphStruct::max, max, LexemGraphStruct::min, ConstraintNetStruct::nodes, NULL, scNew(), scUseCache, and ConstraintNetStruct::values.

Referenced by cnBuild().

ConstraintNet cnBuildInit  ) 
 

This function returns a new ConstraintNet with a unique name, but with all fields set to meaningless default values. Building a complete constraint net is a multi-stage process that involves several of the other functions of this module. Definition at line 85 of file constraintnet.c.

References ConstraintNetStruct::cache, cnCounter, ConstraintNet, ConstraintNetStruct::edges, ConstraintNetStruct::evalBinary, ConstraintNetStruct::evalUnary, ConstraintNetStruct::id, ConstraintNetStruct::isBuilt, ConstraintNetStruct::lvTotals, ConstraintNetStruct::nodes, NULL, ConstraintNetStruct::parses, ConstraintNetStruct::searchagenda, ConstraintNetStruct::statUnary, ConstraintNetStruct::totalNumberOfValues, and ConstraintNetStruct::values.

Referenced by cnBuild().

Boolean cnBuildIter ConstraintNet  net,
GraphemNode  gn,
Boolean  buildLVs
 

Builds the constraint node corresponding to GN in NET.

This function really performs most of the work that was documented under cnBuildNodes() for simplicity. Definition at line 781 of file constraintnet.c.

References cdgCtrlCTrapped, cdgFlush(), cnBuildLevelValues(), cnDeleteNode(), cnUseNonSpec, ConstraintNet, ConstraintNode, FALSE, ConstraintNodeStruct::gn, GraphemNode, LexemGraphStruct::graphemnodes, ConstraintNodeStruct::level, GraphemNodeStruct::lexemes, ConstraintNetStruct::lexemgraph, lgAreDeletedNodes(), ConstraintNodeStruct::net, ConstraintNetStruct::nodes, LexemGraphStruct::nodes, ConstraintNodeStruct::noValidValues, NULL, ConstraintNodeStruct::totalNumberOfValues, TRUE, and ConstraintNodeStruct::values.

Referenced by cnBuildNodes(), and cnBuildUpdateArcs().

void cnBuildLevelValues ConstraintNode  node,
Level  level,
GraphemNode  modifier,
GraphemNode  modifiee
 

Builds all level values for LEVEL, MODIFIER and MODIFIEE.

This function builds all LVs that represent tuples composed from the parameters it receives. This function is used as the innermost loop by cnBuildIter(). Definition at line 652 of file constraintnet.c.

References GraphemNodeStruct::arc, cnBuildLv(), ConstraintNet, ConstraintNode, GraphemNode, ConstraintNetStruct::lexemgraph, lgMayModify(), lgPartitions(), ConstraintNodeStruct::net, and NULL.

Referenced by cnBuildIter(), cnBuildTriple(), and cnBuildUpdateArcs().

void cnBuildLv ConstraintNode  node,
List  modifiers,
Level  level,
String  label,
List  modifiees
 

Build a new levelvalue in NODE.

This function creates exactly one LV with the specified fields using lvNew() and stores it in node, incrementing all relevant counters properly. Definition at line 613 of file constraintnet.c.

References CDG_DEBUG, cdgPrintf(), ConstraintNet, ConstraintNode, evalUnary(), FALSE, ConstraintNodeStruct::net, NULL, ConstraintNodeStruct::totalNumberOfValues, ConstraintNetStruct::totalNumberOfValues, ConstraintNetStruct::values, and ConstraintNodeStruct::values.

Referenced by cnBuildLevelValues().

Boolean cnBuildNodes ConstraintNet  net,
Boolean  buildLVs
 

Builds the constraint nodes of NET. If BUILDLVS is set, the nodes are immediately filled with all possible LVs, otherwise they remain empty.

Returns FALSE if the constraintnet is invalid.

Basically it performs the following steps:

  • allocates the Vectors nodes and values
  • partitions the set of lexeme nodes created from each word hypothesis according to each level by using lgPartitions()
  • allocates a ConstraintNode for each of the partitions k and inserts it into the Vector nodes
  • checks whether the subordination (k, l, m) is possible for each triples of modifier set, label and modifiee set, and constructs the corresponding LV
  • checks whether the subordination (k, l, NIL) is possible for each pair of modifier set and label, and constructs the corresponding LV
  • inserts all new LVs into the respective constraint nodes and the Vector values
  • sorts the LVs in each constraint node by their limit.

However, some complications apply:

  • Under CDG_DEBUG, each word in the word graph is printed as it is used to build LVs.
  • If a level has its useflag reset, it is ignored completely.
  • Some of the LVs created may be destroyed again by cnUnaryPruning() if the variable cnUnaryPruningFraction is smaller than~1. Such LVs are not stored in the constraint node nor in the constraint net.
  • Each iteration executes the hook HOOK_CNBUILDNODES.
  • If cnSortNodes is set, cnSortNodes() is called after building all nodes.
  • If scUseCache is set, a new cache is allocated for the constraint net.
  • The time elapsed is printed as a CDG_PROFILE message.
  • This function is interruptible by C-c in much the same way as cnBuildEdges().
Definition at line 895 of file constraintnet.c.

References CDG_DEBUG, CDG_HOOK, CDG_PROFILE, cdgExecHook(), cdgPrintf(), cnBuildIter(), ConstraintNet, GraphemNode, LexemGraphStruct::graphemnodes, hkVerbosity, HOOK_CNBUILDNODES, ConstraintNetStruct::isBuilt, GraphemNodeStruct::lexemes, ConstraintNetStruct::lexemgraph, LexemNode, LexemGraphStruct::max, ConstraintNetStruct::nodes, LexemGraphStruct::nodes, NULL, Timer, timerElapsed(), timerFree(), timerNew(), TRUE, and ConstraintNetStruct::values.

Referenced by cnBuild().

Boolean cnBuildTriple ConstraintNet  net,
int  a,
int  b,
int  levelno
 

Build all LVs on LEVEL for the pair of time points (A,B) in NET.

All LVs that connect a word that starts at time point A as a modifier to a word that starts at time point B are built and inserted into the constraint net at the appropriate places. B == -1 means NIL, B == -2 means NONSPEC.

Returns FALSE if such LVs have already been built.

This function has nothing to do with incremental processing. It is intended for use by parsing algorithms that do not want the entire set of LVs built before they can start working, although the entire input is known. Definition at line 718 of file constraintnet.c.

References GraphemNodeStruct::arc, cnBuildLevelValues(), ConstraintNet, ConstraintNode, FALSE, ConstraintNodeStruct::gn, GraphemNode, LexemGraphStruct::graphemnodes, ConstraintNetStruct::isBuilt, ConstraintNodeStruct::level, ConstraintNetStruct::lexemgraph, LexemGraphStruct::max, ConstraintNetStruct::nodes, ConstraintNodeStruct::noValidValues, NULL, ConstraintNodeStruct::totalNumberOfValues, TRUE, and ConstraintNodeStruct::values.

Boolean cnBuildUpdateArcs ConstraintNet  net,
List  listArcs
 

Update NET with the arcs in LISTARCS.

This function is used by incrementalcompletion to extend an existing constraint net by the structures corresponding to the specified Arc structures. Definition at line 2100 of file constraintnet.c.

References CDG_DEBUG, cdgPrintf(), cnBuildIter(), cnBuildLevelValues(), cnGetGraphemNodeFromArc(), cnPrintNode(), ConstraintNet, ConstraintNode, FALSE, ConstraintNodeStruct::gn, GraphemNode, ConstraintNodeStruct::level, GraphemNodeStruct::lexemes, ConstraintNetStruct::nodes, ConstraintNodeStruct::noValidValues, NULL, ConstraintNodeStruct::totalNumberOfValues, TRUE, and ConstraintNodeStruct::values.

void cnCallback String  name,
float *  var
 

Callback function for cnUnaryPruningFraction.

This function is used as the callback function for the CDG variable unaryFraction. It prints a notification of the change to the CDG shell. Definition at line 2171 of file constraintnet.c.

References CDG_INFO, and cdgPrintf().

Referenced by cnInitialize().

Boolean cnCompareViolation ConstraintViolation  a,
ConstraintViolation  b
 

compares two violations by penalty, then by domain index This function compares two structures of type ConstraintViolation, comparing first the penalty of the violation, after that the fields nodeBindingIndex1 and nodeBindingIndex2 and finally the names of the constraints.

TODO: this function is never used, see cvCompare for a similar function Definition at line 1830 of file constraintnet.c.

References ConstraintViolationStruct::constraint, ConstraintViolation, FALSE, ConstraintViolationStruct::nodeBindingIndex1, ConstraintViolationStruct::nodeBindingIndex2, ConstraintViolationStruct::penalty, and TRUE.

Boolean cnConnectedByArc ConstraintNode  a,
ConstraintNode  b
 

Are two constraint nodes connected by an arc? This function checks whether two constraint nodes should be connected by an edge or not. This check is always performed before allocating a constraint edge. Two nodes fail this test if they bind the same lexeme and belong to the same level.

Think it over which nodes are connected by an arc. Do we need arcs in both directions?

return ((a->lexemnode == b->lexemnode && a->level != b->level) || (a->level == b->level && lgDistanceOfNodes (a->lexemnode->lexemgraph, a->lexemnode, b->lexemnode) != 0 ) ); Definition at line 1216 of file constraintnet.c.

References ConstraintNode, ConstraintNodeStruct::gn, and ConstraintNodeStruct::level.

Referenced by cnBuildEdges().

void cnDelete ConstraintNet  net  ) 
 

deletes constraint net

This function deallocates an entire constraint net. Note that while cnBuild() only allocates a few fields, this function allocates everything. The following functions are used for the purpose:

If net is identical to cnMostRecentlyCreatedNet, that variable is reset. Definition at line 1640 of file constraintnet.c.

References ConstraintNetStruct::cache, CDG_WARNING, cdgFreeString(), cdgPrintf(), cnDeleteEdge(), cnDeleteNode(), cnMostRecentlyCreatedNet, ConstraintEdge, ConstraintNet, ConstraintNode, ConstraintNetStruct::edges, ConstraintNetStruct::id, ConstraintNetStruct::lexemgraph, lgDelete(), ConstraintNetStruct::lvTotals, ConstraintNetStruct::nodes, NULL, ConstraintNetStruct::parses, scDelete(), ConstraintNetStruct::searchagenda, and ConstraintNetStruct::values.

Referenced by cdgDeleteComputed(), cmdNetdelete(), cnBuild(), cnBuildFinal(), cnTag(), and comApprove().

void cnDeleteAllLVs ConstraintNet  net  ) 
 

delete all levelvalues in a constraint net

This function sets the field isDeleted for all LVs in the specified constraint net. Definition at line 2083 of file constraintnet.c.

References ConstraintNet, TRUE, and ConstraintNetStruct::values.

void cnDeleteBinding NodeBinding  nb  ) 
 

cnDeleteBinding

This function deallocates NodeBinding structure. Both components of the pair are shallow copies and cannot be deallocated. Definition at line 1484 of file constraintnet.c.

References NodeBinding.

void cnDeleteEdge ConstraintEdge  cn  ) 
 

deletes a constraint-edge

This function deallocates a constraint edge. Apart from the ConstraintEdgeStruct itself, only the field scores is deallocated by calling smDelete(). Definition at line 1615 of file constraintnet.c.

References ConstraintEdge, ConstraintEdgeStruct::isMarked, ConstraintEdgeStruct::scores, and smDelete().

Referenced by cnDelete().

void cnDeleteNode ConstraintNode  cn  ) 
 

deletes a constraint-node

This function deallocates a single constraint node and all LVs contained in it. Note that pointers to these LVs may remain in the field values of the enclosing constraint net, so cnDeleteNode() should only be called immediately before deleting the net itself. Definition at line 1593 of file constraintnet.c.

References ConstraintNode, and ConstraintNodeStruct::values.

Referenced by cnBuildIter(), and cnDelete().

ConstraintNet cnFindNet String  id  ) 
 

Looks for a constraint net with id ID and return it or NULL if it can't find the net in inputCurrentGrammar.

Returns:
the net with the specified id in the inputCurrentGrammar structure, or NULL.
Definition at line 2031 of file constraintnet.c.

References cdgNets, and ConstraintNet.

Referenced by cmdDistance(), cmdPrintParses(), cmdRenewnet(), and cmdWriteParses().

ConstraintNode cnFindNode ConstraintNet  net,
LevelValue  lv
 

Find ConstraintNode of an LV. This finds LVs by comparing their IWRT numbers, so cannot give meaningful results if lv was not originally built for net.

Returns:
the constraint node in net that holds lv (or NULL).
Definition at line 1881 of file constraintnet.c.

References CDG_WARNING, cdgPrintf(), ConstraintNet, ConstraintNode, ConstraintNetStruct::nodes, NULL, and ConstraintNodeStruct::values.

GraphemNode cnGetGraphemNodeFromArc ConstraintNet  net,
Arc  arc
 

Return the graphem node in NET that points to ARC. Definition at line 2149 of file constraintnet.c.

References GraphemNodeStruct::arc, ConstraintNet, GraphemNode, LexemGraphStruct::graphemnodes, ConstraintNetStruct::lexemgraph, and NULL.

Referenced by cnBuildUpdateArcs().

Lattice cnGetLattice ConstraintNet  cn  ) 
 

Needed by XCDG because it can't talk to LexemGraphs directly.

This function simply returns cn->lexemgraph->lattice. It exists because XCDG needs that field, and XCDG cannot talk directly to lexeme graphs (they contain arrays of long long ints, which SWIG doesn't handle correctly). Definition at line 2204 of file constraintnet.c.

References ConstraintNet, LexemGraphStruct::lattice, and ConstraintNetStruct::lexemgraph.

void cnInitialize  ) 
 

Initialize the module constraintnet.

This function initializes the module Constraintnet - maintainance of constraint nets. It merely registers the module's CDG variables. Definition at line 2185 of file constraintnet.c.

References cnCallback(), cnEdgesFlag, cnShowDeletedFlag, cnSortNodesMethod, cnUnaryPruningFraction, cnUseNonSpec, and NULL.

Referenced by cdgInitialize().

Boolean cnIsEndNode ConstraintNode  n  ) 
 

Does this node bind the latest lexeme in the lattice? The functions lgIsStartNode() and lgIsEndNode() are used for this purpose. Definition at line 1471 of file constraintnet.c.

References ConstraintNode, ConstraintNodeStruct::gn, ConstraintNodeStruct::level, and lgIsEndNode().

Boolean cnIsStartNode ConstraintNode  n  ) 
 

Does this node bind the earliest lexeme in the lattice? The functions lgIsStartNode() and lgIsEndNode() are used for this purpose. Definition at line 1459 of file constraintnet.c.

References ConstraintNode, ConstraintNodeStruct::gn, ConstraintNodeStruct::level, and lgIsStartNode().

Boolean cnNodeComparePrio ConstraintNode  a,
ConstraintNode  b
 

Compare constraint nodes by the ->no of their levels. Definition at line 549 of file constraintnet.c.

References ConstraintNode, and ConstraintNodeStruct::level.

Referenced by cnSortNodes().

Boolean cnNodeCompareSmallest ConstraintNode  a,
ConstraintNode  b
 

Comparison function for cnSortNodes() based on domain size.

This function is used by cnSortNodes() to compare two constraint nodes according to the value of their totalNumberOfValues= fields. It returns TRUE iff a has a lower value or the same values as b. Definition at line 562 of file constraintnet.c.

References ConstraintNode, and ConstraintNodeStruct::noValidValues.

Referenced by cnSortNodes().

int cnOptimizeNet ConstraintNet  net  ) 
 

optimize constraint net by deleting lexemes and values

This function deletes lexeme nodes and LVs from a constraint net that cannot possibly appear in any solution. It uses several rules for deleting structures:

  • An LV can be deleted if it binds a set of lexeme nodes that are all deleted.
  • An LV can be deleted if is modifier and modifiee are incompatible.
  • A lexeme node can be deleted if it it cannot be bound by any LV on one level.
  • A lexeme can be deleted if there is no path through the lexeme graph in which it appears, and which is totally undeleted.

Since these conditions can trigger each other, the function cnOptimizeNode() is called repeatedly on each node in the constraint net until no progress has been made. The function returns the total number of changes returned by the calls to cnOptimizeNode(), or -1 if none of them did so.

Returns:
> 0 : we have changed the constraintnet

0 : no changes have been made

< 0 : the net is invalid

Definition at line 1168 of file constraintnet.c.

References CDG_DEBUG, cdgPrintf(), cnOptimizeNode(), ConstraintNet, ConstraintNode, countValidValues(), FALSE, ConstraintNetStruct::nodes, and TRUE.

Referenced by cnBuildFinal(), and cnRenew().

int cnOptimizeNode ConstraintNet  net,
ConstraintNode  node
 

Optimize constraint node by deleting lexemes and values.

Returns:
> 0 : we have changed the constraintnode

0 : no changes have been made

< 0 : the node is invalid

This function serves to discard structures in a constraint node that cannot appear in any solution. It returns the number of deletion operations that it has performed, or -1 if an inconsistency was found. This function is repeatedly called by cnOptimizeNet(). Definition at line 943 of file constraintnet.c.

References GraphemNodeStruct::arc, CDG_DEBUG, CDG_WARNING, cdgPrintf(), ConstraintNet, ConstraintNode, FALSE, ConstraintNodeStruct::gn, GraphemNode, ConstraintNodeStruct::level, GraphemNodeStruct::lexemes, ConstraintNetStruct::lexemgraph, LexemNode, lgAreDeletableNodes(), lgAreDeletedNodes(), lgCompatibleNodes(), lgDeleteNode(), lgDeleteNodes(), lgIsDeletedNode(), lgPrintNode(), GraphemNodeStruct::no, LexemNodeStruct::no, LexemGraphStruct::nodes, LexemGraphStruct::noOfPathsFromStart, LexemGraphStruct::noOfPathsToEnd, ConstraintNodeStruct::noValidValues, NULL, TRUE, and ConstraintNodeStruct::values.

Referenced by cnOptimizeNet().

void cnPrint long unsigned int  mode,
ConstraintNet  net
 

Print a constraint net.

This function displays a constraint net in textual form. Output is suppressed if hkVerbosity does not have the bit mode set. The function uses cnPrintNode() and lvPrint(). Constraint nodes from levels that have their showflag reset are skipped. Deleted LVs are only shown if cnShowDeletedFlag is set. Definition at line 291 of file constraintnet.c.

References cdgCtrlCTrapped, cdgPrintf(), chunkerPrintChunks(), LexemGraphStruct::chunks, cnPrintNode(), cnShowDeletedFlag, ConstraintNet, ConstraintNode, ConstraintNetStruct::edges, ConstraintNodeStruct::gn, ConstraintNetStruct::id, LexemGraphStruct::isDeletedNode, ConstraintNodeStruct::level, GraphemNodeStruct::lexemes, ConstraintNetStruct::lexemgraph, lgAreDeletedNodes(), max, min, ConstraintNetStruct::nodes, LexemGraphStruct::noOfPaths, ConstraintNodeStruct::noValidValues, NULL, ConstraintNetStruct::parses, and ConstraintNodeStruct::values.

Referenced by cmdNet().

void cnPrintActiveLVs ConstraintNet  net  ) 
 

prints the active levelvalues

This function applies lvPrint() to all LVs in the specified constraint net that are not deleted. Definition at line 2041 of file constraintnet.c.

References CDG_DEBUG, CDG_INFO, cdgPrintf(), ConstraintNet, ConstraintNode, LexemGraphStruct::isDeletedNode, ConstraintNetStruct::lexemgraph, ConstraintNetStruct::nodes, ConstraintNetStruct::values, and ConstraintNodeStruct::values.

void cnPrintEdge long unsigned int  mode,
ConstraintEdge  e
 

Print a constraint edge.

This function displays a constraint edge and the associated matrix scores. It reacts to the display flag mode in the same way as cnPrint() and all other display functions. Definition at line 384 of file constraintnet.c.

References GraphemNodeStruct::arc, cdgPrintf(), ConstraintEdge, ConstraintNodeStruct::gn, ConstraintNodeStruct::level, NULL, ConstraintEdgeStruct::scores, smGetScore(), ConstraintEdgeStruct::start, ConstraintEdgeStruct::stop, and ConstraintNodeStruct::values.

Referenced by cmdEdges().

void cnPrintInfo ConstraintNet  net  ) 
 

print out some information about this net

This function displays some general information about net. Apart from the fields of the structure themselves, the minimal, average, and maximal number of LVs per node is calculated and displayed. This function is called in various places to summarize briefly the state of a constraint net. Definition at line 1696 of file constraintnet.c.

References ConstraintNetStruct::cache, ScoreCacheStruct::capacity, CDG_INFO, CDG_WARNING, cdgPrintf(), ConstraintNet, ConstraintNode, ConstraintNetStruct::edges, ConstraintNetStruct::evalBinary, ConstraintNetStruct::evalUnary, ScoreCacheStruct::hits, hkVerbosity, ConstraintNetStruct::id, LexemGraphStruct::lattice, ConstraintNetStruct::lexemgraph, max, min, ConstraintNetStruct::nodes, ConstraintNodeStruct::noValidValues, NULL, ScoreCacheStruct::size, and ConstraintNetStruct::statUnary.

Referenced by cmdNetsearch(), cmdNewnet(), cmdPrintParses(), and cmdRenewnet().

void cnPrintNode long unsigned int  mode,
ConstraintNode  cn
 

Print a constraint node.

This function displays a constraint node. A node of the level LEVEL binding the lexemes das_1 and das_2 from time span (1,2) would be displayed like this:

das_1/das_2(1-2)/LEVEL Definition at line 458 of file constraintnet.c.

References GraphemNodeStruct::arc, cdgPrintf(), ConstraintNode, ConstraintNodeStruct::gn, ConstraintNodeStruct::level, GraphemNodeStruct::lexemes, LexemNode, and NULL.

Referenced by cnBuildUpdateArcs(), cnPrint(), and cnSortNodes().

void cnPrintParses ConstraintNet  net  ) 
 

prints all Parses of a net

This function applies parsePrint() to all entries of net->parses. Definition at line 1864 of file constraintnet.c.

References CDG_INFO, cdgPrintf(), ConstraintNet, NULL, and ConstraintNetStruct::parses.

Referenced by cmdNetsearch(), and cmdPrintParses().

Boolean cnRenew ConstraintNet  net  ) 
 

Return a constraint net to untouched state

This function undoes all changes that have been made to a constraint net since it was built. In particular, it restores all deleted lexeme nodes and LVs to a constraint net. All parses of net are deallocated. This returns the net to the state that it was in immediately after being optimized. TRUE is returned only if at least one value remains for each pair of word and level. Definition at line 1247 of file constraintnet.c.

References ConstraintNetStruct::cache, cnOptimizeNet(), cnSortLVs(), cnUseNonSpec, ConstraintNet, ConstraintNode, FALSE, LexemGraphStruct::isDeletedNode, ConstraintNetStruct::lexemgraph, LexemNode, lgComputeDistances(), lgComputeNoOfPaths(), LexemNodeStruct::limit, LexemGraphStruct::nodes, ConstraintNetStruct::nodes, ConstraintNodeStruct::noValidValues, NULL, ConstraintNetStruct::parses, scDelete(), scNew(), scUseCache, TRUE, ConstraintNetStruct::values, and ConstraintNodeStruct::values.

Referenced by cmdRenewnet().

void cnSortLVs ConstraintNet  net  ) 
 

re-sorts the LVs in each constraint node by limit rather than by score

This function sorts the Vectors values=of all constraint nodes of net using lvCompare(). Definition at line 1808 of file constraintnet.c.

References ConstraintNet, ConstraintNode, ConstraintNetStruct::nodes, and ConstraintNodeStruct::values.

Referenced by cnBuildFinal(), and cnRenew().

void cnSortNodes ConstraintNet  net  ) 
 

Sort constraint nodes.

This function sorts the constraint nodes of net using the function cnNodeCompare(). Definition at line 573 of file constraintnet.c.

References CDG_DEBUG, cdgPrintf(), cnNodeComparePrio(), cnNodeCompareSmallest(), cnPrintNode(), cnSortNodesMethod, ConstraintNet, ConstraintNode, hkVerbosity, ConstraintNetStruct::nodes, and ConstraintNodeStruct::noValidValues.

Referenced by cnBuildFinal().

Boolean cnTag ConstraintNet  net,
Lattice  lat
 

Build lexeme graph and add tagger and chunker information to NET. Definition at line 109 of file constraintnet.c.

References CDG_DEBUG, CDG_INFO, cdgPrintf(), Chunker, chunkerChunk(), chunkerDelete(), chunkerNew(), chunkerPrintChunks(), cnDelete(), ConstraintNet, DefaultChunker, FALSE, LexemGraphStruct::graphemnodes, hkVerbosity, ConstraintNetStruct::lexemgraph, lgNew(), LexemGraphStruct::max, LexemGraphStruct::min, LexemGraphStruct::nodes, LexemGraphStruct::noOfPaths, NULL, and TRUE.

Referenced by cnBuild().

void cnUnaryPruning ConstraintNode  node  ) 
 

Remove a given percentage of values from a node.

This function finds the values with the worst scores from a constraint node and deletes them. Let W be the set of LVs in node. All elements of W are deleted whose score is smaller than the score of the nth element, where

n = (int) =|W| * (1 - cnUnaryPruningFraction)

This function temporarily sorts the set $W$ using the function cnUnaryPruningCompare()=. Definition at line 500 of file constraintnet.c.

References CDG_INFO, cdgPrintf(), cnUnaryPruningCompare(), cnUnaryPruningFraction, ConstraintNode, ConstraintNodeStruct::noValidValues, NULL, TRUE, and ConstraintNodeStruct::values.

Referenced by cnBuildFinal().

Boolean cnUnaryPruningCompare LevelValue  a,
LevelValue  b
 

comparison function for cnUnaryPruning()

This function compares two LVs by their scores. It returns TRUE iff a->score < b->score. Definition at line 482 of file constraintnet.c.

Referenced by cnUnaryPruning().

void cnUndeleteAllLVs ConstraintNet  net  ) 
 

undelete all levelvalues in a constraint net

This function resets the field isDeleted for all LVs in the specified constraint net. Definition at line 2066 of file constraintnet.c.

References ConstraintNet, FALSE, and ConstraintNetStruct::values.

int countValidValues ConstraintNet  net  ) 
 

This function returns the number of undeleted LVs in net. It is a helper fo cnOptimizeNet Definition at line 1126 of file constraintnet.c.

References ConstraintNet, and ConstraintNetStruct::values.

Referenced by cnOptimizeNet().

void cvAnalyse ConstraintViolation  cv,
Vector  context
 

Show what the conflict means. This function prints out the conflict itself, the LVs that actually cause it, the constraint that is violated, and the participating lexemes. Definition at line 1494 of file constraintnet.c.

References CDG_INFO, cdgPrintf(), ConstraintViolationStruct::constraint, ConstraintViolation, cvPrint(), evalBinaryConstraint(), LexemNodeStruct::lexem, LexemNode, ConstraintViolationStruct::lv1, ConstraintViolationStruct::lv2, and NULL.

ConstraintViolation cvClone ConstraintViolation  cv  ) 
 

clone a constraint violation

Returns:
a clone of cv.
Definition at line 1793 of file constraintnet.c.

References ConstraintViolationStruct::constraint, ConstraintViolation, cvNew(), ConstraintViolationStruct::lv1, ConstraintViolationStruct::lv2, and ConstraintViolationStruct::penalty.

Boolean cvCompare ConstraintViolation  a,
ConstraintViolation  b
 

Constraint violations should be sorted first by penalty, then by arity, finally by natural order.

This function compares two conflicts. It returns TRUE

  • if a has the lower penalty
  • otherwise, if a is unary and b is binary
  • otherwise, if the first LV in a precedes the first lv in b according to natural order.
Definition at line 1992 of file constraintnet.c.

References ConstraintViolationStruct::constraint, ConstraintViolation, FALSE, ConstraintViolationStruct::lv1, ConstraintViolationStruct::lv2, ConstraintViolationStruct::penalty, and TRUE.

Referenced by comCompareAllLvPairs(), and comCompareWithContext().

Boolean cvCompareNatural ConstraintViolation  a,
ConstraintViolation  b
 

compares two violations by natural order

This function compares two ConstraintViolation= structures by the position of the affected LVs. If both affect the same LVs, it compares them by the constraint name. Definition at line 1960 of file constraintnet.c.

References ConstraintViolationStruct::constraint, ConstraintViolation, FALSE, ConstraintViolationStruct::nodeBindingIndex1, ConstraintViolationStruct::nodeBindingIndex2, and TRUE.

Boolean cvContains List  conflicts,
ConstraintViolation  cv
 

Does a conflict occur in a list?

This function checks whether a conflict equivalent to cv= appears in the List. TRUE= is returned if both the constraint and the fields nodeBindingIndex1= and nodeBindingIndex2= match (the penalty need not match). Definition at line 1933 of file constraintnet.c.

References ConstraintViolationStruct::constraint, ConstraintViolation, FALSE, ConstraintViolationStruct::nodeBindingIndex1, ConstraintViolationStruct::nodeBindingIndex2, and TRUE.

void cvDelete ConstraintViolation  cv  ) 
 

cvDelete

This function deallocates a structure of type ConstraintViolation. Since all components of this type are shallow copies, only the structure itself is deallocated. Definition at line 1567 of file constraintnet.c.

References ConstraintViolation, ConstraintViolationStruct::lv1, and ConstraintViolationStruct::lv2.

Referenced by comCompareAllLvPairs(), and comCompareWithContext().

ConstraintViolation cvNew Constraint  c,
LevelValue  lva,
LevelValue  lvb
 

Allocate a new constraint violation. This function allocates a new ConstraintViolation. The parameters are installed in the corresponding fields of the new structure. All fields of a ConstraintViolation are shallow copies. Definition at line 1756 of file constraintnet.c.

References ConstraintViolationStruct::constraint, ConstraintViolation, ConstraintViolationStruct::lv1, ConstraintViolationStruct::lv2, ConstraintViolationStruct::nodeBindingIndex1, ConstraintViolationStruct::nodeBindingIndex2, and ConstraintViolationStruct::penalty.

Referenced by cvClone(), evalBinary(), and evalUnary().

void cvPrint unsigned long  mode,
ConstraintViolation  cv
 

Print a conflict.

This function displays a conflict using cdgPrintf(). If width is~0, the constraint identifier is printed in full, otherwise it is truncated to width characters. Definition at line 1912 of file constraintnet.c.

References CDG_INFO, cdgPrintf(), ConstraintViolationStruct::constraint, ConstraintViolation, ConstraintViolationStruct::nodeBindingIndex1, ConstraintViolationStruct::nodeBindingIndex2, and ConstraintViolationStruct::penalty.

Referenced by cvAnalyse().


Variable Documentation

int cnCounter
 

Counts the constraint nets created so far and appears in the name of every constraint net. Definition at line 50 of file constraintnet.c.

Referenced by cnBuildInit().

int cnCounter = 0
 

Counts the constraint nets created so far and appears in the name of every constraint net. Definition at line 50 of file constraintnet.c.

Referenced by cnBuildInit().

CnEdgesType cnEdgesFlag
 

This variable implements the CDG variable edges. Definition at line 58 of file constraintnet.c.

Referenced by cmdIncrementalCompletion(), cmdStatus(), cnBuildEdges(), cnBuildFinal(), and cnInitialize().

CnEdgesType cnEdgesFlag = cnEdgesOff
 

This variable implements the CDG variable edges. Definition at line 58 of file constraintnet.c.

Referenced by cmdIncrementalCompletion(), cmdStatus(), cnBuildEdges(), cnBuildFinal(), and cnInitialize().

ConstraintNet cnMostRecentlyCreatedNet
 

cnMostRecentlyCreatedNet points to last constraint net created (or to NULL). This variable is used as an implicit argument to commands that expect the name of a constraint net. Definition at line 55 of file constraintnet.c.

Referenced by cdgDeleteComputed(), cmdISearch(), cmdNet(), cmdNetdelete(), cmdNetsearch(), cmdPrintParses(), cmdRenewnet(), cmdWriteAnno(), cmdWriteNet(), cmdWriteParses(), cnBuild(), and cnDelete().

ConstraintNet cnMostRecentlyCreatedNet = NULL
 

cnMostRecentlyCreatedNet points to last constraint net created (or to NULL). This variable is used as an implicit argument to commands that expect the name of a constraint net. Definition at line 55 of file constraintnet.c.

Referenced by cdgDeleteComputed(), cmdISearch(), cmdNet(), cmdNetdelete(), cmdNetsearch(), cmdPrintParses(), cmdRenewnet(), cmdWriteAnno(), cmdWriteNet(), cmdWriteParses(), cnBuild(), and cnDelete().

Boolean cnShowDeletedFlag
 

If this flag is set, deleted LVs will be bracketed with [ ] in all output. If it is not set, they will not be shown at all. Definition at line 62 of file constraintnet.c.

Referenced by cmdStatus(), cnInitialize(), and cnPrint().

Boolean cnShowDeletedFlag = FALSE
 

If this flag is set, deleted LVs will be bracketed with [ ] in all output. If it is not set, they will not be shown at all. Definition at line 62 of file constraintnet.c.

Referenced by cmdStatus(), cnInitialize(), and cnPrint().

int cnSortNodesMethod
 

This variable implements the CDG variable sortnodes. Definition at line 76 of file constraintnet.c.

Referenced by cmdStatus(), cnBuildFinal(), cnInitialize(), and cnSortNodes().

int cnSortNodesMethod = 0
 

This variable implements the CDG variable sortnodes. Definition at line 76 of file constraintnet.c.

Referenced by cmdStatus(), cnBuildFinal(), cnInitialize(), and cnSortNodes().

Number cnUnaryPruningFraction
 

This variable gives the approximate ratio of LVs retained while building a constraint net. It defaults to~1, so that no LVs are deleted upon building. If it is smaller, then from any set W of LVs the worst floor(|W| x)) LVs will be removed. Definition at line 73 of file constraintnet.c.

Referenced by cmdStatus(), cnInitialize(), and cnUnaryPruning().

Number cnUnaryPruningFraction = 1.0
 

This variable gives the approximate ratio of LVs retained while building a constraint net. It defaults to~1, so that no LVs are deleted upon building. If it is smaller, then from any set W of LVs the worst floor(|W| x)) LVs will be removed. Definition at line 73 of file constraintnet.c.

Referenced by cmdStatus(), cnInitialize(), and cnUnaryPruning().

Boolean cnUseNonSpec
 

if this Flag is set, newly created constraint networks will contain non-specific dependency edges aswell Definition at line 66 of file constraintnet.c.

Referenced by cnBuildFinal(), cnBuildIter(), cnInitialize(), and cnRenew().

Boolean cnUseNonSpec = FALSE
 

if this Flag is set, newly created constraint networks will contain non-specific dependency edges aswell Definition at line 66 of file constraintnet.c.

Referenced by cnBuildFinal(), cnBuildIter(), cnInitialize(), and cnRenew().


CDG 0.95 (20 Oct 2004)