Skip to content

Commit

Permalink
Merge pull request #117 from go-ego/range-pr
Browse files Browse the repository at this point in the history
add empty dictionary function support
  • Loading branch information
vcaesar authored Sep 19, 2021
2 parents 0c45dbf + 1dbfdc5 commit 569222e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dict_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ func (seg *Segmenter) RemoveToken(text string) error {
return seg.Dict.RemoveToken(token)
}

// Empty empty the seg dictionary
func (seg *Segmenter) Empty() error {
seg.Dict = nil
return nil
}

// LoadDictMap load dictionary from []map[string]string
func (seg *Segmenter) LoadDictMap(dict []map[string]string) error {
if seg.Dict == nil {
Expand Down
4 changes: 4 additions & 0 deletions gse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ func TestNum(t *testing.T) {
seg.Alpha = true
s = seg.CutSearch(text)
tt.Equal(t, "[t 1 2 3 t e s t 1 2 3 n u m 1 2 3 - 1]", s)

err = seg.Empty()
tt.Nil(t, err)
tt.Nil(t, seg.Dict)
}

func TestUrl(t *testing.T) {
Expand Down

0 comments on commit 569222e

Please sign in to comment.