瀏覽代碼

developing

罗俊辉 1 年之前
父節點
當前提交
4429708f32
共有 4 個文件被更改,包括 28 次插入4 次删除
  1. 13 1
      applications/algorthims.py
  2. 12 1
      routes/__init__.py
  3. 1 0
      routes/nlpServer.py
  4. 2 2
      test/rank_dev.py

+ 13 - 1
applications/algorthims.py

@@ -9,7 +9,7 @@ from sklearn.metrics import jaccard_score
 from sklearn.metrics.pairwise import cosine_similarity
 
 
-class titleSimilarity(object):
+class Similarity(object):
     """
     标题相似度代码
     """
@@ -91,6 +91,7 @@ class titleSimilarity(object):
         :param title2:
         :return:
         """
+
         def embed_sentences(sentences, model, tokenizer):
             """
             嵌入句子
@@ -110,3 +111,14 @@ class titleSimilarity(object):
             cls.bert_tokenizer)
         return cosine_similarity(embeddings)[0][1]
 
+
+class KeyWords(object):
+    """
+    keywords对象
+    """
+
+
+class Sensitive(object):
+    """
+    敏感词对象
+    """

+ 12 - 1
routes/__init__.py

@@ -5,7 +5,7 @@
 from quart import Blueprint, jsonify, request
 
 from .AccountArticleRank import AccountArticleRank
-
+from .nlpServer import NLPClass
 blueprint = Blueprint("LongArticlesAlgServer", __name__)
 
 
@@ -36,4 +36,15 @@ def AlgRoutes(mysql_client):
         print(response)
         return jsonify(response)
 
+    @blueprint.route("/nlp", methods=["POST"])
+    async def nlpProcess():
+        """
+        nlp processor
+        :return:
+        """
+        params = await request.get_json()
+        nlp = NLPClass(params=params)
+        response = await nlp.deal()
+        return jsonify(response)
+
     return blueprint

+ 1 - 0
routes/nlpServer.py

@@ -43,6 +43,7 @@ class NLPClass(object):
                 print("sensitive")
             case "similarity":
                 print("similarity")
+
     async def deal(self):
         """
         处理代码

+ 2 - 2
test/rank_dev.py

@@ -5,9 +5,9 @@ import json
 
 import requests
 
-# url = "http://61.48.133.26:6060/articleRank"
+url = "http://61.48.133.26:6060/articleRank"
 
-url = "http://localhost:6060/articleRank"
+# url = "http://localhost:6060/articleRank"
 
 body = {
     "accountId": "20231213070634699511719",