HowManyAreAnalyzed(): use status_user_agent to report progress
[linguistica.git] / Suffix.cpp
blob529a28b68c7830659909c03cf2039573a0e5ea41
1 // Implementation of CSuffix methods
2 // Copyright © 2009 The University of Chicago
3 #include "Suffix.h"
5 #include <Q3TextStream>
6 #include "MiniLexicon.h"
7 #include "Stem.h"
8 #include "WordCollection.h"
9 #include "StringSurrogate.h"
10 #include "CompareFunc.h"
11 #include "Typedefs.h"
13 // construction/destruction.
15 CSuffix::CSuffix( CMiniLexicon* mini ) : CAffix( mini )
18 CSuffix::CSuffix (const CStringSurrogate& Key, CMiniLexicon* mini ): CAffix(Key, mini)
21 CSuffix::~CSuffix()
26 //-----------------------------------------------------------------
27 // Other methods
28 //-----------------------------------------------------------------
31 // TODO: Rewrite for Qt
32 // Create the list item to be displayed in
33 // the triscreen
35 // Parameters:
36 // List - the list item to be built
37 // Line - what line it will be displayed
38 // on
40 void CSuffix::ListDisplay(Q3ListView* List, QMap<QString, QString>* filter,
41 bool ExpressDeletees, int char_count)
43 CParse display;
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
52 // single piece
54 // Parameters:
55 // Lexicon - holds stem-->suffix relationship
56 // information
58 void CSuffix::MergeMeWithMyStems (CMiniLexicon* Lexicon)
60 CStringSurrogate ssSuffix = GetKey(),
61 ssStem;
62 CParse Word;
63 CStem* pWord = NULL;
66 for (int j = 1; j <= (int)GetStemString()->Size(); j++)
68 ssStem = GetStemString()->GetPiece(j);
69 Word = ssStem + ssSuffix;
70 pWord = *Lexicon->GetWords() ^= Word;
71 if (pWord)
73 pWord->ClearRootSuffixSplit();
78 QString CSuffix::DisplaySuffix( bool ExpressDeletees )
80 QString Outstring;
81 QString ltSq = "<",
82 rtSq = ">",
83 ltCu = "{",
84 rtCu = "}";
86 if ( ExpressDeletees && m_Deletees.GetKeyLength() > 0 )
88 Outstring += ltSq;
89 Outstring += m_Deletees.Display();
90 Outstring += rtSq;
92 if ( ExpressDeletees && m_Morphees.GetKeyLength() > 0 )
94 QString strMorphees = m_Morphees.Display();
95 CSS ssMorphees( strMorphees );
96 Outstring += ltCu ;
97 Outstring += ssMorphees.Display() ;
98 Outstring += rtCu ;
101 Outstring += GetKey().Display();
103 return Outstring;
107 CParse& CSuffix::Express( CParse& Output, bool ExpressDeletees )
109 Output.ClearParse();
110 QString ltSq = "<",
111 rtSq = ">",
112 ltCu = "{",
113 rtCu = "}";
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();
134 return Output;
138 void CSuffix::OutputSuffix( Q3TextStream& outf )
140 QString key;
142 if( m_KeyLength == 0 ) key = "NULL";
143 else key = Display( QChar(0), m_pMyMini->GetOutFilter() );
145 outf.width(2);
146 outf << " ";
147 outf.setf(2);
148 outf.width(12);
149 outf << key;
150 outf << " ";
152 outf.unsetf(2);
153 outf.width(9);
154 outf << m_UseCount;
155 outf << " ";
156 outf.width(12);
157 outf << GetCorpusCount();
158 outf << " ";
159 outf.width(5);
160 outf << m_Index;
161 outf << " " << endl;
164 #include "affix_list_view_item.tcc"
165 template class linguistica::affix_list_view_item<CSuffix>;