nlp_dev.py 447 B

123456789101112131415161718192021222324
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import requests
  6. import time
  7. url = "http://localhost:6060/nlp"
  8. body = {
  9. "data": {
  10. "text_a": "毛主席",
  11. "text_b": "毛泽东"
  12. },
  13. "function": "similarities"
  14. }
  15. headers = {"Content-Type": "application/json"}
  16. a = time.time()
  17. response = requests.post(url=url, headers=headers, json=body)
  18. b = time.time()
  19. print(json.dumps(response.json(), ensure_ascii=False, indent=4))
  20. print(b - a)