Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 11, 2021
1 parent f7ff210 commit 1699814
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions bot/nlp/sentencedetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
)

var (
endQuestionChars = map[rune]lang.PlaceholderType{
'?': lang.Placeholder,
'?': lang.Placeholder,
'吗': lang.Placeholder,
'么': lang.Placeholder,
}

embededQuestionMarks = []string{
"什么", "为何", "干嘛", "干吗", "怎么", "咋",
}

endQuestionChars = createSet([]rune{
'?',
'?',
'吗',
'么',
})
)

func IsQuestion(sentence string) bool {
Expand All @@ -44,6 +44,14 @@ func IsQuestion(sentence string) bool {
return false
}

func createSet(items []rune) map[rune]lang.PlaceholderType {
ret := make(map[rune]lang.PlaceholderType)
for _, item := range items {
ret[item] = lang.Placeholder
}
return ret
}

func isAscii(s string) bool {
for i := 0; i < len(s); i++ {
if s[i] > unicode.MaxASCII {
Expand Down

0 comments on commit 1699814

Please sign in to comment.