Skip to content

Commit

Permalink
WIP step 4
Browse files Browse the repository at this point in the history
  • Loading branch information
marcboulle committed Oct 6, 2023
1 parent ccce86f commit d4b80d1
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Learning/DTForest/DTGrouperMODLInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DTGrouperMODLTwoClasses : public KWDiscretizerMODL // public DTDiscretizer
IntVector*& ivGroups) const;

// Nom de l'algorithme
const ALString GetName() const;
const ALString GetName() const override;

/////////////////////////////////////////////////////////////////
//// Implementation
Expand Down
2 changes: 0 additions & 2 deletions src/Learning/KWDataPreparation/KWDataGridOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,6 @@ double KWDataGridVNSOptimizer::PROTO_VNSDataGridPostOptimizeVarPart(
neighbourDataGrid->Write(cout);
cout << "Grille apres fusion\n";
mergedDataGrid->Write(cout);
debug(false);
}

// Post-optimisation de l'attribut VarPart uniquement dans le cas d'une optimisation approfondie
Expand Down Expand Up @@ -2086,7 +2085,6 @@ double KWDataGridVNSOptimizer::VNSOptimizeVarPartDataGrid(const KWDataGrid* init
neighbourDataGrid.Write(cout);
cout << "Grille apres fusion\n";
mergedDataGrid.Write(cout);
debug(false);
}

// Post-optimisation de l'attribut VarPart uniquement dans le cas d'une optimisation approfondie
Expand Down
2 changes: 1 addition & 1 deletion src/Learning/KWDataPreparation/KWGrouperMODLInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class KWGrouperMODLTwoClasses : public KWDiscretizerMODL
IntVector*& ivGroups) const;

// Nom de l'algorithme
const ALString GetName() const;
const ALString GetName() const override;

/////////////////////////////////////////////////////////////////
//// Implementation
Expand Down
8 changes: 4 additions & 4 deletions src/Learning/KWModeling/KWPredictorBaseline.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ class KWPredictorBaseline : public KWPredictorNaiveBayes
~KWPredictorBaseline();

// Constructeur generique
KWPredictor* Create() const;
KWPredictor* Create() const override;

// Nom du classifier
const ALString GetName() const;
const ALString GetName() const override;

// Prefixe du predicteur
const ALString GetPrefix() const;
const ALString GetPrefix() const override;

