<commit_before>#include "datasets.hpp"

#include <iostream>
#include <iomanip>


#include "data/attribute/constants.hpp"
#include "data/dictionary/dictionary.hpp"
#include "data/dictionary/dictionary_entry.hpp"

#include "dataset_iterator.hpp"

namespace dicom
{

namespace data
{

namespace dataset
{


using namespace attribute;


std::ostream& operator<<(std::ostream& os, const dataset_type& data)
{

   int depth = 0;
   for (const auto attr : dataset_iterator_adaptor(data)) {
      if (attr.first == Item) {
         depth++;
      }

      std::fill_n(std::ostream_iterator<char>(os), depth, '\t');

      os << attr.first << " ";
      if (attr.second.value_rep.is_initialized()
          && attr.second.value_rep.get() != VR::NN
          && attr.second.value_rep.get() != VR::NI) {
         os << dictionary::dictionary_entry::vr_of_string.right.at(attr.second.value_rep.get());
      } else {
         os << "(unknown) NN / NI";
      }
      if (attr.first != SequenceDelimitationItem
          && attr.first != ItemDelimitationItem
          && attr.first != Item
          && attr.second.value_rep.is_initialized()
          && attr.second.value_rep.get() != VR::SQ
          && attr.second.value_rep.get() != VR::NN
          && attr.second.value_rep.get() != VR::NI) {
         os << " " << attr.second.value_len << "\t\t";
         attr.second.value_field->print(os);
      }
      os << "\n";

      if (attr.first == ItemDelimitationItem) {
         depth--;
      }
   }

   return os;
}

std::size_t dataset_size(dataset_type data, bool explicitvr)
{
   return std::accumulate(data.begin(), data.end(), 0,
      [explicitvr](int acc, const std::pair<const elementfield::tag_type, elementfield>& attr) {
      return acc += attr.second.value_len + 4 + 4
            + (explicitvr ? 2 : 0);
   });
}


std::ostream& operator<<(std::ostream& os, DIMSE_SERVICE_GROUP dsg)
{
    switch (dsg) {
        case DIMSE_SERVICE_GROUP::C_STORE_RQ:
            return os << "C-STORE-RQ";<commit_msg>print length of sequence items<commit_after>#include "datasets.hpp"

#include <iostream>
#include <iomanip>


#include "data/attribute/constants.hpp"
#include "data/dictionary/dictionary.hpp"
#include "data/dictionary/dictionary_entry.hpp"

#include "dataset_iterator.hpp"

namespace dicom
{

namespace data
{

namespace dataset
{


using namespace attribute;


std::ostream& operator<<(std::ostream& os, const dataset_type& data)
{

   int depth = 0;
   for (const auto attr : dataset_iterator_adaptor(data)) {
      if (attr.first == Item) {
         depth++;
      }

      std::fill_n(std::ostream_iterator<char>(os), depth, '\t');

      os << attr.first << " ";
      if (attr.second.value_rep.is_initialized()
          && attr.second.value_rep.get() != VR::NN
          && attr.second.value_rep.get() != VR::NI) {
         os << dictionary::dictionary_entry::vr_of_string.right.at(attr.second.value_rep.get());
      } else {
         os << "(unknown) NN / NI";
      }
      if (attr.first != SequenceDelimitationItem
          && attr.first != ItemDelimitationItem
          && attr.first != Item
          && attr.second.value_rep.is_initialized()
          && attr.second.value_rep.get() != VR::NN
          && attr.second.value_rep.get() != VR::NI) {
         if (attr.second.value_rep.get() == VR::SQ ) {
            os << " " << attr.second.value_len;
            if ((attr.second.value_len & 0xffffffff) == 0xffffffff) {
               os << "(undefined length)";
            }
            os << "\t\t";
         } else {
            os << " " << attr.second.value_len << "\t\t";
            attr.second.value_field->print(os);
         }
      }
      os << "\n";

      if (attr.first == ItemDelimitationItem) {
         depth--;
      }
   }

   return os;
}

std::size_t dataset_size(dataset_type data, bool explicitvr)
{
   return std::accumulate(data.begin(), data.end(), 0,
      [explicitvr](int acc, const std::pair<const elementfield::tag_type, elementfield>& attr) {
      return acc += attr.second.value_len + 4 + 4
            + (explicitvr ? 2 : 0);
   });
}


std::ostream& operator<<(std::ostream& os, DIMSE_SERVICE_GROUP dsg)
{
    switch (dsg) {
        case DIMSE_SERVICE_GROUP::C_STORE_RQ:
            return os << "C-STORE-RQ";
{'fraction_non_alphanumeric': 0.15968157340201358, 'fraction_numerical': 0.003277920861624912, 'mean_word_length': 2.577889447236181, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6793398', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1387, 'n_words': 258}