<commit_before>#ifndef __VALUES_HANDLER_H__
#define __VALUES_HANDLER_H__

#include <json/json.h>

#include "Handler.h"
#include "image/Image.h"

class ValuesHandler : public Handler {

public:

  virtual void handle(Image& image, Json::Value& modification) {

    Json::Value& options = modification["options"];

    const std::string type = options["type"].asString();

    if      (type == "scale") { scale(image, options); }
    else if (type == "normalize" ) { normalize(image); }
    else if( type == "discard" ) { discard(image, options); }

  }

  void scale(Image& image, Json::Value& options) {

    const double minNew = options["minNew"].asDouble();
    const double maxNew = options["maxNew"].asDouble();

    image.values().scale(minNew, maxNew);

  }

  void normalize(Image& image) {

    image.values().normalize();

  }

  void discard(Image& image, Json::Value& options) {

    const int lower = options["lower"].asInt();
    const int upper = options["upper"].asInt();

    image.values().discard_values(lower, upper);

  }

};
#endif<commit_msg>adapted tool to new API<commit_after>#ifndef __VALUES_HANDLER_H__
#define __VALUES_HANDLER_H__

#include <json/json.h>

#include "Handler.h"
#include "image/Image.h"

class ValuesHandler : public Handler {

public:

  virtual void handle(Image& image, Json::Value& modification) {

    Json::Value& options = modification["options"];

    const std::string type = options["type"].asString();

    if      (type == "scale") { scale(image, options); }
    else if (type == "normalize" ) { normalize(image); }
    else if( type == "discard" ) { discard(image, options); }

  }

  void scale(Image& image, Json::Value& options) {

    const double minNew = options["minNew"].asDouble();
    const double maxNew = options["maxNew"].asDouble();

    image.values().scale(minNew, maxNew);

  }

  void normalize(Image& image) {

    image.values().normalize();

  }

  void discard(Image& image, Json::Value& options) {

    const int lower = options["lower"].asInt();
    const int upper = options["upper"].asInt();

    image.values().discard(lower, upper);

  }

};
#endif
{'fraction_non_alphanumeric': 0.16033755274261605, 'fraction_numerical': 0.0, 'mean_word_length': 3.9743589743589745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5513029', 'n_tokens_mistral': 709, 'n_tokens_neox': 663, 'n_words': 161}