1 // UI actions for discovering phonology
2 // Copyright © 2009 The University of Chicago
3 #include "linguisticamainwindow.h"
6 #include "corpusviewdialog.h"
7 #include "MiniLexicon.h"
9 #include "StateEmitHMM.h"
10 #include "Sequencer.h"
13 #include "WordCollection.h"
15 void LinguisticaMainWindow::GenericPhonologySlot()
17 CMiniLexicon
* current_mini
= m_lexicon
->GetMiniLexicon(m_lexicon
->GetActiveMiniIndex());
21 current_mini
->GetWords()->DoPhonology();
24 emit
updateAllViewsSignal();
26 void LinguisticaMainWindow::CreateSkeletonSlot() // Creates CV template
29 CMiniLexicon
* current_mini
= m_lexicon
->GetMiniLexicon(m_lexicon
->GetActiveMiniIndex());
32 current_mini
->GetWords()->CreateCVTemplate();
37 emit
updateAllViewsSignal();
40 void LinguisticaMainWindow::PhonologyCalculateInformation()
46 void LinguisticaMainWindow::DropTierLeaveSlot()
48 CMiniLexicon
* current_mini
= m_lexicon
->GetMiniLexicon(m_lexicon
->GetActiveMiniIndex());
52 current_mini
->GetWords()->SplitPhonologyToTiers(
53 CStem::Split_LeaveSlot
);
54 current_mini
->GetWords()->ComputeZ();
55 current_mini
->GetWords()->ComputeZStar();
56 current_mini
->GetWords()->ComputeBoltzmannProbabilities();
62 emit
updateAllViewsSignal();
65 void LinguisticaMainWindow::DropTierLeaveCopy()
67 CMiniLexicon
* current_mini
= m_lexicon
->GetMiniLexicon(m_lexicon
->GetActiveMiniIndex());
70 current_mini
->GetWords()->SplitPhonologyToTiers(
71 CStem::Split_LeaveCopy
);
72 current_mini
->GetWords()->ComputeZ();
73 current_mini
->GetWords()->ComputeZStar();
74 current_mini
->GetWords()->ComputeBoltzmannProbabilities();
79 emit
updateAllViewsSignal();
82 void LinguisticaMainWindow::PhonologyComputeGibbsFunction() // currently not used.
84 CMiniLexicon
* current_mini
= m_lexicon
->GetMiniLexicon(m_lexicon
->GetActiveMiniIndex());
87 //current_mini->GetWords()->ComputeZ();
90 emit
updateAllViewsSignal();
93 void LinguisticaMainWindow::sequencerReadCorpusSlot()
96 m_Sequencer
->readCorpus(status_display());
99 void LinguisticaMainWindow::sequenceASentenceSlot()
101 if ( m_Sequencer
== NULL
)
110 //m_Sequencer ->sequenceASentence(birank,trirank);
111 m_Sequencer
->sequenceASentence2(birank
,trirank
);
116 void LinguisticaMainWindow::sequencerTestAFileSlot()
118 if (m_Sequencer
!= 0)
119 m_Sequencer
->sequencerTestAFile(status_display());
122 void LinguisticaMainWindow::statsReadCorpusSlot()
124 if ( m_Stats
== NULL
)
129 m_Stats
->readCorpus();
133 void LinguisticaMainWindow::DCNstressSlot()
135 // combinedWindow *window = new combinedWindow(0, "DCN");
139 void LinguisticaMainWindow::DCNsylSlot()
141 // windowsyl* window = new windowsyl(0, "DCN Main Window");
145 void LinguisticaMainWindow::fromStemsFindCompoundsSlot()
147 if( m_logging
) OpenLogFile();
148 m_lexicon
->FromStemsFindCompounds();
149 if( m_logging
) CloseLogFile();
151 // Update corpus words
152 m_lexicon
->DoWordUpdates();
155 m_projectDirty
= true;
158 emit
updateAllViewsSignal();
161 void LinguisticaMainWindow::fromStemsFindFlatCompoundsSlot()
163 if( m_logging
) OpenLogFile();
164 m_lexicon
->FromStemsFindFlatCompounds();
165 if( m_logging
) CloseLogFile();
167 // Update corpus words
168 m_lexicon
->DoWordUpdates();
171 m_projectDirty
= true;
174 emit
updateAllViewsSignal();
180 void LinguisticaMainWindow::mTModel1Slot()
183 int model1Iterations
= 10;
184 int model2Iterations
= 10;
185 bool inheritTFromModel1
= true;
192 m_MT
= new cMT(this, m_projectDirectory
);
194 m_MT
->readTrainingCorpus();
196 m_MT
->trainModel1(model1Iterations
);
198 m_MT
->trainModel2Norm(model2Iterations
, inheritTFromModel1
);
203 void LinguisticaMainWindow::testSEMHMMSlot()
206 CWordCollection
* dataCorpus
;
209 int NumberOfIterations(70);
213 NumberOfIterations
= m_lexicon
->GetIntParameter ("HMM\\NumberOfIterations", 25);
214 NumberOfStates
= m_lexicon
->GetIntParameter ("HMM\\NumberOfStates", 2);
218 QMessageBox::information ( this, "Linguistica : Error", "Lexicon is NULL when running HMM!" );
224 pMini
= (*(m_lexicon
->m_pMiniLexica
))[0];
226 dataCorpus
= pMini
->GetWords();
228 pHMM
= m_lexicon
->CreateNewHMM();
231 dataIsRight
= pHMM
->preprocessData(PHONE_TIER1
, (void*)(dataCorpus
));
236 QMessageBox::information ( this, "Linguistica : Error", "Data is not right for HMM!" );
240 pHMM
->init(NumberOfStates
,NumberOfIterations
);
245 pHMM
->trainParameters();
248 // delete oneStateHMM;
251 emit
updateAllViewsSignal();
255 void LinguisticaMainWindow::calculateAffixnessSlot()
257 if( m_logging
) OpenLogFile();
258 m_lexicon
->CalculateCoefficientsOfAffixness();
259 if( m_logging
) CloseLogFile();
262 m_projectDirty
= true;
265 emit
updateAllViewsSignal();
269 void LinguisticaMainWindow::fromAffixnessUpdateSigsAndCompoundsSlot()
271 if( m_logging
) OpenLogFile();
272 m_lexicon
->FromAffixnessUpdateSigsAndCompounds();
273 if( m_logging
) CloseLogFile();
275 // Update corpus words
276 m_lexicon
->DoWordUpdates();
279 m_projectDirty
= true;
282 emit
updateAllViewsSignal();
286 void LinguisticaMainWindow::viewCorpusSlot()
288 CorpusViewDialog
*corpusViewDlg
= new CorpusViewDialog( m_lexicon
, this,
289 Qt::WStyle_Customize
|
290 Qt::WStyle_NormalBorder
|
292 Qt::WStyle_SysMenu
);
293 if( corpusViewDlg
->exec() == QDialog::Accepted
)
301 delete corpusViewDlg
;
305 void LinguisticaMainWindow::exportProjectSlot()
307 #ifdef _EXPORTWIZARD_ //@@@
308 ExportWizard
*exportWiz
= new ExportWizard( m_lexicon
, this, "exportWizard", FALSE
);
309 if( exportWiz
->exec() == QDialog::Accepted
)
313 exportWiz
->exportAll();