<commit_before>/*ckwg +5
 * Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
 * KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
 * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
 */

#include <vistk/pipeline/config.h>
#include <vistk/pipeline/modules.h>
#include <vistk/pipeline/process.h>
#include <vistk/pipeline/process_registry.h>

#include <boost/algorithm/string/join.hpp>
#include <boost/foreach.hpp>
#include <boost/program_options.hpp>

#include <iostream>

namespace po = boost::program_options;

static po::options_description make_options();
static void usage(po::options_description const& options);

int main(int argc, char* argv[])
{
  vistk::load_known_modules();

  po::options_description const desc = make_options();

  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);
  po::notify(vm);

  if (vm.count("help"))
  {
    usage(desc);
  }

  vistk::process_registry_t reg = vistk::process_registry::self();

  vistk::process_registry::types_t types;

  if (vm.count("type"))
  {
    types = vm["type"].as<vistk::process_registry::types_t>();
  }
  else
  {
    types = reg->types();
  }

  if (vm.count("list"))
  {
    BOOST_FOREACH (vistk::process_registry::type_t const& type, types)
    {
      std::cout << type << std::endl;
    }

    return 0;
  }

  vistk::config_t const conf = vistk::config::empty_config();

  BOOST_FOREACH (vistk::process_registry::type_t const& proc_type, types)
  {
    if (!vm.count("detail"))
    {
      std::cout << proc_type << ": " << reg->description(proc_type) << std::endl;

      continue;
    }

    std::cout << "Process type: " << proc_type << std::endl;
    std::cout << "  Description: " << reg->description(proc_type) << std::endl;

    vistk::process_t const proc = reg->create_process(proc_type, conf);

    std::cout << "  Configuration:" << std::endl;

    vistk::config::keys_t const keys = proc->available_config();

    BOOST_FOREACH (vistk::config::key_t const key, keys)
    {
      vistk::config::value_t const def = proc->config_default(key);
      vistk::config::description_t const conf_desc = proc->config_description(key);

      std::cout << "    Name       : " << key << std::endl;
      std::cout << "    Default    : " << def << std::endl;
      std::cout << "    Description: " << conf_desc << std::endl;
      std::cout << std::endl;
    }

    std::cout << "  Input ports:" << std::endl;

    vistk::process::ports_t const iports = proc->input_ports();

    BOOST_FOREACH (vistk::process::port_t const port, iports)
    {
      vistk::process::port_type_t const type = proc->input_port_type(port);
      vistk::process::port_description_t const port_desc = proc->input_port_description(port);

      vistk::process::port_type_name_t const type_name = type.get<0>();
      vistk::process::port_flags_t const flags = type.get<1>();

      std::string const flags_str = boost::join(flags, ", ");

      std::cout << "    Name       : " << port << std::endl;
      std::cout << "    Type       : " << type_name << std::endl;
      std::cout << "    Flags      : " << flags_str << std::endl;
      std::cout << "    Description: " << port_desc << std::endl;
      std::cout << std::endl;
    }

    std::cout << "  Output ports:" << std::endl;

    vistk::process::ports_t const oports = proc->output_ports();

    BOOST_FOREACH (vistk::process::port_t const port, oports)
    {
      vistk::process::port_type_t const type = proc->output_port_type(port);
      vistk::process::port_description_t const port_desc = proc->output_port_description(port);

      vistk::process::port_type_name_t const type_name = type.get<0>();
      vistk::process::port_flags_t const flags = type.get<1>();

      std::string const flags_str = boost::join(flags, ", ");

      std::cout << "    Name       : " << port << std::endl;
      std::cout << "    Type       : " << type_name << std::endl;
      std::cout << "    Flags      : " << flags_str << std::endl;
      std::cout << "    Description: " << port_desc << std::endl;
      std::cout << std::endl;
    }

    std::cout << std::endl;
    std::cout << std::endl;
  }

  return 0;
}

po::options_description
make_options()
{
  po::options_description desc;<commit_msg>Update processopedia to new process API<commit_after>/*ckwg +5
 * Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
 * KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
 * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
 */

#include <vistk/pipeline/config.h>
#include <vistk/pipeline/modules.h>
#include <vistk/pipeline/process.h>
#include <vistk/pipeline/process_registry.h>

#include <boost/algorithm/string/join.hpp>
#include <boost/foreach.hpp>
#include <boost/program_options.hpp>

#include <iostream>

namespace po = boost::program_options;

static po::options_description make_options();
static void usage(po::options_description const& options);

int main(int argc, char* argv[])
{
  vistk::load_known_modules();

  po::options_description const desc = make_options();

  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);
  po::notify(vm);

  if (vm.count("help"))
  {
    usage(desc);
  }

  vistk::process_registry_t reg = vistk::process_registry::self();

  vistk::process_registry::types_t types;

  if (vm.count("type"))
  {
    types = vm["type"].as<vistk::process_registry::types_t>();
  }
  else
  {
    types = reg->types();
  }

  if (vm.count("list"))
  {
    BOOST_FOREACH (vistk::process_registry::type_t const& type, types)
    {
      std::cout << type << std::endl;
    }

    return 0;
  }

  vistk::config_t const conf = vistk::config::empty_config();

  BOOST_FOREACH (vistk::process_registry::type_t const& proc_type, types)
  {
    if (!vm.count("detail"))
    {
      std::cout << proc_type << ": " << reg->description(proc_type) << std::endl;

      continue;
    }

    std::cout << "Process type: " << proc_type << std::endl;
    std::cout << "  Description: " << reg->description(proc_type) << std::endl;

    vistk::process_t const proc = reg->create_process(proc_type, conf);

    std::cout << "  Configuration:" << std::endl;

    vistk::config::keys_t const keys = proc->available_config();

    BOOST_FOREACH (vistk::config::key_t const key, keys)
    {
      vistk::process::conf_info_t const info = proc->config_info(key);

      vistk::config::value_t const& def = info->def;
      vistk::config::description_t const& conf_desc = info->description;

      std::cout << "    Name       : " << key << std::endl;
      std::cout << "    Default    : " << def << std::endl;
      std::cout << "    Description: " << conf_desc << std::endl;
      std::cout << std::endl;
    }

    std::cout << "  Input ports:" << std::endl;

    vistk::process::ports_t const iports = proc->input_ports();

    BOOST_FOREACH (vistk::process::port_t const port, iports)
    {
      vistk::process::port_info_t const info = proc->input_port_info(port);

      vistk::process::port_type_t const& type = info->type;
      vistk::process::port_flags_t const& flags = info->flags;
      vistk::process::port_description_t const& port_desc = info->description;

      std::string const flags_str = boost::join(flags, ", ");

      std::cout << "    Name       : " << port << std::endl;
      std::cout << "    Type       : " << type << std::endl;
      std::cout << "    Flags      : " << flags_str << std::endl;
      std::cout << "    Description: " << port_desc << std::endl;
      std::cout << std::endl;
    }

    std::cout << "  Output ports:" << std::endl;

    vistk::process::ports_t const oports = proc->output_ports();

    BOOST_FOREACH (vistk::process::port_t const port, oports)
    {
      vistk::process::port_info_t const info = proc->output_port_info(port);

      vistk::process::port_type_t const& type = info->type;
      vistk::process::port_flags_t const& flags = info->flags;
      vistk::process::port_description_t const& port_desc = info->description;

      std::string const flags_str = boost::join(flags, ", ");

      std::cout << "    Name       : " << port << std::endl;
      std::cout << "    Type       : " << type << std::endl;
      std::cout << "    Flags      : " << flags_str << std::endl;
      std::cout << "    Description: " << port_desc << std::endl;
      std::cout << std::endl;
    }

    std::cout << std::endl;
    std::cout << std::endl;
  }

  return 0;
}

po::options_description
make_options()
{
  po::options_description desc;
{'fraction_non_alphanumeric': 0.1678533909186413, 'fraction_numerical': 0.0037352632193299873, 'mean_word_length': 3.521372031662269, 'pattern_counts': {'":': 2, '<': 249, '<?xml version=': 0, '>': 56, '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': '6511114', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2783, 'n_words': 562}