import os print("Введите номер файла: ", end='') name = str(input()) def main(): with name as input: russianAlphabet = set("йфяцычувскамепинртгоьшлбщдюзжхэъёЙФЯЦЫЧУВСКАМЕПИНРТГОЬШЛБЩДЮЗЖХЭЪЁ") allFiles = [item for item in os.listdir("Folder") if item.endswith("txt") and not item.startswith(".")] for name in allFiles[1:2]: print(name) wordList = [] with open("Folder/" + name, "r", encoding = "utf-8") as inp: for line in inp: if line[0] == "№": continue numericSymbolInWord = False tempWord = [] txt = line.lower() for char in txt: if char == "̃" or char == "҂": numericSymbolInWord = True continue elif char == "ѣ" or char == "є": tempWord.append("е") elif char == "і": tempWord.append("и") elif char == "ѳ": tempWord.append("ф") elif char == "-": if len(tempWord) == 0: continue else: if tempWord[-1] == "ъ": tempWord[-1] = "-" else: tempWord.append("-") elif char not in russianAlphabet: if len(tempWord) > 0 and not numericSymbolInWord: if tempWord[-1] == "ъ": wordList.append("".join(tempWord[:-1])) tempWord = [] else: wordList.append("".join(tempWord)) tempWord = [] else: tempWord = [] numericSymbolInWord = False else: tempWord.append(char) if len(tempWord) > 0 and not numericSymbolInWord: if tempWord[-1] == "ъ": wordList.append("".join(tempWord[:-1])) else: wordList.append("".join(tempWord)) print(" ".join(wordList))