1 // User interface and driver
2 // Copyright © 2009 The University of Chicago
3 #ifndef LINGUISTICAMAINWINDOW_H
4 #define LINGUISTICAMAINWINDOW_H
6 // Doxygen comments defining the index page
7 /** \mainpage Linguistica
9 \section intro_sec What is Linguistica?
11 Linguistica is a program designed to explore the unsupervised learning of natural language, with primary focus on morphology (word-structure). It runs under Windows, Mac OS X and Linux, and is written in C++ within the Qt development framework. Its demands on memory depend on the size of the corpus analyzed.
13 Unsupervised learning refers to the computational task of making inferences (and therefore acquiring knowledge) about the structure that lies behind some set of data, without any direct access to that structure. In the case of unsupervised learning of morphology, Linguistica explores the possibilities of morpheme-combinations for a set of words, based on no internal knowledge of the language from which the words are drawn.
15 Segmentation is the first task of this process; the program figures out where the morpheme boundaries are in the words, and then decides what the stems are, what the suffixes are, and so forth. Most of Linguistica's functionality, at this point, goes into making these decisions.
17 \section creator Creator
20 \section engineers Engineers
27 \section contributors Contributors
36 #include <QMainWindow>
37 #include "ui_linguisticamainwindowbase.h"
40 #include <Q3ProgressDialog>
41 #include <Q3FileDialog>
42 #include <QInputDialog>
43 #include <QFontDialog>
44 #include <Q3PopupMenu>
52 #include <QResizeEvent>
53 #include <QCloseEvent>
55 #include <QApplication>
61 #include <Q3TextStream>
65 #include "LPreferences.h"
66 #include "generaldefinitions.h"
67 #include "AffixLocation.h"
71 namespace linguistica
{ namespace ui
{
72 struct status_user_agent
;
82 class CTemplateCollection
;
83 class CTemplateListViewItem
;
89 class GUIWordCollection
;
93 //typedef QMap<QString,QString> StringToString;
94 typedef QMap
<QString
,CTemplate
*> QStringToTemplate
;
95 typedef Q3PtrList
<CStem
> CStemList
;
96 typedef QMap
<QString
,CStemList
> StringToCStemList
;
97 typedef QMap
<QString
,CStem
*> StringToPtrCStem
;
98 typedef QMap
<QString
,CStem
> StringToCStem
;
99 typedef QMap
<QString
,CParse
*> StringToParse
;
100 typedef QMap
<QString
,CCorpusWord
*> StringToPtrCCorpusWord
;
101 typedef QMap
<int,QString
> IntToString
;
103 class LinguisticaMainWindow
: public QMainWindow
,
104 public Ui::LinguisticaMainWindowBase
109 QApplication
* m_app
; ///< memory belongs to caller
110 /// true if running in batch mode
111 bool m_commandLineFlag
;
114 QSettings m_Settings
;
115 CLPreferences m_preferences
;
121 eDocumentType m_docType
;
122 CParse
* m_commandParse
;
126 GUIWordCollection
* m_GUIWords
;
129 int m_numberOfTokens
;
133 QString m_logFileName
;
135 QTextStream
* m_logFileStream
;
137 // Status/Progress Bar
138 std::auto_ptr
<linguistica::ui::status_user_agent
> m_status
;
139 Q3ProgressDialog
* m_progressDialog
;
140 QString m_progressText1
,
144 bool m_counterDisplayFlag
;
147 // Project information
149 QString m_projectDirectory
;
150 QString m_projectName
;
154 QString m_corpusFileName
;
155 QString m_goldStdFileName
;
156 QString m_goldStdOutputFile
;
159 QString m_EncodingType
;
162 // Collection view and command line can have different
163 // font, they are on the east side of the screen
164 QFont m_eastFont
; // Collection view and command line font, east side of screen
168 CState
* m_CommonState
;
171 CTemplate
* m_CommonTemplate
;
172 CTemplateCollection
* m_Words_InitialTemplates
;
173 CTemplateCollection
* m_Words_Templates
;
175 //========= Sequencer
176 CSequencer
* m_Sequencer
;
178 //========= Statistics
185 LinguisticaMainWindow( const int argc
, char** argv
, QApplication
* app
= 0,
186 QWidget
* parent
= 0, Qt::WindowFlags f
= Qt::WType_TopLevel
);
187 ~LinguisticaMainWindow();
191 LinguisticaMainWindow(const LinguisticaMainWindow
& x
);
192 LinguisticaMainWindow
& operator=(const LinguisticaMainWindow
& x
);
195 void SetNumberOfTokens( int i
) { m_numberOfTokens
= i
; }
196 int GetNumberOfTokens() { return m_numberOfTokens
; }
198 void SetUpNewLexicon ();
200 void setProjectDirectory( QString dir
) { m_projectDirectory
= dir
; }
201 bool getProjectDirty () { return m_projectDirty
; }
203 void setStatusBar1 (QString
);
204 void setStatusBar2 (QString
);
206 void BeginCountDown ();
207 void EndCountDown ();
208 void CountDownOnStatusBar(int i
, int total
, int step
= 100);
210 linguistica::ui::status_user_agent
& status_display()
211 { return *m_status
; }
213 QString
GetLogFileName () { return m_logFileName
; }
214 void AskUserForLogFileName();
216 void SetEastFont ( QFont font
) { m_eastFont
= font
; }
217 CLPreferences
* GetPreferences () { return &m_preferences
; }
218 QSettings
* GetSettings () { return &m_Settings
; }
220 void SetDocType ( eDocumentType dt
) { m_docType
= dt
; }
221 eDocumentType
GetDocType () { return m_docType
; }
223 bool autoLayering () { return m_autoLayeringAction
->isOn(); }
225 bool isCorrectAffix ( eAffixLocation
);
227 void executeCommandLineArgs(int words_count
, bool auto_layer
,
228 bool prefix
, bool suffix
);
229 /// true if running in batch mode
230 bool commandLineMode() { return m_commandLineFlag
; }
232 QFont
GetEastFont () { return m_eastFont
; }
235 void CloseLogFile ();
237 bool LogFileOn () { return m_logging
; }
238 QTextStream
* GetLogFileStream() { return m_logFileStream
; }
241 Q3Canvas
* m_SmallCanvas
;
242 GraphicView
* m_SmallGraphicDisplay
; ///< deleted by m_SmallGraphicDisplayTab
243 Q3VBox
* m_SmallGraphicDisplayVBox
;
246 CLexicon
* GetLexicon(void) { return m_lexicon
; }
250 Q3ListViewItem
* GetMiniLexiconSubTree( Q3ListViewItem
*, int );
251 void GetMorphPrecisionRecallByWord( StringToCStemList
&,
258 void GetCutPrecisionRecall( StringToCStemList
&,
265 void GetMorphPrecisionRecall( StringToCStemList
&,
272 QFont
GetFontPreference(QString key
) const
273 { return m_preferences
.GetFontPreference(key
); }
274 void SetFontPreference(QString key
, QFont font
)
275 { m_preferences
.SetFontPreference(key
, font
); }
276 QString
GetPreference(QString key
) const
277 { return m_preferences
.GetPreference(key
); }
278 void GetStringListPreference(QString key
, QStringList
* out
) const
279 { m_preferences
.GetStringListPreference(key
, out
); }
282 void corpusOKSignal(bool);
283 void updateAllViewsSignal();
284 void updateTreeViewSignal();
285 void updateCommandLineSignal();
286 void tokensRequestedSignal(); // for changing the number of words requested
287 void commandLineClose();
291 // Slots derived from LinguisticaMainWindowBase
292 void openFileActionSlot();
293 void runAllSuffixActionSlot();
294 void enableLoggingActionSlot( bool );
295 void clearLogFileActionSlot();
296 void newLogFileActionSlot();
297 /// Refresh collection view, for example for a switch in m_docType.
298 void updateCollectionViewSlot();
299 void updateCollectionViewSlot( Q3ListViewItem
* );
300 void updateCommandLineSlot( Q3ListViewItem
* );
301 void changeFontSlot();
302 void preferencesEditSlot();
303 void saveFileActionSlot();
304 void newFileActionSlot();
305 void saveAsFileActionSlot();
306 void findAllomorphySlot();
307 void showDeleteesSlot( bool );
308 void rereadCorpusSlot();
309 void clearLexiconSlot();
310 void predecessorFreqSlot();
311 void successorFreqSlot();
312 void checkPfxSignaturesSlot();
313 void checkSignaturesSlot();
314 void knownStemsPrefixesSlot();
315 void knownStemsSuffixesSlot();
316 void fromPfxSigsFindStemsSlot();
317 void fromSigsFindStemsSlot();
318 void findPfxSingletonSigsSlot();
319 void findSingletonSigsSlot();
320 void pfxLooseFitSlot();
322 void showToolbarsSlot( bool );
323 void showStatusBarSlot( bool );
324 void saveBrokenCorpusSlot();
325 void helpAboutSlot();
326 void newMiniLexiconActionSlot();
327 void deleteMiniLexiconActionSlot();
328 void autoLayeringActionSlot();
329 void populateWordsActionSlot();
330 void addToBorrowedSigsSlot();
331 void compareGoldStdSlot();
332 void changeGoldStdFileSlot();
333 void runAllPrefixActionSlot();
334 void commandLineCloseSlot();
335 void viewCorpusSlot();
336 void exportProjectSlot();
337 void addContentToCommandLine(QString
);
338 void setCommandLineTabStopWidth(int length
){m_commandLine
->setTabStopWidth(length
);};
339 int getCommandLinePointSize(){ return m_commandLine
->pointSize();};
340 void setCommandLineStyle( QString
);
341 void xfstExportActionSlot();
344 void fromStemsFindCompoundsSlot();
345 void fromStemsFindFlatCompoundsSlot();
346 void calculateAffixnessSlot();
347 void fromAffixnessUpdateSigsAndCompoundsSlot();
348 void compareCompoundsSlot();
351 virtual void GenericPhonologySlot();
352 virtual void CreateSkeletonSlot();
353 virtual void fromStemsFindAffixesSlot();
354 virtual void DropTierLeaveSlot();
355 virtual void DropTierLeaveCopy();
356 virtual void PhonologyCalculateInformation();
357 virtual void PhonologyComputeGibbsFunction();
359 void updateSmallGraphicDisplaySlot(); //needed for compound displays
361 void fsaTestFuncAction();
363 // Phonogy graphic display
364 void updateSmallGraphicDisplaySlotForPhonogy(CStem
*);
368 void sequencerReadCorpusSlot();
369 void sequenceASentenceSlot();
370 void sequencerTestAFileSlot();
376 void testSEMHMMSlot();
377 void DisplayVideoHMM();
379 // ========= Graphic display of Multidimension data
380 void testMultiDimensionDisplaySlot();
381 void updateSmallGraphicDisplaySlotForMultiDimensionData(int, int, double**, IntToString
);
383 // ====== Goldwater Method
384 void goldwaterMethodSlot();
386 void testSignatureDisplaySlot(); //jg july 2006
389 void statsReadCorpusSlot();
392 void DCNstressSlot();
395 void DCNstressComputeSlot();
396 void DCNstressLearnSlot();
398 void DCNsylFindTrainSlot();
399 void DCNsylFindTestSlot();
400 void DCNsylTrainSlot();
402 // StringEditDistance
404 void FindSlicesSlot();
405 void FindAllEditDistances(CTemplateCollection
*);
406 void CheckForConflations(CTemplateCollection
* , CTemplateCollection
* );
407 void FindAllWordNeighbors(CLexicon
*);
410 // void GetPrecisionRecall(StringToPtrCStem&, StringToParse&, double& , double& , double& , double& );
412 // Machine Translation
413 void editCorpusForMT();
416 void jgWebLinksActionSlot();
417 void lxaWebLinksActionSlot();
418 void updateTreeViewSlot();
419 void updateCommandLineSlot();
420 void tokensRequestedDialogSlot();
421 void setProjectDirtySlot( bool b
) { m_projectDirty
= b
; }
423 void suffixesCollapse_two_signaturesAction_activated();
424 void updateSignatureGraphicDisplaySlot();
427 // User interface items
428 void toggleMultipleSelectionSlot();
432 virtual void closeEvent( QCloseEvent
* );
433 virtual void resizeEvent( QResizeEvent
* );
434 virtual void moveEvent( QMoveEvent
* );
437 bool getLogging(){ return m_logging
; }
440 #endif // LINGUISTICAMAINWINDOW_H