Simplify包:fix [interferon beta-1a] bug

master
宋青青 22 hours ago
parent 17458fd610
commit e589b0c2c0
  1. 10
      simplify/words.go

@ -37,17 +37,19 @@ func (w *Words) Simplify() []string {
for _, separator := range separators { for _, separator := range separators {
str = strings.ReplaceAll(str, separator, " ") str = strings.ReplaceAll(str, separator, " ")
} }
wide := " " + strings.Join(strings.Fields(str), " ") + " " // 空格开头结尾,便于包含判断 wide := " " + strings.Join(strings.Fields(str), " ") + " " // 去掉连续空格 且 空格开头结尾,便于包含判断
if strings.TrimSpace(wide) == "" { if strings.TrimSpace(wide) == "" {
continue continue
} }
wides[keyword] = wide if _, ok := wides[wide]; !ok { // 优先保留 input内容
wides[wide] = keyword
}
} }
// 计算重复次数 // 计算重复次数
repetition := make(map[string]int) repetition := make(map[string]int)
for _, wide1 := range wides { for wide1 := range wides {
for keyword, wide2 := range wides { for wide2, keyword := range wides {
// 首尾空格字符串 包含另一个 首尾空格字符串,则认为重复 // 首尾空格字符串 包含另一个 首尾空格字符串,则认为重复
if strings.Contains(wide2, wide1) { if strings.Contains(wide2, wide1) {

Loading…
Cancel
Save