1 // CSequencer, sentenceItem classes
2 // Copyright © 2009 The University of Chicago
9 #include <Q3SortedList>
12 namespace linguistica
{ namespace ui
{ class status_user_agent
; } }
23 QMap
<QString
, int> m_bigrams
;
24 QMap
<QString
, int> m_trigrams
;
26 QMap
<QString
, int> m_bigramsbase
;
27 QMap
<QString
, int> m_trigramsbase
;
29 QMap
<QString
, double> m_bigramprob
;
30 QMap
<QString
, double> m_trigramprob
;
34 int m_totalbigramsbase
;
35 int m_totaltrigramsbase
;
39 void readCorpus(linguistica::ui::status_user_agent
& status_out
);
40 void sequenceASentence(int& birank
, int& trirank
,
41 QString inputSentence
= QString());
42 void sequenceASentence2(int& birank
, int& trirank
,
43 QString inputSentence
= QString());
44 void sequenizeFromABigram(QString bigram
, double bigram_value
,
45 QMap
<QString
, int>& words
, int sentence_len
, int K
,
46 Q3SortedList
<sentenceItem
>& result_K_sentences
,
48 void sequenize2(QMap
<QString
, int> allwords
, int sentence_len
,
49 int K
, Q3SortedList
<sentenceItem
>& result_K_sentences
,
51 void sequencerTestAFile(linguistica::ui::status_user_agent
& status_out
);
60 QMap
<QString
, int> m_bagofwords
;
61 QMap
<int, QString
> m_historystrings
;
62 QMap
<int, double> m_historyscores
;
64 int m_numberofwordsinsentence
; // only used for sequencerize2
70 sentenceItem(double value
, QString
& key
,
71 QMap
<QString
, int>& bagofwords
,
73 QMap
<int, QString
>& historystrings
,
74 QMap
<int, double>& historyscores
)
76 m_key
= key
; m_bagofwords
= bagofwords
; m_stepnumber
= stepnumber
; m_historystrings
= historystrings
; m_historyscores
= historyscores
;\
77 m_historystrings
.insert(m_stepnumber
, m_key
); m_historyscores
.insert(m_stepnumber
, m_value
); m_numberofwordsinsentence
= 0; };
80 sentenceItem(sentenceItem
* other
) {m_value
= other
->m_value
; \
81 m_key
= other
->m_key
; m_bagofwords
= other
->m_bagofwords
; \
82 m_stepnumber
= other
->m_stepnumber
; \
83 m_historystrings
= other
->m_historystrings
; \
84 m_historyscores
= other
->m_historyscores
;\
85 m_numberofwordsinsentence
= other
->m_numberofwordsinsentence
;
90 bool operator<(const sentenceItem
& another
) {return !(m_value
> another
.m_value
); };
91 bool operator==(const sentenceItem
& another
) {return (m_value
== another
.m_value
);};