1 // Implementation of CSuffix methods
2 // Copyright © 2009 The University of Chicago
5 #include <Q3TextStream>
6 #include "MiniLexicon.h"
8 #include "WordCollection.h"
9 #include "StringSurrogate.h"
10 #include "CompareFunc.h"
13 // construction/destruction.
15 CSuffix::CSuffix( CMiniLexicon
* mini
) : CAffix( mini
)
18 CSuffix::CSuffix (const CStringSurrogate
& Key
, CMiniLexicon
* mini
): CAffix(Key
, mini
)
26 //-----------------------------------------------------------------
28 //-----------------------------------------------------------------
31 // TODO: Rewrite for Qt
32 // Create the list item to be displayed in
36 // List - the list item to be built
37 // Line - what line it will be displayed
40 void CSuffix::ListDisplay(Q3ListView
* List
, QMap
<QString
, QString
>* filter
,
41 bool ExpressDeletees
, int char_count
)
44 Express( display
, ExpressDeletees
);
45 static_cast<void>(new CSuffixListViewItem(List
,
46 display
.Display(QChar(), filter
),
47 this, filter
, char_count
));
51 // Remerge all words that use this suffix into a
55 // Lexicon - holds stem-->suffix relationship
58 void CSuffix::MergeMeWithMyStems (CMiniLexicon
* Lexicon
)
60 CStringSurrogate ssSuffix
= GetKey(),
66 for (int j
= 1; j
<= (int)GetStemString()->Size(); j
++)
68 ssStem
= GetStemString()->GetPiece(j
);
69 Word
= ssStem
+ ssSuffix
;
70 pWord
= *Lexicon
->GetWords() ^= Word
;
73 pWord
->ClearRootSuffixSplit();
78 QString
CSuffix::DisplaySuffix( bool ExpressDeletees
)
86 if ( ExpressDeletees
&& m_Deletees
.GetKeyLength() > 0 )
89 Outstring
+= m_Deletees
.Display();
92 if ( ExpressDeletees
&& m_Morphees
.GetKeyLength() > 0 )
94 QString strMorphees
= m_Morphees
.Display();
95 CSS
ssMorphees( strMorphees
);
97 Outstring
+= ssMorphees
.Display() ;
101 Outstring
+= GetKey().Display();
107 CParse
& CSuffix::Express( CParse
& Output
, bool ExpressDeletees
)
115 if ( ExpressDeletees
&& m_Deletees
.GetKeyLength() > 0 )
117 QString strDeletees
= m_Deletees
.Display();
118 CSS
ssDeletees( strDeletees
);
119 Output
.Append( ltSq
);
120 Output
.Append( ssDeletees
);
121 Output
.Append( rtSq
);
123 if ( ExpressDeletees
&& m_Morphees
.GetKeyLength() > 0 )
125 QString strMorphees
= m_Morphees
.Display();
126 CSS
ssMorphees( strMorphees
);
127 Output
.Append( ltCu
);
128 Output
.Append ( ssMorphees
);
129 Output
.Append( rtCu
);
132 Output
.Append ( GetKey() );
133 Output
.SimplifyParseStructure();
138 void CSuffix::OutputSuffix( Q3TextStream
& outf
)
142 if( m_KeyLength
== 0 ) key
= "NULL";
143 else key
= Display( QChar(0), m_pMyMini
->GetOutFilter() );
157 outf
<< GetCorpusCount();
164 #include "affix_list_view_item.tcc"
165 template class linguistica::affix_list_view_item
<CSuffix
>;