Sha256: d20f782981630dc077b1402b3d7b58ae549edb3c6c6d1c79acc67f601fccc709

Contents?: true

Size: 1.68 KB

Versions: 8

Compression:

Stored size: 1.68 KB

Contents

/**
 * Copyright (c) 2016-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#pragma once

#include "real.h"

#include <algorithm>
#include <chrono>
#include <fstream>
#include <ostream>
#include <vector>

#if defined(__clang__) || defined(__GNUC__)
#define FASTTEXT_DEPRECATED(msg) __attribute__((__deprecated__(msg)))
#elif defined(_MSC_VER)
#define FASTTEXT_DEPRECATED(msg) __declspec(deprecated(msg))
#else
#define FASTTEXT_DEPRECATED(msg)
#endif

namespace fasttext {

using Predictions = std::vector<std::pair<real, int32_t>>;

namespace utils {

int64_t size(std::ifstream&);

void seek(std::ifstream&, int64_t);

template <typename T>
bool contains(const std::vector<T>& container, const T& value) {
  return std::find(container.begin(), container.end(), value) !=
      container.end();
}

template <typename T1, typename T2>
bool containsSecond(
    const std::vector<std::pair<T1, T2>>& container,
    const T2& value) {
  return std::find_if(
             container.begin(),
             container.end(),
             [&value](const std::pair<T1, T2>& item) {
               return item.second == value;
             }) != container.end();
}

double getDuration(
    const std::chrono::steady_clock::time_point& start,
    const std::chrono::steady_clock::time_point& end);

class ClockPrint {
 public:
  explicit ClockPrint(int32_t duration);
  friend std::ostream& operator<<(std::ostream& out, const ClockPrint& me);

 private:
  int32_t duration_;
};

bool compareFirstLess(const std::pair<double, double>& l, const double& r);

} // namespace utils

} // namespace fasttext

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fasttext-0.4.0 vendor/fastText/src/utils.h
fasttext-0.3.0 vendor/fastText/src/utils.h
fasttext-0.2.4 vendor/fastText/src/utils.h
fasttext-0.2.3 vendor/fastText/src/utils.h
fasttext-0.2.2 vendor/fastText/src/utils.h
fasttext-0.2.1 vendor/fastText/src/utils.h
fasttext-0.2.0 vendor/fastText/src/utils.h
fasttext-0.1.3 vendor/fastText/src/utils.h