CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / Sequencer.h
blob7420d1a9785d1b7530d8c0001ef5d49ce12629b9
1 // CSequencer, sentenceItem classes
2 // Copyright © 2009 The University of Chicago
3 #ifndef SEQUENCER_H
4 #define SEQUENCER_H
6 class CSequencer;
7 class sentenceItem;
9 #include <Q3SortedList>
10 #include <QString>
11 #include <QMap>
12 namespace linguistica { namespace ui { class status_user_agent; } }
14 class CSequencer {
15 // parameters.
16 int m_K;
17 int m_resultK;
18 int m_maxlineintrain;
19 int m_maxlineintest;
20 private:
21 QString separator;
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;
32 int m_totalbigrams;
33 int m_totaltrigrams;
34 int m_totalbigramsbase;
35 int m_totaltrigramsbase;
36 public:
37 CSequencer();
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,
47 int computetype);
48 void sequenize2(QMap<QString, int> allwords, int sentence_len,
49 int K, Q3SortedList<sentenceItem>& result_K_sentences,
50 int computetype);
51 void sequencerTestAFile(linguistica::ui::status_user_agent& status_out);
54 class sentenceItem
56 public:
58 double m_value;
59 QString m_key;
60 QMap<QString, int> m_bagofwords;
61 QMap<int, QString> m_historystrings;
62 QMap<int, double> m_historyscores;
63 int m_stepnumber;
64 int m_numberofwordsinsentence; // only used for sequencerize2
66 public:
67 sentenceItem(){};
68 ~sentenceItem(){};
70 sentenceItem(double value, QString& key,
71 QMap<QString, int>& bagofwords,
72 int stepnumber,
73 QMap<int, QString>& historystrings,
74 QMap<int, double>& historyscores)
75 { m_value = value;
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);};
97 #endif // SEQUENCER_H