Skip to content

Commit

Permalink
Handle patterns in vocab
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Oct 16, 2023
1 parent 0089863 commit d74a03f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions strcase/sentence.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ func (sc *SentenceConverter) Convert(s string) string {

func (sc *SentenceConverter) inVocab(s string) string {
for _, token := range sc.vocab {
matched, _ := regexp.MatchString(token, s)
if strings.ToLower(token) == strings.ToLower(s) {
return token
} else if matched {
return s
}
}
return ""
Expand Down
3 changes: 3 additions & 0 deletions strcase/title.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ func (tc *TitleConverter) Convert(s string) string {

func (tc *TitleConverter) inVocab(s string) string {
for _, token := range tc.vocab {
matched, _ := regexp.MatchString(token, s)
if strings.ToLower(token) == strings.ToLower(s) {
return token
} else if matched {
return s
}
}
return ""
Expand Down

0 comments on commit d74a03f

Please sign in to comment.