diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/pythonProject/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/pythonProject/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/misc.xml b/pythonProject/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a01189048dd51552f6ba99bf21b7c67f3613c98 --- /dev/null +++ b/pythonProject/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/modules.xml b/pythonProject/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..e15ec35fe054f3b2c7c21e3dcca866d6a79ca0ba --- /dev/null +++ b/pythonProject/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/pythonProject.iml b/pythonProject/.idea/pythonProject.iml new file mode 100644 index 0000000000000000000000000000000000000000..74d515a027de98657e9d3d5f0f1831882fd81374 --- /dev/null +++ b/pythonProject/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject/cos.py b/pythonProject/cos.py new file mode 100644 index 0000000000000000000000000000000000000000..a279bac88ed3ec511837632411b5275a5a78eeaa --- /dev/null +++ b/pythonProject/cos.py @@ -0,0 +1,23 @@ +# 计算两个向量点乘 +def dot(a,b): + sum=0; + c=zip(a,b) + for item in c: + sum+=item[0]*item[1] + return sum + +def mo(a): + sum=0 + for i in a: + sum+=i*i + return sum**0.5 + +import math +def angle(a,b): + ji=dot(a,b) + amo=mo(a) + bmo=mo(b) + cos=ji/(amo*bmo) + hudu=math.acos(cos) + jiaodu=hudu*180/math.pi + return jiaodu diff --git a/pythonProject/main.py b/pythonProject/main.py new file mode 100644 index 0000000000000000000000000000000000000000..f3e05ff55df4a24f3e3aea9f09802d942ebe7546 --- /dev/null +++ b/pythonProject/main.py @@ -0,0 +1,24 @@ +from flask import Flask,render_template +from datas import datas +from cos import angle +app=Flask(__name__) +@app.route('/') +def index(): + return render_template("demo.html",datas=datas) + +@app.route('/tuijian/') +def tuijian(id): + current=datas[id] ["feature"] + arr=[] + for i in range(len(datas)): + if(i!=id): + obj={} + a=angle(current,datas[i] ["feature"]) + obj["angle"]=a + obj["id"]=i + arr.append(obj) + def k(v): + return v["angle"] + arr.sort(key=k) + return render_template("tuijian.html",datas=datas,arr=arr[:5]) +app.run() \ No newline at end of file diff --git a/pythonProject/templates/demo.html b/pythonProject/templates/demo.html new file mode 100644 index 0000000000000000000000000000000000000000..3120017b52274e3c000bdd6b6bc862b08aec6d6c --- /dev/null +++ b/pythonProject/templates/demo.html @@ -0,0 +1,57 @@ + + + + + Title + + + + + {%for i in range(datas|length))%} + + + + + + {{datas[i].name}} + 推荐电影 + + + {%endfor%} + + + \ No newline at end of file diff --git a/pythonProject/templates/tuijian.html b/pythonProject/templates/tuijian.html new file mode 100644 index 0000000000000000000000000000000000000000..d02b0f1aa7bd75d46dba9bb0d1d6152783c7db30 --- /dev/null +++ b/pythonProject/templates/tuijian.html @@ -0,0 +1,49 @@ + + + + + Title + + + + + {%for item in arr%} + + + + + + {{datas[item.id].name}} + {{item.angle}} + + + {%endfor%} + + + \ No newline at end of file