Commit ed50608a by zhaoyanchao

对周搜索/年搜索大的词进行加分,以发现较新的新词热词,限制uv>20,避免特殊情况干扰

parent 33b7d636
...@@ -72,8 +72,6 @@ var prefixFilterArr = []string{"https://", "http://", "dg", "d & g", "dolce&gabb ...@@ -72,8 +72,6 @@ var prefixFilterArr = []string{"https://", "http://", "dg", "d & g", "dolce&gabb
const TABLE_SPLIT_STEP_SIZE = 10000 const TABLE_SPLIT_STEP_SIZE = 10000
const LEVEL_SIZE = 1
const MAX_TAG_SIZE = 5 const MAX_TAG_SIZE = 5
var UPDATE_TIME = time.Now().UnixNano() / 1e6 var UPDATE_TIME = time.Now().UnixNano() / 1e6
...@@ -117,7 +115,7 @@ func main() { ...@@ -117,7 +115,7 @@ func main() {
count := arr[1] / TABLE_SPLIT_STEP_SIZE count := arr[1] / TABLE_SPLIT_STEP_SIZE
log.Printf("maxId/10000=%d\n", count) log.Printf("maxId/10000=%d\n", count)
if arr[1] < 2800000 { if arr[1] < 1000000 {
log.Printf("data is too little ,return") log.Printf("data is too little ,return")
sendSuggestNotify() sendSuggestNotify()
return return
...@@ -467,10 +465,12 @@ func processWord(w *Word) { ...@@ -467,10 +465,12 @@ func processWord(w *Word) {
calculateWordRank(w) calculateWordRank(w)
calculateWordABRank(w) calculateWordABRank(w)
addNewScoreIfNewHotWord(w)
} }
func isFilterWord(w *Word) bool { func isFilterWord(w *Word) bool {
// 敏感词过滤 // 敏感词过滤
if w.IsSensitive { return true } if w.IsSensitive { return true }
...@@ -502,6 +502,29 @@ func isFilterWord(w *Word) bool { ...@@ -502,6 +502,29 @@ func isFilterWord(w *Word) bool {
} }
} }
func addNewScoreIfNewHotWord(w *Word) {
if w == nil {
return
}
// 比例有意义
if w.WeekCount == 0 || w.YearCount == 0 || w.WeekCount < 20 {
return
}
// 周点击占年点击 40% 以上
if w.WeekCount *10 / w.YearCount <= 5 {
return
}
if w.WeekClickCount < 3 || w.WeekUv < 5 {
return
}
// 新词加分大小 类似于 人工干预值
w.WordABRank = w.WordABRank * math.Sqrt(5.0)
fmt.Printf("最新热词添加分数,新词: %s", w.Keyword )
}
func isAllDigit(str string) bool { func isAllDigit(str string) bool {
for _, x := range str { for _, x := range str {
// x 的类型是 rune 其实就是对应字符的 utf8 编码 // x 的类型是 rune 其实就是对应字符的 utf8 编码
......
package main package main
import ( import "fmt"
"math"
"strings" type Phone interface {
"fmt" call()
)
type B struct {
Keyword string `json:"keyword"`
KeywordPinYin string `json:"keywordPinYin"`
YearCount int32 `json:"yearCount"`
YearClickCount int32 `json:"yearClickCount"`
YearCartCount int32 `json:"yearCartCount"`
ZhaoCount int32 `json:"-"`
} }
func main() {
prefix := strings.HasPrefix("tod's", "tod's") type NokiaPhone struct {
fmt.Print(prefix) Name string
}
func (nokiaPhone *NokiaPhone) call() {
fmt.Print(nokiaPhone.Name)
} }
//
//func (nokiaPhone *NokiaPhone) call() {
// fmt.Print(nokiaPhone.Name)
//}
func main() {
func calculateRatioFactor2(ratio float64, count int32) float64 {
var rank float64 var phone = NokiaPhone{Name:"zhangsan"}
switch { phone.call()
case count > 1 && count < 10 : rank = 1.2
case count >= 10 && count < 20 : rank = 1.4
case count >= 20 && count < 50 : rank = 1.6
case count >= 50 && count < 100 : rank = 1.8
case count >= 100 && count < 200 : rank = 2.0
case count >= 200 && count < 500 : rank = 2.2
case count >= 500 : rank = 2.5
default:rank = 1.0
}
//根据搜索转化率,转换为热度因子
return math.Log10(math.Sqrt(ratio + 10)) * rank
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment