# se creaza un script de rezumare a unuit text dintr-un fisier dat ca argument cu ajutorul nltk
# se adauga la finalul scriptului un comentariu ce reprezinta continutul fisierului dat ca argument

from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
import sys
# se citeste fisierul dat ca argument
f = open(sys.argv[1], "r")
text = f.read()
# se imparte textul in cuvinte
words = word_tokenize(text)
# se elimina stopwords
stop_words = set(stopwords.words('english'))
filtered_words = [w for w in words if not w in stop_words]
# se face rezumatul textului dat ca argument
summary = ""
for w in filtered_words:
    summary += w + " "
    # se afiseaza rezumatul
print(summary)
#scrie in fisierul rezumat.txt rezumatul textului dat ca argument
f = open("rezumat.txt", "w")
f.write(summary)
f.close()

