Skip to content

Commit

Permalink
ci: add golangci
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 30, 2021
1 parent b9e7ca5 commit 32f9f84
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 39 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ on:
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v2
37 changes: 9 additions & 28 deletions bot/adapters/storage/memorystorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sort"

"github.com/tal-tech/go-zero/core/lang"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/core/mr"
"github.com/wangbin/jiebago"
"github.com/wangbin/jiebago/analyse"
Expand Down Expand Up @@ -43,11 +44,11 @@ type (

func RestoreMemoryStorage(decoder *gob.Decoder) (*memoryStorage, error) {
var segmenter jiebago.Segmenter
segmenter.LoadDictionary(dictFile)
logx.Must(segmenter.LoadDictionary(dictFile))
var extracter analyse.TagExtracter
extracter.LoadDictionary(dictFile)
extracter.LoadIdf(idfFile)
extracter.LoadStopWords(stopWordsFile)
logx.Must(extracter.LoadDictionary(dictFile))
logx.Must(extracter.LoadIdf(idfFile))
logx.Must(extracter.LoadStopWords(stopWordsFile))

var keys []string
responses := make(map[string]map[string]int)
Expand Down Expand Up @@ -76,11 +77,11 @@ func RestoreMemoryStorage(decoder *gob.Decoder) (*memoryStorage, error) {

func NewMemoryStorage() *memoryStorage {
var segmenter jiebago.Segmenter
segmenter.LoadDictionary(dictFile)
logx.Must(segmenter.LoadDictionary(dictFile))
var extracter analyse.TagExtracter
extracter.LoadDictionary(dictFile)
extracter.LoadIdf(idfFile)
extracter.LoadStopWords(stopWordsFile)
logx.Must(extracter.LoadDictionary(dictFile))
logx.Must(extracter.LoadIdf(idfFile))
logx.Must(extracter.LoadStopWords(stopWordsFile))

return &memoryStorage{
segmenter: &segmenter,
Expand Down Expand Up @@ -382,23 +383,3 @@ func splitStrings(slice []string, size int) []*keyChunk {

return result
}

func (storage *memoryStorage) print() {
fmt.Println("Questions:")
for _, key := range storage.keys {
fmt.Printf("\t%s\n", key)
}

fmt.Println("Responses:")
for key, value := range storage.responses {
fmt.Printf("\t%s:\n", key)
for text, occurrence := range value {
fmt.Printf("\t\t%s:\t%d\n", text, occurrence)
}
}

fmt.Println("Indexes:")
for key, ids := range storage.indexes {
fmt.Printf("\t%s: %v\n", key, ids)
}
}
7 changes: 0 additions & 7 deletions bot/nlp/comparisons.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,3 @@ func min(a int, b int) int {
}
return a
}

func max(a int, b int) int {
if b > a {
return b
}
return a
}
4 changes: 3 additions & 1 deletion bot/trainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ func (trainer *CorpusTrainer) Train(data interface{}) error {

for _, convs := range corpora {
for _, conv := range convs {
convTrainer.Train(conv)
if err := convTrainer.Train(conv); err != nil {
return err
}
}
}

Expand Down

0 comments on commit 32f9f84

Please sign in to comment.