première version
This commit is contained in:
33
include/Context.hpp
Normal file
33
include/Context.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* @file Context.hpp
|
||||
* @brief calcul de fréquence et prédiction
|
||||
* @author F. Merciol
|
||||
* @version 0.1
|
||||
* @date 18 / août 2023
|
||||
*/
|
||||
#ifndef _Context_hpp_
|
||||
#define _Context_hpp_
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// ========================================
|
||||
class Context {
|
||||
string prev;
|
||||
static const int prevSize;
|
||||
static const string end;
|
||||
static const string sep;
|
||||
public:
|
||||
static bool validChar (const char &c);
|
||||
static bool isEnd (const string &c);
|
||||
static bool isSep (const string &c);
|
||||
bool empty () { return prev.empty (); }
|
||||
void reset () { prev.clear (); }
|
||||
string getState () { return prev; }
|
||||
void forward (string current);
|
||||
};
|
||||
|
||||
// ========================================
|
||||
#endif // _Context_hpp_
|
30
include/LexFreq.hpp
Normal file
30
include/LexFreq.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*!
|
||||
* @file LexFreq.hpp
|
||||
* @brief calcul de fréquence et prédiction
|
||||
* @author F. Merciol
|
||||
* @version 0.1
|
||||
* @date 18 / août 2023
|
||||
*/
|
||||
#ifndef _LexFreq_hpp_
|
||||
#define _LexFreq_hpp_
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// ========================================
|
||||
class LexFreq {
|
||||
long size;
|
||||
map<string, long> hist;
|
||||
public:
|
||||
friend ostream& operator << (ostream& os, const LexFreq &freqLex);
|
||||
|
||||
LexFreq ();
|
||||
long getSize () const { return hist.size (); }
|
||||
void addChar (const string &c);
|
||||
string getChar () const;
|
||||
};
|
||||
|
||||
// ========================================
|
||||
#endif // _LexFreq_hpp_
|
32
include/TextProdChar.hpp
Normal file
32
include/TextProdChar.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*!
|
||||
* @file TextProdChar.hpp
|
||||
* @brief calcul de fréquence et prédiction
|
||||
* @author F. Merciol
|
||||
* @version 0.1
|
||||
* @date 18 / août 2023
|
||||
*/
|
||||
#ifndef _TextProdChar_hpp_
|
||||
#define _TextProdChar_hpp_
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "Context.hpp"
|
||||
#include "LexFreq.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// ========================================
|
||||
class TextProdChar {
|
||||
Context context;
|
||||
map<string, LexFreq> prevFreq;
|
||||
public:
|
||||
friend ostream& operator << (ostream& os, const TextProdChar &ia);
|
||||
|
||||
void learn (istream &in);
|
||||
void prod (ostream &out, const long &size);
|
||||
};
|
||||
|
||||
|
||||
// ========================================
|
||||
#endif // _TextProdChar_hpp_
|
Reference in New Issue
Block a user