Ich habe diesen Code, den ich seit einiger Zeit verwende. Ich frage mich, ob es eine Möglichkeit gibt, CSV-Datei pro Zeile (Twitter-Feeds) zu lesen und die Ausgabe in CSV zu exportieren.NLTK POS Tags - CSV kann nicht exportiert werden
Ich bin im Idealfall auf der Suche nach Substantiv Begriffe pro Zeile, d. H. In meinem Fall ein Twitter-Feed.
Hier ist der Code. Es tut mir leid, aber ich bin neu in Python.
import nltk
essays = u"""text here"""
tokens = nltk.word_tokenize(essays)
tagged = nltk.pos_tag(tokens)
nouns = [word for word,pos in tagged \
\t if (pos == 'NN' or pos == 'NNP' or pos == 'NNS' or pos == 'NNPS')]
downcased = [x.lower() for x in nouns]
joined = " ".join(downcased).encode('utf-8')
into_string = str(nouns)
output = open("output.txt", "w")
output.write(joined)
output.close()