KeyNoteTokenFreqPerFileTable.mesa
Copyright Ó 1985, 1986 by Xerox Corporation. All rights reserved.
Jack Kent January 14, 1988 11:37:45 am PST
The TokenFreqPerFileTable is a structure used to 'hold' the (token, frequency) results while a given file is being perused. The results for a given file are then written out (in their entirety) to the database on behalf of a single transaction.
Note: A RedBlack Tree was used instead of a Symbol Table as the latter provides no client controlled enumeration (only call-back procedures).
DIRECTORY
Rope,
RedBlackTree;
KeyNoteTokenFreqPerFileTable: CEDAR DEFINITIONS = BEGIN
Types
ROPE: TYPE = Rope.ROPE;
Table: TYPE = RedBlackTree.Table;
Compare: TYPE = RedBlackTree.Compare;
EachNode: TYPE = RedBlackTree.EachNode;
Node: TYPE = RedBlackTree.Node;
Key: TYPE = RedBlackTree.Key;
UserData: TYPE = REF UserDataObject;
UserDataObject: TYPE = RECORD [
token: ROPE,
frequency: INTEGER];
Procedures
Create: PROC [] RETURNS [table: Table];
This procedure creates a redBlack tree for KeyNote
DestroyTable: PROC [table: Table];
makes it empty. called between files
InsertAndBumpFrequncy: PROC [table: Table, tokenName: ROPE];
inserts the entry tokenName into RedBlackTree and bumps frequency as a side-effect
EnumerateDecreasing: PROC [table: Table, procToApply: EachNode];
LookupNextLarger: PROC [self: Table, tokenName: ROPE] RETURNS [data: UserData];
Lookup: PROC [ self: Table, tokenName: ROPE] RETURNS [data: UserData];
END.