fasttext 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,6 @@
10
10
  #include "loss.h"
11
11
  #include "utils.h"
12
12
 
13
- #include <assert.h>
14
13
  #include <algorithm>
15
14
  #include <stdexcept>
16
15
 
@@ -11,5 +11,4 @@
11
11
  namespace fasttext {
12
12
 
13
13
  typedef float real;
14
-
15
14
  }
@@ -8,6 +8,7 @@
8
8
 
9
9
  #include "utils.h"
10
10
 
11
+ #include <iomanip>
11
12
  #include <ios>
12
13
 
13
14
  namespace fasttext {
@@ -23,6 +24,30 @@ void seek(std::ifstream& ifs, int64_t pos) {
23
24
  ifs.clear();
24
25
  ifs.seekg(std::streampos(pos));
25
26
  }
27
+
28
+ double getDuration(
29
+ const std::chrono::steady_clock::time_point& start,
30
+ const std::chrono::steady_clock::time_point& end) {
31
+ return std::chrono::duration_cast<std::chrono::duration<double>>(end - start)
32
+ .count();
33
+ }
34
+
35
+ ClockPrint::ClockPrint(int32_t duration) : duration_(duration) {}
36
+
37
+ std::ostream& operator<<(std::ostream& out, const ClockPrint& me) {
38
+ int32_t etah = me.duration_ / 3600;
39
+ int32_t etam = (me.duration_ % 3600) / 60;
40
+ int32_t etas = (me.duration_ % 3600) % 60;
41
+
42
+ out << std::setw(3) << etah << "h" << std::setw(2) << etam << "m";
43
+ out << std::setw(2) << etas << "s";
44
+ return out;
45
+ }
46
+
47
+ bool compareFirstLess(const std::pair<double, double>& l, const double& r) {
48
+ return l.first < r;
49
+ }
50
+
26
51
  } // namespace utils
27
52
 
28
53
  } // namespace fasttext
@@ -11,7 +11,9 @@
11
11
  #include "real.h"
12
12
 
13
13
  #include <algorithm>
14
+ #include <chrono>
14
15
  #include <fstream>
16
+ #include <ostream>
15
17
  #include <vector>
16
18
 
17
19
  #if defined(__clang__) || defined(__GNUC__)
@@ -38,6 +40,33 @@ bool contains(const std::vector<T>& container, const T& value) {
38
40
  container.end();
39
41
  }
40
42
 
43
+ template <typename T1, typename T2>
44
+ bool containsSecond(
45
+ const std::vector<std::pair<T1, T2>>& container,
46
+ const T2& value) {
47
+ return std::find_if(
48
+ container.begin(),
49
+ container.end(),
50
+ [&value](const std::pair<T1, T2>& item) {
51
+ return item.second == value;
52
+ }) != container.end();
53
+ }
54
+
55
+ double getDuration(
56
+ const std::chrono::steady_clock::time_point& start,
57
+ const std::chrono::steady_clock::time_point& end);
58
+
59
+ class ClockPrint {
60
+ public:
61
+ explicit ClockPrint(int32_t duration);
62
+ friend std::ostream& operator<<(std::ostream& out, const ClockPrint& me);
63
+
64
+ private:
65
+ int32_t duration_;
66
+ };
67
+
68
+ bool compareFirstLess(const std::pair<double, double>& l, const double& r);
69
+
41
70
  } // namespace utils
42
71
 
43
72
  } // namespace fasttext
@@ -12,7 +12,6 @@
12
12
 
13
13
  #include <cmath>
14
14
  #include <iomanip>
15
- #include <utility>
16
15
 
17
16
  #include "matrix.h"
18
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasttext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-11 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice
@@ -94,7 +94,6 @@ files:
94
94
  - ext/fasttext/extconf.rb
95
95
  - lib/fasttext.rb
96
96
  - lib/fasttext/classifier.rb
97
- - lib/fasttext/ext.bundle
98
97
  - lib/fasttext/model.rb
99
98
  - lib/fasttext/vectorizer.rb
100
99
  - lib/fasttext/version.rb
@@ -102,6 +101,8 @@ files:
102
101
  - vendor/fastText/README.md
103
102
  - vendor/fastText/src/args.cc
104
103
  - vendor/fastText/src/args.h
104
+ - vendor/fastText/src/autotune.cc
105
+ - vendor/fastText/src/autotune.h
105
106
  - vendor/fastText/src/densematrix.cc
106
107
  - vendor/fastText/src/densematrix.h
107
108
  - vendor/fastText/src/dictionary.cc
@@ -126,7 +127,7 @@ files:
126
127
  - vendor/fastText/src/utils.h
127
128
  - vendor/fastText/src/vector.cc
128
129
  - vendor/fastText/src/vector.h
129
- homepage: https://github.com/ankane/fasttext
130
+ homepage: https://github.com/ankane/fastText
130
131
  licenses:
131
132
  - MIT
132
133
  metadata: {}
Binary file