1
0

plagiat_1.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import os
  2. from difflib import SequenceMatcher
  3. from tqdm import tqdm
  4. import datetime
  5. import requests
  6. # директория файла
  7. BASE_DIR = os.path.abspath(os.path.dirname(__file__))
  8. # ссылка для проверки
  9. url = "http://213.155.192.79:3001/ypv/up/raw/master/%d0%ad%d0%90%d0%a1%d0%b2%d0%97%d0%98/%d0%9b%d0%b5%d0%ba%d1%86%d0%b8%d0%b8/1.3.300_%d0%9a%d1%80%d0%b8%d1%82%d0%b5%d1%80%d0%b8%d0%b8_%d0%ba%d0%bb%d0%b0%d1%81%d1%81%d0%b8%d1%84%d0%b8%d0%ba%d0%b0%d1%86%d0%b8%d0%b8_%d1%83%d0%b3%d1%80%d0%be%d0%b7/Doc.md"
  10. print()
  11. response = requests.get(url)
  12. post_html = response.text
  13. post_list = post_html.split("\n")
  14. print(post_list[0])
  15. exit()
  16. files_paths = []
  17. dirs = os.listdir(BASE_DIR)
  18. for dir in dirs:
  19. dir_path = os.path.join(BASE_DIR, dir)
  20. if os.path.isdir(dir_path) and (dir != "__pycache__"):
  21. files = os.listdir(dir_path)
  22. for file in files:
  23. file_path = os.path.join(BASE_DIR, dir, file)
  24. filename, fileext = os.path.splitext(file)
  25. if os.path.isfile(file_path) and (fileext=='.md'):
  26. files_paths.append(file_path)
  27. out_str = ""
  28. max_ratio = 0
  29. max_ratio_file = ""
  30. for file_1 in tqdm(files_paths):
  31. small_filename_1 = str(file_1).replace(BASE_DIR, "").strip("\\")
  32. try:
  33. with open(file_1, encoding="utf-8") as f_1:
  34. str1 = f_1.read()
  35. except:
  36. with open(file_1, encoding="cp1251") as f_1:
  37. str1 = f_1.read()
  38. f_1.close()
  39. with open(file_1, 'w', encoding="utf-8") as f_1:
  40. f_1.write(str1)
  41. f_1.close()
  42. ratio = int(SequenceMatcher(None, str1.lower(), post_html.lower()).ratio() * 100)
  43. if (ratio > 70):
  44. out_str += f"{small_filename_1}\n"
  45. out_str += f"ratio = {ratio}\n"
  46. if (ratio > max_ratio):
  47. max_ratio = ratio
  48. max_ratio_file = small_filename_1
  49. print(out_str)
  50. print()
  51. print(f"max ratio: {max_ratio}%")
  52. print(f"max ratio file: {max_ratio_file}")
  53. print("success")