Folgende Fehlermeldung (siehe unten) kann ich nicht identifizieren.
Mein nltk-modul ist geupdatet und getestet. Im Terminal funktionieren alle Funktionen ohne Probleme, aber im anhängenden Quellcode bekomme ich folgenden Fehler sobald ich irgendwas mit nltk programmieren will.
Ich hoffe jemand kann helfen..
Viele Grüße
Code: Alles auswählen
#!/usr/local/bin/python
#coding: utf-8
import os
import sys
reload(sys)
sys.setdefaultencoding('Cp1252')
import re
import nltk
from nltk import sent_tokenize, word_tokenize, pos_tag
def load_words(filename):
with open(filename, 'r') as text_file:
return text_file.read().split()
def nlp_textrazor():
path = 'Input'
filenames = os.listdir(path)
print filenames
stop_words = set(load_words('stopwords.txt'))
tokens = word_tokenize(words)
len(tokens)
print len(tokens)
for filename in filenames:
print 'Processing:', filename
words = load_words(os.path.join(path, filename))
with open(filename, 'w') as filtered_file:
for word in (w for w in words if w not in stop_words):
filtered_file.write(word + '\n')
nlp_textrazor()
File "master.py", line 8, in <module>
from nltk import sent_tokenize, word_tokenize, pos_tag
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 89, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python2.7/dist-packages/nltk/internals.py", line 29, in <module>
from nltk import compat
File "/usr/local/lib/python2.7/dist-packages/nltk/compat.py", line 101, in <module>
from urllib2 import (urlopen, HTTPError, URLError,
File "/usr/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 73, in <module>
from urlparse import urlsplit
File "/usr/lib/python2.7/urlparse.py", line 119, in <module>
from collections import namedtuple
File "/usr/lib/python2.7/collections.py", line 10, in <module>
from keyword import iskeyword as _iskeyword
ImportError: cannot import name iskeyword