用户水军识别应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
8.6 KiB

  1. #coding:utf8
  2. import re
  3. import json
  4. from jsonpath_ng import jsonpath, parse
  5. import traceback
  6. from log_util.set_logger import set_logger
  7. def parse_data(raw_data,url):
  8. val = None
  9. try:
  10. if "#json#" in url:
  11. parm = url.split("#")
  12. data1 = parse_data(raw_data, parm[0])
  13. data1_json = json.loads(data1)
  14. expr = parse(parm[2])
  15. match = [match.value for match in expr.find(data1_json)]
  16. val = match[0]
  17. else:
  18. all_result = raw_data['data']
  19. param_split = str(url).split(":")
  20. datasourcestr = all_result[param_split[0]]
  21. datasource = json.loads(datasourcestr)
  22. # 创建 JsonPath 表达式对象
  23. expr = parse(param_split[1])
  24. # 使用表达式来选择 JSON 元素
  25. match = [match.value for match in expr.find(datasource)]
  26. val = match[0]
  27. except Exception as e:
  28. traceback.print_exc()
  29. val = ''
  30. return val
  31. def get_content(inputdata,logging):
  32. """
  33. :param inputdata:json数据
  34. :return: prompt及其他参数
  35. """
  36. res={}
  37. admin=inputdata["metadata"]["admin"]
  38. data=inputdata["data"]
  39. prompt=admin["prompt"]
  40. if_user=re.findall("{{(.*)}}",prompt)
  41. if_data=re.findall("@@(.*)@@",prompt)
  42. if if_user != []:
  43. user_data=inputdata["metadata"]["user"]
  44. if if_user[0] in user_data.keys():
  45. tmp=user_data[if_user[0]]
  46. prompt=re.sub("{{(.*)}}",tmp,prompt)
  47. if if_data!=[] and if_data[0] in data.keys():
  48. tmp1=data[if_data[0]]
  49. prompt=re.sub("@@(.*)@@",tmp1,prompt)
  50. res["prompt"]=prompt
  51. res["authorization"]=admin["authorization"]
  52. res["model"]=admin["model"]
  53. res["temperature"]=admin["temperature"]
  54. res["authorization"]=admin["authorization"]
  55. res["top_p"]=admin["top_p"]
  56. res["n"]=admin["n"]
  57. return res
  58. if __name__=="__main__":
  59. datasourcestr = '{"author": "Pelham@Resist_05", "authorId": "1430497892314218502", "authornickname": "", "commentsCount": 2518, "content": "Israeli Army Commander admits they handcuffed 2 couples inside a house then used tanks to destroy the building.15 civilians were burned to death including 8 babies… https://t.co/1V4iUsA3RM", "crawlTimeStr": "2024-01-03 17:39:25", "fansCount": "", "friendsCount": "", "otherInfoJson": "", "pageType": "storyDetailPage", "postCount": "", "postId": "1733008513163784237", "pubTimeStr": "2023-12-08 14:20:01", "subjectId": "304904", "taskId": "1111881", "userType": ""}'
  60. datasource = json.loads(datasourcestr)
  61. # logging.info("数据源:{}".format(datasource))
  62. # 创建 JsonPath 表达式对象
  63. expr = parse("$.crawlTimeStr")
  64. # 使用表达式来选择 JSON 元素
  65. match = [match.value for match in expr.find(datasource)]
  66. val = match[0]
  67. print(val)
  68. # inputdata={
  69. # "metadata":{
  70. # "output":{
  71. # "output_type":"table",
  72. # "label_col":[
  73. # "软件著作抽取结果"
  74. # ]
  75. # },
  76. # "input":{
  77. # "input_type":"text",
  78. # "label":[
  79. # "7_软件著作过滤器"
  80. # ]
  81. # },
  82. # "address":"http://172.18.1.181:9011/chatGpt/",
  83. # "admin":{
  84. # "authorization":"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",
  85. # "top_p":"1",
  86. # "user_input":[
  87. # {
  88. # "keyname":"tag",
  89. # "keydesc":""
  90. # }
  91. # ],
  92. # "temperature":"0.2",
  93. # "model":"gpt-3.5-turbo-16k",
  94. # "prompt":"请在下面这句话中提取出:证书号、软件名称、著作权人,以json格式输出,找不到的字段赋值为空字符串,不要有多余的文字输出,只输出json结构。@@7_软件著作过滤器@@",
  95. # "n":"1"
  96. # },
  97. # "index":1
  98. # },
  99. # "data":{
  100. # "1_项目文件上传":"[{ \"fileUrl\":\"http://172.18.1.130:9985/group33/default/20230816/16/05/1/1-基于时间序列遥感 影像洪涝检测系统.jpg\",\"fileType\":\"jpg\", \"filePath\":\"/软件著作/1-基于时间序列遥感 影像洪涝检测系统.jpg\",\"fileId\":\"cd6592f0389bb1da25afbb44901f9cde\",\"fileName\":\"1-基于时间序列遥感 影像洪涝检测系统.jpg\" },{ \"fileUrl\":\"http://172.18.1.130:9985/group33/default/20230816/16/06/1/2-基于遥感影像的快速变化检测系统.jpg\",\"fileType\":\"jpg\", \"filePath\":\"/软件著作/2-基于遥感影像的快速变化检测系统.jpg\",\"fileId\":\"338847e34904fa96e8834cb220667db8\",\"fileName\":\"2-基于遥感影像的快速变化检测系统.jpg\" },{ \"fileUrl\":\"http://172.18.1.130:9985/group33/default/20230816/16/08/1/3-基于时空模型的遥感时间序列森林火灾检测系统.jpg\",\"fileType\":\"jpg\", \"filePath\":\"/软件著作/1/3-基于时空模型的遥感时间序列森林火灾检测系统.jpg\",\"fileId\":\"944eec1cf98f216ea953459dac4dd505\",\"fileName\":\"3-基于时空模型的遥感时间序列森林火灾检测系统.jpg\" },{ \"fileUrl\":\"http://172.18.1.130:9985/group33/default/20230816/16/09/1/4-基于隐马尔可夫模型的遥感时间序列分类系统.jpg\",\"fileType\":\"jpg\", \"filePath\":\"/软件著作/4-基于隐马尔可夫模型的遥感时间序列分类系统.jpg\",\"fileId\":\"eb378cb9ee914323f601500378dfad76\",\"fileName\":\"4-基于隐马尔可夫模型的遥感时间序列分类系统.jpg\" }]",
  101. # "2_文件分类信息":"{\"软件著作\":4}",
  102. # "3_OCR识别内容":"{\"content\":\" 22222222222222222222222222222222222222222222222222\\n中华人民共和国国家版权局\\n计算机软件著作权登记证书\\n证书号:软著登字第1623261号\\n软件名称:\\n基于遥感影像的快速变化检测系统\\nV1.0\\n著作权人:中国科学院遥感与数字地球研究所\\n开发完成日期:2016年08月01日\\n首次发表日期:未发表\\n权利取得方式:原始取得\\n权利范围:全部权利\\n登记号:2017SR037977\\n根据《计算机软件保护条例》和《计算机软件著作权登记办法》的\\n规定,经中国版权保护中心审核,对以上事项予以登记\\n计算机软件著作权\\n登记专用章\\n2017年02月10日\\nNo.01433672\",\"fileId\":\"338847e34904fa96e8834cb220667db8\",\"fileName\":\"2-基于遥感影像的快速变化检测系统.jpg\",\"filePath\":\"/软件著作/2-基于遥感影像的快速变化检测系统.jpg\",\"fileType\":\"jpg\",\"fileUrl\":\"http://172.18.1.130:9985/group33/default/20230816/16/06/1/2-基于遥感影像的快速变化检测系统.jpg\",\"pageNum\":1}",
  103. # "businessKey":"185aef3b1c810799a6be8314abf6512c",
  104. # "7_软件著作过滤器":"{\"content\":\" 22222222222222222222222222222222222222222222222222\\n中华人民共和国国家版权局\\n计算机软件著作权登记证书\\n证书号:软著登字第1623261号\\n软件名称:\\n基于遥感影像的快速变化检测系统\\nV1.0\\n著作权人:中国科学院遥感与数字地球研究所\\n开发完成日期:2016年08月01日\\n首次发表日期:未发表\\n权利取得方式:原始取得\\n权利范围:全部权利\\n登记号:2017SR037977\\n根据《计算机软件保护条例》和《计算机软件著作权登记办法》的\\n规定,经中国版权保护中心审核,对以上事项予以登记\\n计算机软件著作权\\n登记专用章\\n2017年02月10日\\nNo.01433672\",\"fileId\":\"338847e34904fa96e8834cb220667db8\",\"fileName\":\"2-基于遥感影像的快速变化检测系统.jpg\",\"filePath\":\"/软件著作/2-基于遥感影像的快速变化检测系统.jpg\",\"fileType\":\"jpg\",\"fileUrl\":\"http://172.18.1.130:9985/group33/default/20230816/16/06/1/2-基于遥感影像的快速变化检测系统.jpg\",\"pageNum\":1}"
  105. # },
  106. # "created":1691004265000,
  107. # "module":"OCR",
  108. # "start_tag":"false",
  109. # "last_edit":1692464331000,
  110. # "next_app_id":[
  111. # {
  112. # "start_id":86,
  113. # "edge_id":49,
  114. # "end_id":90
  115. # }
  116. # ],
  117. # "transfer_id":11,
  118. # "blueprint_id":3,
  119. # "scenes_id":3,
  120. # "scenario":{
  121. # "dataloss":1,
  122. # "autoCommitTriggerLast":1,
  123. # "maxErrors":3,
  124. # "autoCommit":1,
  125. # "freshVariables":1
  126. # },
  127. # "wait_condition":[
  128. #
  129. # ],
  130. # "scheduling":{
  131. # "interval":-1,
  132. # "type":"single"
  133. # },
  134. # "name":"软件著作抽取",
  135. # "businessKey":"185aef3b1c810799a6be8314abf6512c",
  136. # "id":86,
  137. # "describe":"软件著作抽取"
  138. # }
  139. # a=get_content(inputdata,"")
  140. # print(a)