/////////////////////////////////////////////////////////
//// Implementation
protected:
// Redefinition de la methode d'apprentissage
boolean InternalTrain();
boolean InternalTrain() override;
};
13 changes: 7 additions & 6 deletions src/Learning/KWTest/CreateLargeFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void CopyFileTwiceThenConcatenate(const ALString& sPathName, boolean bFast)
longint lPosition;
const int nBufferLength = MemSegmentByteSize;
char sBuffer[nBufferLength];
int nByteReadNumber;
FILE* fFile;
FILE* fCopy1;
FILE* fCopy2;
Expand Down Expand Up @@ -284,14 +285,14 @@ void CopyFileTwiceThenConcatenate(const ALString& sPathName, boolean bFast)
{
if (lPosition + nBufferLength < lFileSize)
{
fread(sBuffer, sizeof(char), nBufferLength, fFile);
nByteReadNumber = (int)fread(sBuffer, sizeof(char), nBufferLength, fFile);
fwrite(sBuffer, sizeof(char), nBufferLength, fCopy1);
fwrite(sBuffer, sizeof(char), nBufferLength, fCopy2);
lPosition += nBufferLength;
}
else
{
fread(sBuffer, sizeof(char), int(lFileSize - lPosition), fFile);
nByteReadNumber = (int)fread(sBuffer, sizeof(char), int(lFileSize - lPosition), fFile);
fwrite(sBuffer, sizeof(char), int(lFileSize - lPosition), fCopy1);
fwrite(sBuffer, sizeof(char), int(lFileSize - lPosition), fCopy2);
lPosition = lFileSize;
Expand Down Expand Up @@ -337,13 +338,13 @@ void CopyFileTwiceThenConcatenate(const ALString& sPathName, boolean bFast)
{
if (lPosition + nBufferLength < lFileSize)
{
fread(sBuffer, sizeof(char), nBufferLength, fCopy1);
nByteReadNumber = (int)fread(sBuffer, sizeof(char), nBufferLength, fCopy1);
fwrite(sBuffer, sizeof(char), nBufferLength, fConcat);
lPosition += nBufferLength;
}
else
{
fread(sBuffer, sizeof(char), int(lFileSize - lPosition), fCopy1);
nByteReadNumber = (int)fread(sBuffer, sizeof(char), int(lFileSize - lPosition), fCopy1);
fwrite(sBuffer, sizeof(char), int(lFileSize - lPosition), fConcat);
lPosition = lFileSize;
}
Expand All @@ -357,13 +358,13 @@ void CopyFileTwiceThenConcatenate(const ALString& sPathName, boolean bFast)
{
if (lPosition + nBufferLength < lFileSize)
{
fread(sBuffer, sizeof(char), nBufferLength, fCopy2);
nByteReadNumber = (int)fread(sBuffer, sizeof(char), nBufferLength, fCopy2);
fwrite(sBuffer, sizeof(char), nBufferLength, fConcat);
lPosition += nBufferLength;
}
else
{
fread(sBuffer, sizeof(char), int(lFileSize - lPosition), fCopy2);
nByteReadNumber = (int)fread(sBuffer, sizeof(char), int(lFileSize - lPosition), fCopy2);
fwrite(sBuffer, sizeof(char), int(lFileSize - lPosition), fConcat);
lPosition = lFileSize;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Learning/KWTest/KWDataGridTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class KWSGGaussianMixture : public KWSampleGenerator
~KWSGGaussianMixture();

// Redefinition des methodes virtuelles
const ALString GetName() const;
const ALString GetName() const override;
void GenerateObjectValues(KWObject* kwoObject) override;

// Parametres de la Gaussienne pour la classe '-' (par defaut: moyenne = (-1 -1) et ecart type = (1 1))
Expand Down
14 changes: 7 additions & 7 deletions src/Learning/KWTest/KWHierarchicalMultinomialStudy.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,24 @@ class KWDataGridClusteringCostsBivariate : public KWDataGridCosts
// La taille de la grille est donnee par son log, pour ne pas depasser les limites informatiques
// Les attributs informatifs sont ceux ayant strictement plus de une partie
double ComputeDataGridCost(const KWDataGrid* dataGrid, double dLnGridSize,
int nInformativeAttributeNumber) const;
int nInformativeAttributeNumber) const override;

// Calcul du cout local d'un attribut, pour un nombre de parties donnees
// Le nombre de parties est le nombre total de parties.
// En cas de presence d'une poubelle il s'agit du nombre de parties informatives de l'attribut + 1
double ComputeAttributeCost(const KWDGAttribute* attribute, int nPartitionSize) const;
double ComputeAttributeCost(const KWDGAttribute* attribute, int nPartitionSize) const override;

// Calcul du cout local d'une partie
double ComputePartCost(const KWDGPart* part) const;
double ComputePartCost(const KWDGPart* part) const override;

// Calcul du cout local de l'union de deux parties
double ComputePartUnionCost(const KWDGPart* part1, const KWDGPart* part2) const;
double ComputePartUnionCost(const KWDGPart* part1, const KWDGPart* part2) const override;

// Calcul du cout local d'une cellule
double ComputeCellCost(const KWDGCell* cell) const;
double ComputeCellCost(const KWDGCell* cell) const override;

// Calcul du cout local d'une valeur d'un attribut symbolique
double ComputeValueCost(const KWDGValue* value) const;
double ComputeValueCost(const KWDGValue* value) const override;

// Libelle de la classe
const ALString GetClassLabel() const override;
Expand All @@ -192,7 +192,7 @@ class KWDataGridClusteringCostsBivariateH : public KWDataGridClusteringCostsBiva

// Calcul du cout local d'un DataGrid, selon le prior hierarchique
double ComputeDataGridCost(const KWDataGrid* dataGrid, double dLnGridSize,
int nInformativeAttributeNumber) const;
int nInformativeAttributeNumber) const override;

// Libelle de la classe
const ALString GetClassLabel() const override;
Expand Down
4 changes: 4 additions & 0 deletions src/Learning/KWTest/KWTextParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ void KWTextParser::BuildLineWordDictionary(char* sLine, ObjectDictionary* odWord
// Transformation des caracteres accentues
if (bFilterAccentuation)
{
// Compilation uniquement sous windows pour cette methode prototype,
// pour eviter les warnings de type illegal character encoding
#ifdef _WIN32
if (cLineChar == 'é')
cLineChar = 'e';
else if (cLineChar == 'è')
Expand Down Expand Up @@ -421,6 +424,7 @@ void KWTextParser::BuildLineWordDictionary(char* sLine, ObjectDictionary* odWord
cLineChar = 'u';
else if (cLineChar == 'ç')
cLineChar = 'c';
#endif // _WIN32
}

// Traitement du caractere en fonction de l'etat courant
Expand Down
4 changes: 3 additions & 1 deletion src/Learning/KWTest/SystemDivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ int OpenPdfFile(char* sPdfFilePathName)
return ((int)nRet>32);
*/
char sCommand[1000];
int nResult;

snprintf(sCommand, sizeof(sCommand), "start %s", sPdfFilePathName);
system(sCommand);
nResult = system(sCommand);
return 0;
}
10 changes: 5 additions & 5 deletions src/Learning/KWUserInterface/KWPredictorEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ class KWPredictorExternal : public KWPredictor
~KWPredictorExternal();

// Type de predicteur disponible: classification et regression
boolean IsTargetTypeManaged(int nType) const;
boolean IsTargetTypeManaged(int nType) const override;

// Constructeur generique
KWPredictor* Create() const;
KWPredictor* Create() const override;

// Nom du predicteur
const ALString GetName() const;
const ALString GetName() const override;

// Prefixe du predicteur
const ALString GetPrefix() const;
const ALString GetPrefix() const override;

// Parametrage du predicteur par un objet KWTrainedPredictor externe
// Memoire: le KWTrainedPredictor appartient a l'appele
Expand All @@ -214,7 +214,7 @@ class KWPredictorExternal : public KWPredictor
//// Implementation
protected:
// Redefinition de la methode d'apprentissage
boolean InternalTrain();
boolean InternalTrain() override;

// Memorisation
KWTrainedPredictor* externalTrainedPredictor;
Expand Down
10 changes: 5 additions & 5 deletions src/Learning/samples/sample2/CMMajorityClassifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CMMajorityClassifier : public KWPredictorNaiveBayes
// KWType::Symbol: classification
// KWType::Continuous: regression
// KWType::None: non supervise
boolean IsTargetTypeManaged(int nType) const;
boolean IsTargetTypeManaged(int nType) const override;

// Creation pour renvoyer une instance du meme type dynamique
// Doit etre reimplementer dans les sous-classes
Expand All @@ -37,20 +37,20 @@ class CMMajorityClassifier : public KWPredictorNaiveBayes
// {
// return new KWSpecificPredictor;
// }
KWPredictor* Create() const;
KWPredictor* Create() const override;

// Nom du predicteur
// Doit etre reimplementer dans les sous-classes
const ALString GetName() const;
const ALString GetName() const override;

// Prefixe du predicteur, utilisable pour le nommage de la classe en deploiement (par defaut: "P_")
const ALString GetPrefix() const;
const ALString GetPrefix() const override;

///////////////////////////////////////////////////////
//// Implementation
protected:
// Redefinition de la methode d'apprentissage
boolean InternalTrain();
boolean InternalTrain() override;

// Construction d'un predicteur bayesien naif a partir d'un tableau d'attributs prepares
// La methode filtre les attributs inutiles (partition source singleton ou poids nul)
Expand Down
2 changes: 1 addition & 1 deletion src/Norm/base/ALString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Pour une chaine vide, les donnees vont pointer ici
// Cela permet d'eviter de nombreux tests de pointeur à NULL lors de
// l'appel des fonction de la librairie C standard
char* ALSCHARNIL = '\0';
char ALSCHARNIL = '\0';

extern const ALString ALSEmptyString;

Expand Down

0 comments on commit d4b80d1

Please sign in to comment.