feature:优化匹配规则

This commit is contained in:
charlesxie
2023-09-09 12:42:46 +08:00
parent 76da9121a4
commit 3e8c3fed63
6 changed files with 32 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
from applications.task.utils import match_score
from applications.task.utils import match_score, match_artist
from concurrent.futures import ThreadPoolExecutor
from component import music_tag
@@ -32,8 +31,14 @@ class SmartTagClient:
for songs in results:
for song in songs:
title_score = match_score(title, song["name"])
artist_score = match_score(artist if artist else title, song["artist"])
artist_score = match_artist(artist if artist else title, song["artist"])
album_score = match_score(album if album else title, song["album"])
if artist and artist_score == 0:
artist_score = -2
# 标题包含艺术家信息
if not artist and artist_score >= 1:
if title_score >= 1:
title_score = 2
song["score"] = title_score + artist_score + album_score
max_score = max(max_score, song["score"])
if title_score == 0:

View File

@@ -50,6 +50,14 @@ def match_score(my_value, u_value):
return 0
def match_artist(my_value, u_value):
if "," in u_value:
return match_score(my_value, u_value.split(",")[0].replace(" ", "")) \
+ match_score(my_value, u_value.split(",")[1].replace(" ", ""))
else:
return match_score(my_value, u_value)
def match_song(resource, song_path, select_mode):
from applications.task.services.music_resource import MusicResource
@@ -71,8 +79,14 @@ def match_song(resource, song_path, select_mode):
}
for song in songs:
match_score_map["title"] = match_score(title, song["name"])
match_score_map["artist"] = match_score(artist if artist else title, song["artist"])
match_score_map["artist"] = match_artist(artist if artist else title, song["artist"])
match_score_map["album"] = match_score(album if album else title, song["album"])
if artist and match_score_map["artist"] == 0:
match_score_map["artist"] = -2
# 标题包含艺术家信息
if not artist and match_score_map["artist"] >= 1:
if match_score_map["title"] >= 1:
match_score_map["title"] = 2
if sum(match_score_map.values()) >= 3:
is_match = True
song_select = song
@@ -120,3 +134,7 @@ def detect_language(lyrics):
return '泰文'
else:
return '未知'
def parse_discnumber(discnumber):
pass

View File

@@ -1,3 +1,3 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>音乐标签Web版|Music Tag Web|</title><link rel="shortcut icon" href=/static/dist/img/favicon_64.ico type=image/x-icon><link href=./static/dist/css/app.css rel=stylesheet></head><body><script>window.siteUrl = "/"
window.APP_CODE = 'dj-flow';
window.CSRF_COOKIE_NAME = 'django_vue_cli_csrftoken'</script><div id=app></div><script type=text/javascript src=./static/dist/js/manifest.9ba6c0d4f4490e9a4f28.js></script><script type=text/javascript src=./static/dist/js/vendor.051dd49be048f27f51f9.js></script><script type=text/javascript src=./static/dist/js/app.d34f0d58eafaeacc5302.js></script></body></html>
window.CSRF_COOKIE_NAME = 'django_vue_cli_csrftoken'</script><div id=app></div><script type=text/javascript src=./static/dist/js/manifest.9ba6c0d4f4490e9a4f28.js></script><script type=text/javascript src=./static/dist/js/vendor.051dd49be048f27f51f9.js></script><script type=text/javascript src=./static/dist/js/app.0a49d5b848fb993c489d.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -775,9 +775,9 @@
// 如果在某些情况下 h 不能自动注入而报错,需将 h 参数写上;一般来说 h 默认是第一参数,但是现在改为第一参数会导致已经使用的用户都需要修改,所以先放在最后。
// 如果 h 能自动注入则可以忽略 h 参数,无需写上,否则 h 参数会重复。
const titleClass = node.selected ? 'node-title node-selected' : 'node-title ' + node.state
if (node.title.length > 30) {
if (node.title.length > 25) {
return <span>
<span class={titleClass} domPropsInnerHTML={node.title.slice(0, 30)}
<span class={titleClass} domPropsInnerHTML={node.title.slice(0, 25)}
onClick={() => {
this.nodeClickOne(node)
}} v-bk-tooltips={node.title}>
@@ -785,7 +785,7 @@
</span>
} else {
return <span>
<span class={titleClass} domPropsInnerHTML={node.title.slice(0, 30)}
<span class={titleClass} domPropsInnerHTML={node.title.slice(0, 25)}
onClick={() => {
this.nodeClickOne(node)
}}>