Skip to content

Commit

Permalink
woo-hoo!
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed Nov 26, 2020
1 parent 6e9b48f commit df3e726
Show file tree
Hide file tree
Showing 42 changed files with 1,243 additions and 870 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: go

go:
- "1.14.x"
- "1.15.x"

services:
- docker
Expand Down
187 changes: 0 additions & 187 deletions cmd/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions cmd/model/glove/glove.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import (
"github.com/spf13/cobra"

"github.com/ynqa/wego/cmd/model/cmdutil"
"github.com/ynqa/wego/pkg/corpus"
"github.com/ynqa/wego/pkg/corpus/pairwise"
"github.com/ynqa/wego/pkg/model"
"github.com/ynqa/wego/pkg/model/glove"
"github.com/ynqa/wego/pkg/model/modelutil/save"
)
Expand All @@ -51,10 +48,6 @@ func New() *cobra.Command {
cmdutil.AddOutputFlags(cmd, &outputFile)
cmdutil.AddProfFlags(cmd, &prof)
cmdutil.AddSaveVectorTypeFlags(cmd, &saveVectorType)

corpus.LoadForCmd(cmd, &opts.CorpusOptions)
pairwise.LoadForCmd(cmd, &opts.PairwiseOptions)
model.LoadForCmd(cmd, &opts.ModelOptions)
glove.LoadForCmd(cmd, &opts)
return cmd
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/model/lexvec/lexvec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/spf13/cobra"

"github.com/ynqa/wego/cmd/model/cmdutil"
"github.com/ynqa/wego/pkg/corpus"
"github.com/ynqa/wego/pkg/model"
"github.com/ynqa/wego/pkg/model/lexvec"
"github.com/ynqa/wego/pkg/model/modelutil/save"
)
Expand All @@ -50,9 +48,6 @@ func New() *cobra.Command {
cmdutil.AddOutputFlags(cmd, &outputFile)
cmdutil.AddProfFlags(cmd, &prof)
cmdutil.AddSaveVectorTypeFlags(cmd, &saveVectorType)

corpus.LoadForCmd(cmd, &opts.CorpusOptions)
model.LoadForCmd(cmd, &opts.ModelOptions)
lexvec.LoadForCmd(cmd, &opts)
return cmd
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/model/word2vec/word2vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/spf13/cobra"

"github.com/ynqa/wego/cmd/model/cmdutil"
"github.com/ynqa/wego/pkg/corpus"
"github.com/ynqa/wego/pkg/model"
"github.com/ynqa/wego/pkg/model/modelutil/save"
"github.com/ynqa/wego/pkg/model/word2vec"
)
Expand All @@ -50,9 +48,6 @@ func New() *cobra.Command {
cmdutil.AddOutputFlags(cmd, &outputFile)
cmdutil.AddProfFlags(cmd, &prof)
cmdutil.AddSaveVectorTypeFlags(cmd, &saveVectorType)

corpus.LoadForCmd(cmd, &opts.CorpusOptions)
model.LoadForCmd(cmd, &opts.ModelOptions)
word2vec.LoadForCmd(cmd, &opts)
return cmd
}
Expand Down
File renamed without changes.
17 changes: 8 additions & 9 deletions cmd/search/repl/repl.go → cmd/query/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package repl
package console

import (
"os"

"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/ynqa/wego/cmd/search/cmdutil"
"github.com/ynqa/wego/cmd/query/cmdutil"
"github.com/ynqa/wego/pkg/embedding"
"github.com/ynqa/wego/pkg/search"
"github.com/ynqa/wego/pkg/search/repl"
"github.com/ynqa/wego/pkg/search/console"
)

var (
Expand All @@ -33,10 +33,9 @@ var (

func New() *cobra.Command {
cmd := &cobra.Command{
Use: "search-repl",
Short: "Search similar words (REPL mode)",
Long: "Search similar words (REPL mode)",
Example: " wego search-repl -i example/word_vectors.txt\n" +
Use: "console",
Short: "Console to investigate word vectors",
Example: " wego console -i example/word_vectors.txt\n" +
" >> apple + banana\n" +
" ...",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -70,9 +69,9 @@ func execute() error {
if err != nil {
return err
}
repl, err := repl.New(searcher, rank)
console, err := console.New(searcher, rank)
if err != nil {
return err
}
return repl.Run()
return console.Run()
}
11 changes: 5 additions & 6 deletions cmd/search/search.go → cmd/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package search
package query

import (
"os"

"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/ynqa/wego/cmd/search/cmdutil"
"github.com/ynqa/wego/cmd/query/cmdutil"
"github.com/ynqa/wego/pkg/embedding"
"github.com/ynqa/wego/pkg/search"
)
Expand All @@ -32,10 +32,9 @@ var (

func New() *cobra.Command {
cmd := &cobra.Command{
Use: "search",
Short: "Search similar words",
Long: "Search similar words",
Example: " wego search -i example/word_vectors.txt microsoft",
Use: "query",
Short: "Query similar words",
Example: " wego query -i example/word_vectors.txt microsoft",
RunE: func(cmd *cobra.Command, args []string) error {
return execute(args)
},
Expand Down
8 changes: 4 additions & 4 deletions examples/word2vec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (

func main() {
model, err := word2vec.New(
word2vec.WithWindow(5),
word2vec.WithModel(word2vec.Cbow),
word2vec.WithOptimizer(word2vec.NegativeSampling),
word2vec.WithNegativeSampleSize(5),
word2vec.Window(5),
word2vec.Model(word2vec.Cbow),
word2vec.Optimizer(word2vec.NegativeSampling),
word2vec.NegativeSampleSize(5),
word2vec.Verbose(),
)
if err != nil {
Expand Down
23 changes: 10 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
module github.com/ynqa/wego

go 1.13
go 1.15

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/olekukonko/tablewriter v0.0.0-20171203151007-65fec0d89a57
github.com/peterh/liner v1.1.0
github.com/pkg/errors v0.8.0
github.com/spf13/cobra v0.0.1
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/peterh/liner v1.2.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/sync v0.0.0-20200930132711-30421366ff76
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
)
Loading

0 comments on commit df3e726

Please sign in to comment.