-
Notifications
You must be signed in to change notification settings - Fork 5
/
lexicon_sublexicon.cpp
73 lines (66 loc) · 2.54 KB
/
lexicon_sublexicon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <QList>
#include <QMap>
#include <QDebug>
#include <QMapIterator>
#include "mainwindow.h"
#include "Lexicon.h"
#include "Stem.h"
#include "StemCollection.h"
#include "WordCollection.h"
CLexicon* CLexicon::build_sublexicon(MainWindow* my_window)
{
CSignature* pSig;
CLexicon* sublexicon = new CLexicon(m_main_window,this, get_suffix_flag());
my_window->set_lexicon(sublexicon);
set_window(my_window);
sublexicon->set_progress_bar(my_window->m_ProgressBar);
sublexicon->set_status_bar(my_window->statusBar());
if (m_suffix_flag == false && m_PrefixSignatures->get_count() < 1) {
return NULL;
}
if (m_suffix_flag == true && m_Signatures->get_count() < 1) {
return NULL;
}
// Get a map of the full signatures (non-hollow), and then take only the stems
// associated with full signatures.
QMap<CSignature*,int> full_signatures;
if (m_suffix_flag){
QMapIterator<sigstring_t, CSignature*> sig_iter (*m_Signatures->get_map());
while (sig_iter.hasNext()){
pSig = sig_iter.next().value();
if (pSig->get_stem_entropy() > get_entropy_threshold_for_positive_signatures() ){
full_signatures[pSig] = 1;
}
}
QMapIterator<QString, CStem*> stem_iter (*m_suffixal_stems->get_stem_map());
while (stem_iter.hasNext()){
CStem* pStem = stem_iter.next().value();
CSignature* pSig = pStem->get_signature();
if (pSig->get_stem_entropy() < m_entropy_threshold_for_stems){
continue;
}
stem_t stem = stem_iter.key();
sublexicon->add_word(stem);
}
}else{ // prefixal signatures
QMapIterator<sigstring_t, CSignature*> sig_iter (*m_PrefixSignatures->get_map());
while (sig_iter.hasNext()){
pSig = sig_iter.next().value();
if (pSig->get_stem_entropy() > get_entropy_threshold_for_positive_signatures() ){
full_signatures[pSig] = 1;
}
}
QMapIterator<QString, CStem*> stem_iter (*m_prefixal_stems->get_stem_map());
while (stem_iter.hasNext()){
CStem* pStem = stem_iter.next().value();
CSignature* pSig = pStem->get_signature();
if (pSig->get_stem_entropy() < m_entropy_threshold_for_stems){
continue;
}
stem_t stem = stem_iter.key();
sublexicon->add_word(stem);
}
}
sublexicon->get_word_collection()->sort_word_lists();
return sublexicon;
}