textblob

Replace apostrophe/short words in python

情到浓时终转凉″ 提交于 2019-12-01 02:52:37
问题 I am using python to clean a given sentence. Suppose that my sentence is: What's the best way to ensure this? I want to convert: What's -> What is Similarly, must've -> must have Also, verbs to original form, told -> tell Singular to plural, and so on. I am currently exploring textblob. But not all of the above is possible using it. 回答1: For the first question, there isn't a direct module that does that for you so you will have to build your own, first you will need a contraction dictionary

Python pickle error: UnicodeDecodeError

吃可爱长大的小学妹 提交于 2019-11-30 07:47:50
I'm trying to do some text classification using Textblob. I'm first training the model and serializing it using pickle as shown below. import pickle from textblob.classifiers import NaiveBayesClassifier with open('sample.csv', 'r') as fp: cl = NaiveBayesClassifier(fp, format="csv") f = open('sample_classifier.pickle', 'wb') pickle.dump(cl, f) f.close() And when I try to run this file: import pickle f = open('sample_classifier.pickle', encoding="utf8") cl = pickle.load(f) f.close() I get this error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

Python pickle error: UnicodeDecodeError

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 10:29:51
问题 I'm trying to do some text classification using Textblob. I'm first training the model and serializing it using pickle as shown below. import pickle from textblob.classifiers import NaiveBayesClassifier with open('sample.csv', 'r') as fp: cl = NaiveBayesClassifier(fp, format="csv") f = open('sample_classifier.pickle', 'wb') pickle.dump(cl, f) f.close() And when I try to run this file: import pickle f = open('sample_classifier.pickle', encoding="utf8") cl = pickle.load(f) f.close() I get this

nltk NaiveBayesClassifier training for sentiment analysis

主宰稳场 提交于 2019-11-26 15:13:45
I am training the NaiveBayesClassifier in Python using sentences, and it gives me the error below. I do not understand what the error might be, and any help would be good. I have tried many other input formats, but the error remains. The code given below: from text.classifiers import NaiveBayesClassifier from text.blob import TextBlob train = [('I love this sandwich.', 'pos'), ('This is an amazing place!', 'pos'), ('I feel very good about these beers.', 'pos'), ('This is my best work.', 'pos'), ("What an awesome view", 'pos'), ('I do not like this restaurant', 'neg'), ('I am tired of this

nltk NaiveBayesClassifier training for sentiment analysis

空扰寡人 提交于 2019-11-26 04:19:12
问题 I am training the NaiveBayesClassifier in Python using sentences, and it gives me the error below. I do not understand what the error might be, and any help would be good. I have tried many other input formats, but the error remains. The code given below: from text.classifiers import NaiveBayesClassifier from text.blob import TextBlob train = [(\'I love this sandwich.\', \'pos\'), (\'This is an amazing place!\', \'pos\'), (\'I feel very good about these beers.\', \'pos\'), (\'This is my best