Created
February 26, 2024 14:54
-
-
Save bilhox/4fe92002d7f01f3985e00e8c47827f25 to your computer and use it in GitHub Desktop.
Récupère le texte du fichier passé en argument lors de l'exécution, et crée un fichier avec tout les mots utilisés sans doublon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
text = "" | |
ponctuation = ['?', '...', '..', '.', ':', '"', "'", '!', ';', ',', '/', '&'] | |
with open(sys.argv[1], mode='r', newline='') as reader: | |
for line in reader.readlines(): | |
for c in line.strip(): | |
if c not in ponctuation: | |
text += c | |
words = set([w.strip().lower() for w in text.split()]) | |
with open("result.txt", mode="w") as writer: | |
for word in words: | |
writer.write(word + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment