<commit_before>// Copyright 2016 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "std-funcs.h"

#include "utils/check.h"
#include "utils/glob.h"

namespace shpp {
namespace internal {
namespace module {
namespace stdf {

ObjectPtr PrintFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  for (auto& e: params) {
    std::cout << e->Print();
  }

  std::cout << std::endl;

  return obj_factory_.NewNull();
}

ObjectPtr PrintErrFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  for (auto& e: params) {
    std::cerr << e->Print();
  }

  std::cerr << std::endl;

  return obj_factory_.NewNull();
}

ObjectPtr ReadFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  SHPP_FUNC_CHECK_PARAM_TYPE(params[0], path, STRING)

  std::string str;

  std::cout << static_cast<StringObject&>(*params[0]).value();
  std::cin >> str;

  return obj_factory_.NewString(str);
}

ObjectPtr LenFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  SHPP_FUNC_CHECK_NUM_PARAMS(params, 1, len)

  long int size = params[0]->Len();

  return obj_factory_.NewInt(static_cast<int>(size));
}

ObjectPtr CompFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  SHPP_FUNC_CHECK_NUM_PARAMS(params, 2, comp)

  ObjectPtr obj_resp = params[0]->Lesser(params[1]);
<commit_msg>fix read function<commit_after>// Copyright 2016 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "std-funcs.h"

#include "utils/check.h"
#include "utils/glob.h"

namespace shpp {
namespace internal {
namespace module {
namespace stdf {

ObjectPtr PrintFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  for (auto& e: params) {
    std::cout << e->Print();
  }

  std::cout << std::endl;

  return obj_factory_.NewNull();
}

ObjectPtr PrintErrFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  for (auto& e: params) {
    std::cerr << e->Print();
  }

  std::cerr << std::endl;

  return obj_factory_.NewNull();
}

ObjectPtr ReadFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  SHPP_FUNC_CHECK_NUM_PARAMS_UNTIL(params, 1, read)

  if (params.size()  == 1) {
    SHPP_FUNC_CHECK_PARAM_TYPE(params[0], prompt, STRING)
    std::cout << static_cast<StringObject&>(*params[0]).value();
  }

  std::string str;

  if (!(std::cin >> str)) {
    return obj_factory_.NewNull();
  }

  return obj_factory_.NewString(str);
}

ObjectPtr LenFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  SHPP_FUNC_CHECK_NUM_PARAMS(params, 1, len)

  long int size = params[0]->Len();

  return obj_factory_.NewInt(static_cast<int>(size));
}

ObjectPtr CompFunc::Call(Executor*, std::vector<ObjectPtr>&& params) {
  SHPP_FUNC_CHECK_NUM_PARAMS(params, 2, comp)

  ObjectPtr obj_resp = params[0]->Lesser(params[1]);

{'fraction_non_alphanumeric': 0.1464, 'fraction_numerical': 0.008533333333333334, 'mean_word_length': 4.590163934426229, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4117610', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1190, 'n_words': 335}