forked from bountylabs/go-fasttext
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joseph Bernstein
committed
Aug 28, 2018
1 parent
6967fb1
commit 0a6885e
Showing
10 changed files
with
119 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "fastText"] | ||
path = fastText | ||
url = https://github.com/facebookresearch/fastText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Go parameters | ||
GOCMD=go | ||
GOBUILD=$(GOCMD) build | ||
GOCLEAN=$(GOCMD) clean | ||
GOTEST=$(GOCMD) test | ||
GOGET=$(GOCMD) get | ||
BINARY_NAME=fast_bind | ||
BINARY_UNIX=$(BINARY_NAME)_unix | ||
|
||
all: clean test | ||
build: | ||
$(GOBUILD) -o $(BINARY_NAME) -v | ||
test: | ||
go run cli/main.go predict -m ../service/chat-quality/tools/ml/fasttext/model.bin "i accidentally shrunk my shrinky dink lol </s>" | ||
echo "i accidentally shrunk my shrinky dink lol" | ./fastText/fasttext predict-prob ../service/chat-quality/tools/ml/fasttext/model.bin - | ||
go run cli/main.go sentence -m ../service/chat-quality/tools/ml/fasttext/model.bin "i accidentally shrunk my shrinky dink lol </s>" | ||
echo "i accidentally shrunk my shrinky dink lol" | ./fastText/fasttext print-sentence-vectors ../service/chat-quality/tools/ml/fasttext/model.bin | ||
clean: | ||
rm -rf ~/Library/Caches/go-build/ | ||
$(GOCLEAN) | ||
rm -f $(BINARY_NAME) | ||
rm -f $(BINARY_UNIX) | ||
run: | ||
$(GOBUILD) -o $(BINARY_NAME) -v ./... | ||
./$(BINARY_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/bountylabs/go-fasttext/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Unknwon/com" | ||
"github.com/k0kubun/pp" | ||
fasttext "github.com/bountylabs/go-fasttext" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// predictCmd represents the predict command | ||
var sentenceCmd = &cobra.Command{ | ||
Use: "sentence -m [path_to_model] [query]", | ||
Short: "get a sentence vector", | ||
Args: cobra.ExactArgs(1), // make sure that there is only one argument being passed in | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if !com.IsFile(modelPath) { | ||
fmt.Println("the file %s does not exist", modelPath) | ||
return | ||
} | ||
|
||
// create a model object | ||
model := fasttext.Open(modelPath) | ||
// close the model at the end | ||
defer model.Close() | ||
// perform the prediction | ||
preds, err := model.Sentencevec(args[0]) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
pp.Println(preds) | ||
}, | ||
} | ||
|
||
func init() { | ||
sentenceCmd.Flags().StringVarP(&modelPath, "model", "m", "", "path to the fasttext model") | ||
rootCmd.AddCommand(sentenceCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.