123456789101112131415161718192021222324252627282930313233343536373839404142 |
- """
- https://www.cyberforum.ru/python-graphics/thread2712141.html
- """
- import os
- from difflib import SequenceMatcher
- # директория файла
- BASE_DIR = os.path.abspath(os.path.dirname(__file__))
- files_path = []
- dirs = os.listdir(BASE_DIR)
- print(dirs)
- for dir in dirs:
- dir_path = os.path.join(BASE_DIR, dir)
- if os.path.isdir(dir_path) and (dir != "__pycache__"):
- files = os.listdir(dir_path)
- for file in files:
- file_path = os.path.join(BASE_DIR, dir, file)
- filename, fileext = os.path.splitext(file)
- if os.path.isfile(file_path) and (fileext=='.md'):
- files_path.append(file_path)
- for file_1 in files_path:
- for file_2 in files_path:
- if (file_1 != file_2):
- with open(file_1, encoding="utf-8") as f_1:
- str1 = f_1.read()
- with open(file_2, encoding="utf-8") as f_2:
- str2 = f_2.read()
- ratio = int(SequenceMatcher(None, str1.lower(), str2.lower()).ratio() * 100)
- if (ratio > 70):
- print(file_2)
- print(file_1)
- print(f"ratio = {ratio}")
- print()
- print("success")
|