Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read all the files in a folder and run EFZP.py #2

Open
EvoluzTampere opened this issue Apr 15, 2019 · 1 comment
Open

read all the files in a folder and run EFZP.py #2

EvoluzTampere opened this issue Apr 15, 2019 · 1 comment

Comments

@EvoluzTampere
Copy link
Owner

import os
files_path = '/Users/xxx/Desktop/Test_SP/'
for filename in os.listdir(files_path):
# only care the txt files
if filename.endswith(".txt"):
#load data
file = open("{}/{}".format(files_path,filename))
text = file.read()
file.close()
# split into words
from nltk.tokenize import word_tokenize
tokens = word_tokenize(text)
# run the .py code
import EFZP
porter = EFZP()
stemmed = [porter.stem(word) for word in tokens]
# write on the same file with input
with open("{}/{}".format(files_path,filename), 'w') as fout:
fout.write(stemmed[:20])

@EvoluzTampere
Copy link
Owner Author

f = open("TXT_41.txt
p=zp.parse(f.read())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant