4 #include "LanguageModelling/PPMPYLanguageModel.h"
5 #include "Alphabet/AlphInfo.h"
6 #include "AbstractXMLParser.h"
9 class CTrainer
: public AbstractParser
{
12 CTrainer(CMessageDisplay
*pMsgs
, CLanguageModel
*pLanguageModel
, const CAlphInfo
*pInfo
, const CAlphabetMap
*pAlphabet
);
14 class ProgressIndicator
{
16 virtual void bytesRead(off_t
)=0;
19 void SetProgressIndicator(ProgressIndicator
*pProg
) {m_pProg
= pProg
;}
21 ///Parses a text file; bUser ignored.
22 bool Parse(const std::string
&strDesc
, std::istream
&in
, bool bUser
);
26 virtual void Train(CAlphabetMap::SymbolStream
&syms
);
28 ///Try to read a context-switch escape sequence from the symbolstream.
29 /// \param sContext context to be reinitialized if a context-switch command is found
30 /// \param sym symbol that was most recently read from stream, i.e. that
31 /// might be the start of the context-switch command
32 /// \syms symbolstream to read body of command from, if necessary; should be positioned
33 /// just after the first occurrence of the escape character.
34 /// \return true if a context-switch command was found (=> sContext reinitialized);
35 /// false if the character was not a context-switch; specifically, if there was a
36 /// double context-switch character, meaning that an actual occurrence of that
37 /// character is desired to be fed into the LanguageModel, this method returns false
38 /// with the stream positioned just after the second ctx-switch character
39 /// (ready to continue reading as per normal)
40 bool readEscape(CLanguageModel::Context
&sContext
, symbol sym
, CAlphabetMap::SymbolStream
&syms
);
42 ///Returns the description of the file as passed to Parse()
43 /// (usually a filename)
44 const std::string
&GetDesc() {return m_strDesc
;}
45 const CAlphabetMap
* const m_pAlphabet
;
46 CLanguageModel
* const m_pLanguageModel
;
47 const CAlphInfo
* const m_pInfo
;
48 // symbol number in alphabet of the context-switch character (maybe 0 if not in alphabet!)
51 ProgressIndicator
*m_pProg
;
52 std::string m_strDesc
;