Skip to content

Commit

Permalink
Merge branch 'master' of github.com:genotrance/nimfastText into lang_…
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
bung87 committed Sep 26, 2018
2 parents 4d50c6d + d49c6b8 commit 0291814
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,7 +17,7 @@ This will download, wrap and install nimfastText in the standard Nimble package
__Usage__

```nim
import nimfastText/fastText
import nimfastText/fasttext
var ft: FastText
```
Expand Down
81 changes: 50 additions & 31 deletions nimfastText.cfg
Expand Up @@ -34,7 +34,7 @@ comment.5 = 1
regex.6 = """([u]?int[\d]+)_t"""
replace.6 = "$1"

[fastText.h]
[fasttext.h]
preprocess = true
defines = true
recurse = true
Expand All @@ -47,58 +47,70 @@ search.2 = "loss_{}"
replace.2 = "loss_"

compile = nimfastText/src
pragma-lin = "passL: \"-lpthread\""

[args.nim]
search.0 = string
replace.0 = std_string

prepend = """type
vector {.importc: "std::vector", header: "vector".}[T] = object
ostream {.importc: "std::ostream", header: "ostream".} = object
istream {.importc: "std::istream", header: "istream".} = object
vector {.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
vector {.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
vector {.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
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
Vector = object
"""

[vector.nim]
prepend = """type
ostream {.importc: "std::ostream", header: "ostream".} = object
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
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
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = 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
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
real = float
"""

Expand All @@ -110,19 +122,25 @@ comment.2 = 1

[utils.nim]
prepend = """type
ifstream {.importc: "std::ifstream", header: "fstream".} = object
ifstream {.importc: "std::ifstream", header: "<fstream>".} = object
"""

[fastText.nim]
[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
vect {.importc: "std::vector", header: "vector".}[T] = object
`tuple` {.importc: "std::tuple", header: "tuple".}[T, U, V] = object
pair {.importc: "std::pair", header: "utility".}[T, U] = object
shared_ptr {.importc: "std::shared_ptr", header: "<memory>".}[T] = object
ostream {.importc: "std::ostream", header: "<ostream>".} = object
istream {.importc: "std::istream", header: "<istream>".} = object
vect {.importc: "std::vector", header: "<vector>".}[T] = object
`tuple` {.importc: "std::tuple", header: "<tuple>".}[T, U, V] = object
pair {.importc: "std::pair", header: "<utility>".}[T, U] = object
real = float
cppset {.importc: "std::set", header: "set".}[T] = object
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>".}
"""

search.1 = "vector["
Expand All @@ -132,7 +150,8 @@ search.2 = "import nimfastText/real"
comment.2 = 1

search.3 = "set["
replace.3 = "cppset["
replace.3 = "std_set["

search.4 = "{.compile: \"nimfastText/src/main.cc\".}"
comment.4 = 1
comment.4 = 1

4 changes: 3 additions & 1 deletion tests/testfast.nim
@@ -1,3 +1,5 @@
import nimfastText/fastText
import nimfastText/fasttext

var ft: FastText

ft.loadModel(constructStdString("lid.176.ftz"))

0 comments on commit 0291814

Please sign in to comment.