From 7a7bd82224f5332ae6c60bae21e2b1f89daab2f9 Mon Sep 17 00:00:00 2001 From: ogunbanwo opeyemi <58431589+papycoda@users.noreply.github.com> Date: Sat, 1 Jan 2022 14:27:15 +0100 Subject: [PATCH] Update NLP for Text Classification (Jupyter Notebook).ipynb edited the print (key), and passed the set of stopped words into a list to fix syntax errors and attribute has no len function errors respectively --- NLP for Text Classification (Jupyter Notebook).ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NLP for Text Classification (Jupyter Notebook).ipynb b/NLP for Text Classification (Jupyter Notebook).ipynb index 2f8b3de..b7d1d37 100644 --- a/NLP for Text Classification (Jupyter Notebook).ipynb +++ b/NLP for Text Classification (Jupyter Notebook).ipynb @@ -352,9 +352,9 @@ "source": [ "from nltk.corpus import stopwords\n", "\n", - "# remove stop words from text messages\n", + "# remove stop words from text messages,and passed result into a list\n", "\n", - "stop_words = set(stopwords.words('english'))\n", + "stop_words = list(set(stopwords.words('english')))\n", "\n", "processed = processed.apply(lambda x: ' '.join(\n", " term for term in x.split() if term not in stop_words))" @@ -461,7 +461,7 @@ "features = find_features(processed[0])\n", "for key, value in features.items():\n", " if value == True:\n", - " print key" + " print (key)" ] }, { @@ -546,7 +546,7 @@ "# train the model on the training data\n", "model.train(training)\n", "\n", - "# and test on the testing dataset!\n", + "# and test on the testing dataset!(warning, this might take some time,so go make yourself a good meal, you desereve it)\n", "accuracy = nltk.classify.accuracy(model, testing)*100\n", "print(\"SVC Accuracy: {}\".format(accuracy))" ]