Skip to content

Commit

Permalink
3.1.6 fix Bug fasttext cpp 压缩模型加载错误
Browse files Browse the repository at this point in the history
Former-commit-id: 38e5acf
  • Loading branch information
jimichan committed Jun 22, 2020
1 parent 3741a37 commit d871140
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'eclipse'

description = "mynlp是mayabot开源的中文自然语言处理工具集"

def buildVersion = "3.1.5"
def buildVersion = "3.1.6"
def snapShot = false

allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Dictionary(

private var pdiscard: FloatArray = FloatArray(0)
var pruneidxSize = -1L
private val pruneidx: HashMap<Int,Int> = HashMap()
private var pruneidx: HashMap<Int, Int> = HashMap()

private val maxn = args.maxn
private val minn = args.minn
Expand Down Expand Up @@ -405,6 +405,9 @@ class Dictionary(
dict.initTableDiscard()
dict.initNgrams()

dict.pruneidxSize = pruneidxSize
dict.pruneidx = pruneidx

dict.onehotMap.initWordHash2WordId()

return dict
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mayabot.nlp.fasttext

import java.io.File

fun main() {
val model = FastText.loadCppModel(File("fastText4j/data/ChineseJapaneseKoreanLangIder.ftz"))

val list = model.predict(listOf("こんにちは"), 3, 0.1f)

list.forEach {
println(it)
}

}

0 comments on commit d871140

Please sign in to comment.