Updated German translation
[dasher.git] / Src / DasherCore / Trainer.h
blob4e2094d8d6c815437d423b4d5fa467894585cd58
1 #ifndef __trainer_h__
2 #define __trainer_h__
4 #include "LanguageModelling/PPMPYLanguageModel.h"
5 #include "Alphabet/AlphInfo.h"
6 #include "AbstractXMLParser.h"
8 namespace Dasher {
9 class CTrainer : public AbstractParser {
11 public:
12 CTrainer(CMessageDisplay *pMsgs, CLanguageModel *pLanguageModel, const CAlphInfo *pInfo, const CAlphabetMap *pAlphabet);
13 virtual ~CTrainer();
14 class ProgressIndicator {
15 public:
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);
24 protected:
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!)
49 int m_iCtxEsc;
50 private:
51 ProgressIndicator *m_pProg;
52 std::string m_strDesc;
57 #endif