-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnimfastText.cfg
247 lines (193 loc) · 6.14 KB
/
nimfastText.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
[n.global]
output = nimfastText
[n.include]
nimfastText/src
[n.exclude]
to_cstring.cc
to_cstring.h
[n.prepare]
gitremote = "https://github.com/facebookresearch/fastText"
gitsparse = """
src/*
"""
[n.wildcard]
wildcard = *.h
search.1 = "enum class"
replace.1 = enum
regex.2 = """: [a-z0-9_]+ \{"""
replace.2 = "{"
regex.3 = """([A-Za-z&]+ operator=)"""
replace.3 = "//$1"
search.4 = " = delete"
replace.4 = ""
search.5 = "((__deprecated__"
comment.5 = 1
regex.6 = """([u]?int[\d]+)_t"""
replace.6 = "$1"
search.7 = " = default"
replace.7 = ""
search.8 = "std::ostream& operator<<"
comment.8 = 1
search.9 = "_{};"
replace.9 = "_;"
search.n = "noexcept"
replace.n = ""
search.o = "override"
replace.o = ""
wildcard.2 = *.nim
search.11 = "vector["
replace.11 = "vect["
search.12 = "import nimfastText/real"
replace.12 = ""
search.13 = real
replace.13 = cfloat
search.14 = Predictions
replace.14 = "vect[pair[cfloat, int32]]"
[nimfastText/src/to_cstring.cc]
create = """
#include "to_cstring.h"
char* toCstring( const std::string& s ) {
std::vector<char> v(s.size()+1);
memcpy( &v.front(), s.c_str(), s.size() + 1 );
return v.data();
};
"""
[nimfastText/src/to_cstring.h]
create = """
#include <string>
#include <vector>
#include <cstring>
char* toCstring( const std::string& s );
"""
[utils.h]
search.1 = "const T& value) {"
replace.1 = "const T& value);"
search.2 = " return"
comment.2 = 3
preprocess = true
flags = "--stdcall --cpp --suffix:_"
ppflags = "-std=gnu++11"
[fasttext.h]
preprocess = true
defines = true
recurse = true
flags = "--stdcall --cpp --suffix:_"
ppflags = "-std=gnu++11"
compile = nimfastText/src
pragma-lin.1 = "passC: \"-std=gnu++11\""
pragma-lin.2 = "passL: \"-lpthread\""
pragma-mac = "passC: \"-std=gnu++11\""
[args.nim]
search.0 = string
replace.0 = std_string
prepend = """type
vect {.importc: "std::vector", header: "<vector>".}[T] = object
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
std_string {.importc: "std::string", header: "<string>".} = object
"""
[dictionary.nim]
search.0 = string
replace.0 = std_string
prepend = """type
vect {.importc: "std::vector", header: "<vector>".}[T] = object
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
shared_ptr {.importc: "std::shared_ptr", header: "<memory>".}[T] = object
minstd_rand {.importc: "std::minstd_rand", header: "<random>".} = object
std_string {.importc: "std::string", header: "<string>".} = object
"""
search.1 = nullptr
replace.1 = nil
search.2 = "__get_nil_t()"
replace.2 = nil
[matrix.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
Vector = object
"""
search = "bycopy.} = object"
replace = "bycopy.} = object of RootObj"
[vector.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "<ostream>".} = object
Matrix = object
QMatrix = object
"""
[productquantizer.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
"""
[qmatrix.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
"""
[meter.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "<ostream>".} = object
vect {.importc: "std::vector", header: "<vector>".}[T] = object
pair {.importc: "std::pair", header: "<utility>".}[T, U] = object
"""
[model.nim]
prepend = """type
shared_ptr {.importc: "std::shared_ptr", header: "<memory>".}[T] = object
minstd_rand {.importc: "std::minstd_rand", header: "<random>".} = object
vect {.importc: "std::vector", header: "<vector>".}[T] = object
pair {.importc: "std::pair", header: "<utility>".}[T, U] = object
"""
search = "discard \"forward decl of Loss\""
replace = "type Loss {.bycopy.} = object"
[utils.nim]
prepend = """type
ifstream {.importc: "std::ifstream", header: "<fstream>".} = object
vect {.importc: "std::vector", header: "<vector>".}[T] = object
pair {.importc: "std::pair", header: "<utility>".}[T, U] = object
"""
search = nil
replace = ""
[densematrix.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
Vector = object
"""
[fasttext.nim]
search.0 = " string"
replace.0 = " std_string"
prepend = """type
shared_ptr {.importc: "std::shared_ptr", header: "<memory>".}[T] = object
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
istringstream* {.importc: "std::istringstream", header: "<sstream>".} = object
vect* {.importcpp: "std::vector", header: "<vector>".}[T] = object
`tuple` {.importc: "std::tuple", header: "<tuple>".}[T, U, V] = object
pair* {.importcpp: "std::pair", header: "<utility>".}[T, U] = object
first*:T
second*:U
std_set {.importc: "std::set", header: "<set>".}[T] = object
std_string* {.importc: "std::string", header: "<string>".} = object
proc constructStdString*(s: cstring): std_string {.importcpp: "std::string(@)", constructor, header: "<string>".}
proc constructStdIStringStream*(s: std_string): istringstream {.importcpp: "std::istringstream(@)", constructor, header: "<sstream>".}
template `[]=`*[T](v: var vect[T], key: int, val: T) =
{.emit: [v, "[", key, "] = ", val, ";"].}
proc `[]`*[T](v: var vect[T], key: int): T {.importcpp: "(#[#])", nodecl.}
"""
search.7 = "const headerfasttext = sourcePath & \"/src/fasttext.h\""
replace.7 = """
const headerfasttext = sourcePath & "/src/fasttext.h"
const headerto_cstring = sourcePath & "/src/to_cstring.h"
proc toCstring*(s: std_string):cstring{.importcpp:"::toCstring(@)",header:headerto_cstring.}
converter toString*(x:std_string):string =
$toCstring(x)
"""
search.3 = "set["
replace.3 = "std_set["
search.4 = "{.compile: \"nimfastText/src/main.cc\".}"
comment.4 = 1
search.5 = "var istream"
replace.5 = "var istringstream"
[n.post]
reset = true