File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,13 @@ func CharAt(s string, i int) byte {
59
59
60
60
// ToTitle returns a copy of the string m with its first Unicode letter mapped
61
61
// to its title case.
62
- func ToTitle (m string ) string {
62
+ func ToTitle (m string , strict bool ) string {
63
63
r , size := utf8 .DecodeRuneInString (m )
64
- return string (unicode .ToTitle (r )) + strings .ToLower (m [size :])
64
+
65
+ other := m [size :]
66
+ if strict {
67
+ other = strings .ToLower (other )
68
+ }
69
+
70
+ return string (unicode .ToTitle (r )) + other
65
71
}
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ func (sc *SentenceConverter) Convert(s string) string {
65
65
if entry := sc .inVocab (token ); entry != "" {
66
66
made = append (made , entry )
67
67
} else if i == 0 || sc .indicator (prev , i - 1 ) {
68
- made = append (made , internal .ToTitle (token ))
68
+ made = append (made , internal .ToTitle (token , true ))
69
69
} else {
70
70
made = append (made , strings .ToLower (token ))
71
71
}
Original file line number Diff line number Diff line change @@ -97,7 +97,8 @@ func (tc *TitleConverter) Convert(s string) string {
97
97
(internal .CharAt (t , pos + ext ) != '-' || internal .CharAt (t , pos - 1 ) == '-' ) {
98
98
return sm
99
99
}
100
- return internal .ToTitle (m )
100
+
101
+ return internal .ToTitle (m , false )
101
102
})
102
103
}
103
104
You can’t perform that action at this time.
0 commit comments