1 // Pair-of-tries class template
2 // Copyright © 2009 The University of Chicago
3 #ifndef COLLECTIONTEMPLATE_H
4 #define COLLECTIONTEMPLATE_H
9 #include "generaldefinitions.h"
16 class CSuffixCollection
;
17 class CPrefixCollection
;
18 class CStemCollection
;
20 template<class T
> class TCollection
: public CTrie
{
23 bool m_DeletePointers
;
25 bool m_HashHasChangedFlag
;
29 CMiniLexicon
* m_pMiniLex
;
30 CTrie
* m_pReverseTrie
;
31 CNode
** m_pTerminalNodeArray
;
34 enum eSortStyle m_SortStyle
;
35 double m_TotalUseCount
;
37 // construction/destruction.
40 TCollection(CMiniLexicon
* Mini
, QString MemberName
= QString());
41 TCollection(CLexicon
* Lex
, QString MemberName
= QString());
46 TCollection(const TCollection
& x
);
47 TCollection
& operator=(const TCollection
& x
);
50 T
* operator<< ( CParse
* );
51 T
* operator<< ( CStringSurrogate
);
52 T
* operator<< ( QString
);
53 T
* operator^= ( CParse
* );
54 T
* operator^= ( CStringSurrogate
);
55 T
* operator^= ( QString
);
56 T
* operator[] ( uint n
);
58 void AddPointer( T
* );
59 T
* AddToCollection( const CParse
& );
60 T
* AddToCollection( const CStringSurrogate
& );
61 bool Contains( CStringSurrogate
& );
62 void CreatePointerArray();
63 void CreateReverseTrie();
64 void DeleteMarkedMembers();
65 void DoNotDeletePointers();
66 void DumpVisibleToLogFile();
67 void DumpVisibleWords( CWordCollection
* );
69 CStringSurrogate
FindMaximalMajorityPrefix();
70 void FindMemberExtensions ( int, TCollection
<CLParse
>& );
72 CStringSurrogate
GetAt_SS( int );
73 T
* GetAtSort( int n
);
74 CStringSurrogate
GetAtSort_SS( int );
75 int GetCorpusCount() const;
76 CLexicon
* GetLexicon();
77 CMiniLexicon
* GetMiniLexicon();
78 CTrie
* GetReverseTrie();
79 int GetSortValidFlag();
80 int GetTotalUseCount() { return m_TotalUseCount
; }
82 int GetWidth( CStringSurrogate
); // i.e., from Trie
83 void IncrementCorpusCount( int n
= 1 );
84 void MarkForDeletion( int );
85 void RecomputeCorpusCount();
86 bool Remove( T
* ); // doesn't delete T*
88 bool RemoveMember( T
* ); // deletes T*
89 bool RemoveMember( const CStringSurrogate
& ); // deletes T*
90 bool RemoveMember( const CStringSurrogate
&, bool ); // FSA
91 CLParse
* SeekChain( T
*, CLParse
*, int );
92 void SetKey( T
*, CParse
& );
93 void SetKey( T
*, QString
);
94 void SetSortStyle( eSortStyle
);
95 void SetSortValidFlag(bool value
);
96 void Sort( eSortStyle
);
97 void T_PredecessorFrequency( eSuccessorFrequencyMode
,
98 CStemCollection
* Stems
= NULL
,
99 CPrefixCollection
* Suffixes
= NULL
,
100 int MaxNeighborPredecessorCount
= 1,
101 int MaximumPrefixLength
= 5,
102 int MinimumStemLength
= 3,
104 int RightMargin
= -1 );
105 void T_SuccessorFrequency( eSuccessorFrequencyMode
,
106 CStemCollection
* Stems
= NULL
,
107 CSuffixCollection
* Suffixes
= NULL
,
108 int MaxNeighborSuccessorCount
= 1,
109 int MaximumSuffixLength
= 5,
110 int MinimumStemLength
= 3,
112 int RightMargin
= -1 );
115 #include "CollectionTemplate.tcc"
117 #endif // COLLECTIONTEMPLATE_H