This commit is contained in:
+20
-2
@@ -351,6 +351,14 @@ func min(a, b int) int {
|
||||
|
||||
func rankSearchResults(query string, results []services.SearchResult) []services.SearchResult {
|
||||
queryTerms := strings.Fields(strings.ToLower(query))
|
||||
positiveTerms := []string{
|
||||
"b-roll", "b roll", "stock", "stock footage", "footage", "cinematic", "editorial",
|
||||
"establishing", "4k", "hd", "drone", "ambient", "scene", "urban", "cityscape",
|
||||
}
|
||||
negativeTerms := []string{
|
||||
"shocking", "amazing", "crazy", "must watch", "reaction", "gossip", "celebrity",
|
||||
"thumbnail", "meme", "prank", "drama", "breaking", "viral",
|
||||
}
|
||||
type scoredResult struct {
|
||||
item services.SearchResult
|
||||
score int
|
||||
@@ -365,6 +373,16 @@ func rankSearchResults(query string, results []services.SearchResult) []services
|
||||
score += 3
|
||||
}
|
||||
}
|
||||
for _, term := range positiveTerms {
|
||||
if strings.Contains(text, term) {
|
||||
score += 2
|
||||
}
|
||||
}
|
||||
for _, term := range negativeTerms {
|
||||
if strings.Contains(text, term) {
|
||||
score -= 4
|
||||
}
|
||||
}
|
||||
if result.ThumbnailURL != "" {
|
||||
score += 2
|
||||
}
|
||||
@@ -372,9 +390,9 @@ func rankSearchResults(query string, results []services.SearchResult) []services
|
||||
case "Google Video":
|
||||
score += 3
|
||||
case "Envato":
|
||||
score += 2
|
||||
score += 4
|
||||
case "Artgrid":
|
||||
score += 2
|
||||
score += 4
|
||||
}
|
||||
scored = append(scored, scoredResult{item: result, score: score})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user