1 // Syllabification using Dynamic Computational Networks
2 // Copyright © 2009 The University of Chicago
3 #include "DCNcorpussyl.h"
4 #include <Q3TextStream>
7 //////////////////////////////////////////////////////////////////////
8 // Construction/Destruction
9 //////////////////////////////////////////////////////////////////////
11 corpussyl::corpussyl()
16 corpussyl::~corpussyl()
21 void corpussyl::readInput(QFile
&file
)
23 if ( file
.open( QIODevice::ReadOnly
) )
25 Q3TextStream
stream( &file
);
28 while ( !stream
.atEnd() ) {
29 line
= stream
.readLine(); // line of text excluding '\n'
31 word
.setText(line
.section('\t', 0, 0));
32 word
.setMaxima(line
.section('\t', 1, 1));
34 m_wordVector
.push_back(word
);
41 void corpussyl::printCorpus(QLabel
*label
, grammarsyl
*gram
)
46 QString corpus
= gram
->print() + "\n\n";
48 Q3ValueVector
<dcnword
>::const_iterator it
= m_wordVector
.begin();
49 Q3ValueVector
<dcnword
>::const_iterator end
= m_wordVector
.end();
53 QString targText
= it
->getText();
54 QString targMaxima
= it
->getMaxima();
56 net
.setWord(targText
);
58 QString expText
= net
.getSyllabifiedWord();
59 QString expMaxima
= net
.getMaxima();
60 corpus
+= targText
+ "\t" + targMaxima
+ "\t\t" + expText
+ "\t\t"
65 label
->setText(corpus
);
69 QString
corpussyl::printCorpus(grammarsyl
*gram
)
76 Q3ValueVector
<dcnword
>::const_iterator it
= m_wordVector
.begin();
77 Q3ValueVector
<dcnword
>::const_iterator end
= m_wordVector
.end();
81 QString targText
= it
->getText();
82 QString targMaxima
= it
->getMaxima();
84 net
.setWord(targText
);
86 QString expText
= net
.getSyllabifiedWord();
87 QString expMaxima
= net
.getMaxima();
88 corpus
+= targText
+ "\t\t" + targMaxima
+ "\n" + expText
+ "\t\t"
96 dcnword
corpussyl::wordAt(uint index
) const
98 return m_wordVector
.at(index
);