Skip to content

Commit 16aa45e

Browse files
committed
fix: modify some misspelt words in code comment
1 parent 3265fd7 commit 16aa45e

File tree

11 files changed

+25
-24
lines changed

11 files changed

+25
-24
lines changed

Diff for: dag.go

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func (seg *Segmenter) Analyze(text []string, t1 string, by ...bool) (az []Analyz
123123
return
124124
}
125125

126+
// getDag get a directed acyclic graph (DAG) from slice of runes(containing Unicode characters)
126127
func (seg *Segmenter) getDag(runes []rune) map[int][]int {
127128
dag := make(map[int][]int)
128129
n := len(runes)

Diff for: dict_1.16.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (seg *Segmenter) LoadDictEmbed(dict ...string) (err error) {
8787
return seg.loadZh()
8888
}
8989

90-
// LoadDictStr load the dictionary from string
90+
// LoadDictStr load the dictionary from dict path
9191
func (seg *Segmenter) LoadDictStr(dict string) error {
9292
if seg.Dict == nil {
9393
seg.Dict = NewDict()
@@ -153,7 +153,7 @@ func (seg *Segmenter) LoadStopEmbed(dict ...string) (err error) {
153153
return seg.LoadStopStr(stopDict)
154154
}
155155

156-
// LoadDictStr load the stop dictionary from string
156+
// LoadStopStr load the stop dictionary from dict path
157157
func (seg *Segmenter) LoadStopStr(dict string) error {
158158
if seg.StopWordMap == nil {
159159
seg.StopWordMap = make(map[string]bool)

Diff for: dict_util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
var (
32-
// ToLower set alpha tolower
32+
// ToLower set alpha to lowercase
3333
ToLower = true
3434
)
3535

@@ -238,7 +238,7 @@ func (seg *Segmenter) GetIdfPath(files ...string) []string {
238238
return files
239239
}
240240

241-
// Read read the dict flie
241+
// Read read the dict file
242242
func (seg *Segmenter) Read(file string) error {
243243
if !seg.SkipLog {
244244
log.Printf("Load the gse dictionary: \"%s\" ", file)

Diff for: dictionary.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (dict *Dictionary) Find(word []byte) (float64, string, bool) {
131131
}
132132

133133
// Value find word in the dictionary
134-
// retrun the word's value and id
134+
// return the word's value and id
135135
func (dict *Dictionary) Value(word []byte) (val, id int, err error) {
136136
id, err = dict.trie.Jump(word, id)
137137
if err != nil {

Diff for: examples/dict/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func segment() {
6767
segments := seg.Segment(text1)
6868
// fmt.Println(gse.ToString(segments, false))
6969
fmt.Println(gse.ToString(segments))
70-
//"旧金山湾/n 金门大桥/nz "
70+
// "旧金山湾/n 金门大桥/nz "
7171

7272
// 搜索模式主要用于给搜索引擎提供尽可能多的关键字
7373
segs := seg.ModeSegment(text1, true)

Diff for: gse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ func (seg *Segmenter) HMMCutMod(str string, prob ...map[rune]float64) []string {
141141
return hmm.Cut(str)
142142
}
143143

144-
// Slice use modeSegment segment retrun []string
144+
// Slice use modeSegment segment return []string
145145
// using search mode if searchMode is true
146146
func (seg *Segmenter) Slice(s string, searchMode ...bool) []string {
147147
segs := seg.ModeSegment([]byte(s), searchMode...)
148148
return ToSlice(segs, searchMode...)
149149
}
150150

151-
// Slice use modeSegment segment retrun string
151+
// Slice use modeSegment segment return string
152152
// using search mode if searchMode is true
153153
func (seg *Segmenter) String(s string, searchMode ...bool) string {
154154
segs := seg.ModeSegment([]byte(s), searchMode...)

Diff for: hmm/idf/idf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (i *Idf) NumTokens() int {
5858
return i.seg.Dict.NumTokens()
5959
}
6060

61-
// TotalFreq reruen the IDF total frequency
61+
// TotalFreq return the IDF total frequency
6262
func (i *Idf) TotalFreq() float64 {
6363
return i.seg.Dict.TotalFreq()
6464
}

Diff for: hmm/pos/dict.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ func (d *Dict) updateLogTotal() {
4444
d.logTotal = math.Log(d.total)
4545
}
4646

47-
// Freq find the word return the frequency and existenced
47+
// Freq find the word return the word's freq, pos and existence
4848
func (d *Dict) Freq(key string) (float64, string, bool) {
4949
return d.Seg.Find(key)
5050
}
5151

52-
// Pos find the key return the POS and existenced
52+
// Pos find the key return the POS and existence
5353
func (d *Dict) Pos(key string) (string, bool) {
5454
value, _, _ := d.Seg.Value(key)
5555
if value == 0 {

Diff for: seg_utils.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"fmt"
2121
)
2222

23-
// ToString converts a segments slice to string retrun the string
23+
// ToString converts a segments slice to string return the string
2424
//
2525
// two output modes:
2626
//
@@ -75,7 +75,7 @@ func tokenToBytes(token *Token) (output []byte) {
7575
return
7676
}
7777

78-
// ToSlice converts a segments to slice retrun string slice
78+
// ToSlice converts a segments to slice return string slice
7979
func ToSlice(segs []Segment, searchMode ...bool) (output []string) {
8080
var mode bool
8181
if len(searchMode) > 0 {
@@ -158,7 +158,7 @@ func tokenToPos(token *Token) (output []SegPos) {
158158
return
159159
}
160160

161-
// let make multiple []Text into one string ooutput
161+
// let make multiple []Text into one string output
162162
func textToString(text []Text) (output string) {
163163
for _, word := range text {
164164
output += string(word)
@@ -171,7 +171,7 @@ func textSliceToString(text []Text) string {
171171
return Join(text)
172172
}
173173

174-
// retrun total length of text slice
174+
// return total length of text slice
175175
func textSliceByteLen(text []Text) (length int) {
176176
for _, word := range text {
177177
length += len(word)

Diff for: segmenter.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Segmenter struct {
4343
LoadNoFreq bool
4444
// MinTokenFreq load min freq token
4545
MinTokenFreq float64
46-
// TextFreq add token frenquency when not specified freq
46+
// TextFreq add token frequency when not specified freq
4747
TextFreq string
4848

4949
// SkipLog set skip log print
@@ -65,15 +65,15 @@ type jumper struct {
6565
token *Token
6666
}
6767

68-
// Segment use shortest path to segment the text
68+
// Segment use the shortest path to segment the text
6969
//
7070
// input parameter:
7171
//
72-
// bytes UTF8 text []byte
72+
// bytes UTF8 text []byte
7373
//
7474
// output:
7575
//
76-
// []Segment retrun segments result
76+
// []Segment return segments result
7777
func (seg *Segmenter) Segment(bytes []byte) []Segment {
7878
return seg.internalSegment(bytes, false)
7979
}
@@ -237,7 +237,7 @@ func (seg *Segmenter) SplitTextToWords(text Text) []Text {
237237
current += size
238238
}
239239

240-
// procsss last byte is alpha and num
240+
// process last byte is alpha and num
241241
if inAlphanumeric && !seg.AlphaNum {
242242
if current != 0 {
243243
output = append(output, toLow(text[alphanumericStart:current]))

Diff for: token.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ func (s *Segment) Start() int {
5050
return s.start
5151
}
5252

53-
// End retrun the end byte position of the segment (not including this)
53+
// End return the end byte position of the segment (not including this)
5454
func (s *Segment) End() int {
5555
return s.end
5656
}
5757

58-
// Token retrun the segment token information
58+
// Token return the segment token information
5959
func (s *Segment) Token() *Token {
6060
return s.token
6161
}
@@ -71,13 +71,13 @@ type Token struct {
7171
// a segment string,it's []Text
7272
text []Text
7373

74-
// a frenquency of the token
74+
// a frequency of the token
7575
freq float64
7676

7777
// part of speech label
7878
pos string
7979

80-
// log2(total frequency/this segment frenquency),equal to log2(1/p(segment))),
80+
// log2(total frequency/this segment frequency),equal to log2(1/p(segment))),
8181
// used by the short path as the path length of the clause in dynamic programming.
8282
// Solving for the maximum of prod(p(segment)) is equivalent to solving for the minimum of
8383
// the minimum of sum(distance(segment)),

0 commit comments

Comments
 (0)