<commit_before>/*=========================================================================

 Program:   ORFEO Toolbox
 Language:  C++
 Date:      $Date$
 Version:   $Revision$


 Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
 See OTBCopyright.txt for details.


 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notices for more information.

 =========================================================================*/
#include "itkMacro.h"
#include <iostream>

#include "otbConfusionMatrixToMassOfBelief.h"

int otbConfusionMatrixToMassOfBeliefNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
{
  typedef unsigned long                                   ConfusionMatrixEltType;
  typedef itk::VariableSizeMatrix<ConfusionMatrixEltType> ConfusionMatrixType;
  typedef int                                             LabelType;

  // filter types
  typedef otb::ConfusionMatrixToMassOfBelief<ConfusionMatrixType, LabelType>
      ConfusionMatrixToMassOfBelief2TemplatesType;
  typedef otb::ConfusionMatrixToMassOfBelief<ConfusionMatrixType> ConfusionMatrixToMassOfBelief1TemplateType;
  typedef otb::ConfusionMatrixToMassOfBelief<> ConfusionMatrixToMassOfBelief0TemplateType;

  // filters
  ConfusionMatrixToMassOfBelief2TemplatesType::Pointer
      confusionMatrixToMassOfBelief2Templates = ConfusionMatrixToMassOfBelief2TemplatesType::New();
  ConfusionMatrixToMassOfBelief1TemplateType::Pointer
      confusionMatrixToMassOfBelief1Template = ConfusionMatrixToMassOfBelief1TemplateType::New();
  ConfusionMatrixToMassOfBelief0TemplateType::Pointer
      confusionMatrixToMassOfBelief0Template = ConfusionMatrixToMassOfBelief0TemplateType::New();

  std::cout << confusionMatrixToMassOfBelief2Templates << std::endl;
  std::cout << std::endl;
  std::cout << confusionMatrixToMassOfBelief1Template << std::endl;
  std::cout << std::endl;
  std::cout << confusionMatrixToMassOfBelief0Template << std::endl;
  std::cout << std::endl;

  return EXIT_SUCCESS;
}


