0
が、私はこの行の問題を持って予想外のキーワード引数を得ましたか。あなたが唯一のprocess
のための関数のシグネチャ内の1つのキーワード引数filters
(def process(...)
ライン)を定義定義された関数は
def process(text, filters=nltk.corpus.stopwords.words('english')):
""" Normalizes case and handles punctuation
Inputs:
text: str: raw text
lemmatizer: an instance of a class implementing the lemmatize() method
(the default argument is of type nltk.stem.wordnet.WordNetLemmatizer)
Outputs:
list(str): tokenized text
"""
lemmatizer=nltk.stem.wordnet.WordNetLemmatizer()
word_list = nltk.word_tokenize(text);
lemma_list = [];
for i in word_list:
if i not in filters:
try:
lemma = lemmatizer.lemmatize(i);
lemma_list.append(str(lemma));
except:
pass
return " ".join(lemma_list)
if __name__ == '__main__':
#construct filter for processor
file = open("accountant.txt").read().lower()
filters = set(nltk.word_tokenize(file))
filters.update(nltk.corpus.stopwords.words('english'))
filters = list(filters)
#webcrawling
webContent = []
dataJobs = pd.read_csv("test.csv");
webContent = []
for i in dataJobs["url"]:
content = webCrawl(i);
webContent.append(content);
#clean the crawled text
cleaned_list = []
for j in webContent:
cleaned = extractUseful(j);
processed = process(cleaned, lemmatizer=nltk.stem.wordnet.WordNetLemmatizer());
cleaned_list.append(processed)
#save to csv
contents = pd.DataFrame({ "Content":webContent, "Cleaned": cleaned_list})
contents.to_csv("testwebcrawled.csv")
dataJobs[['jd']]= cleaned_list
dataJobs.to_csv("test_v2_crawled.csv")
してください[編集]あなたの質問あなたのインデントを修正する、と**フルテキストを追加する**すべてのエラーのかトレースバック。さらに、Pythonには行終了文字はありません。すべてのセミコロン ';'は完全に不要です。 – MattDMo