1
0

plagiat.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """
  2. https://www.cyberforum.ru/python-graphics/thread2712141.html
  3. """
  4. import os
  5. from difflib import SequenceMatcher
  6. # директория файла
  7. BASE_DIR = os.path.abspath(os.path.dirname(__file__))
  8. files_path = []
  9. dirs = os.listdir(BASE_DIR)
  10. print(dirs)
  11. for dir in dirs:
  12. dir_path = os.path.join(BASE_DIR, dir)
  13. if os.path.isdir(dir_path) and (dir != "__pycache__"):
  14. files = os.listdir(dir_path)
  15. for file in files:
  16. file_path = os.path.join(BASE_DIR, dir, file)
  17. filename, fileext = os.path.splitext(file)
  18. if os.path.isfile(file_path) and (fileext=='.md'):
  19. files_path.append(file_path)
  20. for file_1 in files_path:
  21. for file_2 in files_path:
  22. if (file_1 != file_2):
  23. with open(file_1, encoding="utf-8") as f_1:
  24. str1 = f_1.read()
  25. with open(file_2, encoding="utf-8") as f_2:
  26. str2 = f_2.read()
  27. ratio = int(SequenceMatcher(None, str1.lower(), str2.lower()).ratio() * 100)
  28. if (ratio > 70):
  29. print(file_2)
  30. print(file_1)
  31. print(f"ratio = {ratio}")
  32. print()
  33. print("success")