int otbConfusionMatrixToMassOfBeliefTest(int itkNotUsed(argc), char* argv[])
{
  typedef unsigned long                                   ConfusionMatrixEltType;
  typedef itk::VariableSizeMatrix<ConfusionMatrixEltType> ConfusionMatrixType;
  typedef int                                             LabelType;

  // filter type
  typedef otb::ConfusionMatrixToMassOfBelief<ConfusionMatrixType, LabelType> ConfusionMatrixToMassOfBeliefType;
  typedef ConfusionMatrixToMassOfBeliefType::MapOfClassesType                MapOfClassesType;
  typedef ConfusionMatrixToMassOfBeliefType::MassOfBeliefDefinitionMethod    MassOfBeliefDefinitionMethod;
  typedef ConfusionMatrixToMassOfBeliefType::LabelMassMapType                SingleClassLabelMassMapType;

  // mapOfClasses[label] = index in the rows/columns of the confusion matrix
  MapOfClassesType mapOfClasses;
  mapOfClasses[1] = 0;
  mapOfClasses[2] = 1;
  mapOfClasses[3] = 2;
  mapOfClasses[4] = 3;

  unsigned int nbClasses = mapOfClasses.size();
  ConfusionMatrixType confMat = ConfusionMatrixType(nbClasses, nbClasses);
  confMat(0, 0) = 1, confMat(0, 1) = 0, confMat(0, 2) = 0, confMat(0, 3) = 2;
  confMat(1, 0) = 0, confMat(1, 1) = 1, confMat(1, 2) = 1, confMat(1, 3) = 1;
  confMat(2, 0) = 0, confMat(2, 1) = 0, confMat(2, 2) = 2, confMat(2, 3) = 1;
  confMat(3, 0) = 0, confMat(3, 1) = 0, confMat(3, 2) = 1, confMat(3, 3) = 2;
  std::cout << "confusion matrix = " << std::endl << confMat << std::endl;


  // Converting the Confusion Matrix into a std::map<ClassLabelType, MassType> of Masses of Belief for each label
  ConfusionMatrixToMassOfBeliefType::Pointer confMatToMass = ConfusionMatrixToMassOfBeliefType::New();
  MassOfBeliefDefinitionMethod massOfBeliefDefMethod;

  std::string massOfBeliefDefMethodStr = argv[1];
  if (massOfBeliefDefMethodStr.compare("PRECISION") == 0)
    {
    massOfBeliefDefMethod = ConfusionMatrixToMassOfBeliefType::PRECISION;
    }
  else
    {<commit_msg>COV: Fixing coverity issue 1266613 (Uninitialized scalar variable)<commit_after>/*=========================================================================

 Program:   ORFEO Toolbox
 Language:  C++
 Date:      $Date$
 Version:   $Revision$


 Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
 See OTBCopyright.txt for details.


 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notices for more information.

 =========================================================================*/
#include "itkMacro.h"
#include <iostream>

#include "otbConfusionMatrixToMassOfBelief.h"

int otbConfusionMatrixToMassOfBeliefNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
{
  typedef unsigned long                                   ConfusionMatrixEltType;
  typedef itk::VariableSizeMatrix<ConfusionMatrixEltType> ConfusionMatrixType;
  typedef int                                             LabelType;

  // filter types
  typedef otb::ConfusionMatrixToMassOfBelief<ConfusionMatrixType, LabelType>
      ConfusionMatrixToMassOfBelief2TemplatesType;
  typedef otb::ConfusionMatrixToMassOfBelief<ConfusionMatrixType> ConfusionMatrixToMassOfBelief1TemplateType;
  typedef otb::ConfusionMatrixToMassOfBelief<> ConfusionMatrixToMassOfBelief0TemplateType;

  // filters
  ConfusionMatrixToMassOfBelief2TemplatesType::Pointer
      confusionMatrixToMassOfBelief2Templates = ConfusionMatrixToMassOfBelief2TemplatesType::New();
  ConfusionMatrixToMassOfBelief1TemplateType::Pointer
      confusionMatrixToMassOfBelief1Template = ConfusionMatrixToMassOfBelief1TemplateType::New();
  ConfusionMatrixToMassOfBelief0TemplateType::Pointer
      confusionMatrixToMassOfBelief0Template = ConfusionMatrixToMassOfBelief0TemplateType::New();

  std::cout << confusionMatrixToMassOfBelief2Templates << std::endl;
  std::cout << std::endl;
  std::cout << confusionMatrixToMassOfBelief1Template << std::endl;
  std::cout << std::endl;
  std::cout << confusionMatrixToMassOfBelief0Template << std::endl;
  std::cout << std::endl;

  return EXIT_SUCCESS;
}


int otbConfusionMatrixToMassOfBeliefTest(int itkNotUsed(argc), char* argv[])
{
  typedef unsigned long                                   ConfusionMatrixEltType;
  typedef itk::VariableSizeMatrix<ConfusionMatrixEltType> ConfusionMatrixType;
  typedef int                                             LabelType;

  // filter type
  typedef otb::ConfusionMatrixToMassOfBelief<ConfusionMatrixType, LabelType> ConfusionMatrixToMassOfBeliefType;
  typedef ConfusionMatrixToMassOfBeliefType::MapOfClassesType                MapOfClassesType;
  typedef ConfusionMatrixToMassOfBeliefType::MassOfBeliefDefinitionMethod    MassOfBeliefDefinitionMethod;
  typedef ConfusionMatrixToMassOfBeliefType::LabelMassMapType                SingleClassLabelMassMapType;

  // mapOfClasses[label] = index in the rows/columns of the confusion matrix
  MapOfClassesType mapOfClasses;
  mapOfClasses[1] = 0;
  mapOfClasses[2] = 1;
  mapOfClasses[3] = 2;
  mapOfClasses[4] = 3;

  unsigned int nbClasses = mapOfClasses.size();
  ConfusionMatrixType confMat = ConfusionMatrixType(nbClasses, nbClasses);
  confMat(0, 0) = 1, confMat(0, 1) = 0, confMat(0, 2) = 0, confMat(0, 3) = 2;
  confMat(1, 0) = 0, confMat(1, 1) = 1, confMat(1, 2) = 1, confMat(1, 3) = 1;
  confMat(2, 0) = 0, confMat(2, 1) = 0, confMat(2, 2) = 2, confMat(2, 3) = 1;
  confMat(3, 0) = 0, confMat(3, 1) = 0, confMat(3, 2) = 1, confMat(3, 3) = 2;
  std::cout << "confusion matrix = " << std::endl << confMat << std::endl;


  // Converting the Confusion Matrix into a std::map<ClassLabelType, MassType> of Masses of Belief for each label
  ConfusionMatrixToMassOfBeliefType::Pointer confMatToMass = ConfusionMatrixToMassOfBeliefType::New();
  MassOfBeliefDefinitionMethod massOfBeliefDefMethod = ConfusionMatrixToMassOfBeliefType::PRECISION;

  std::string massOfBeliefDefMethodStr = argv[1];
  if (massOfBeliefDefMethodStr.compare("PRECISION") == 0)
    {
    massOfBeliefDefMethod = ConfusionMatrixToMassOfBeliefType::PRECISION;
    }
  else
    {
{'fraction_non_alphanumeric': 0.12186815859888105, 'fraction_numerical': 0.018608611043541716, 'mean_word_length': 4.907327586206897, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5449195', 'n_tokens_mistral': 2565, 'n_tokens_neox': 2420, 'n_words': 510}