textblob

Python 2.7 and Textblob - TypeError: The `text` argument passed to `__init__(text)` must be a string, not <type 'list'>

ε祈祈猫儿з 提交于 2019-12-20 07:09:21
问题 Update: Issue resolved. (see comment section below.) Ultimately, the following two lines were required to transform my .csv to unicode and utilize TextBlob: row = [cell.decode('utf-8') for cell in row], and text = ' '.join(row). Original question: I am trying to use a Python library called Textblob to analyze text from a .csv file. Error I receive when I call Textblob in my code is: Traceback (most recent call last): File "C:\Users\Marcus\Documents\Blog\Python\Scripts\Brooks\textblob

How to do sentiment analysis of headlines with TextBlob and Python

社会主义新天地 提交于 2019-12-13 03:01:21
问题 I want to calculate the polarity and subjectivity for some headlines that I have. My code works fine, it does not gives any error but for some rows it gives result 0.00000 for polarity and subjectivity. Do you know why? You can download the data form here: https://www.sendspace.com/file/e8w4tw Am I doing something wrong? This is the code: import pandas as pd from textblob import TextBlob pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 500) pd.set_option('display

Text search using python

雨燕双飞 提交于 2019-12-11 02:26:10
问题 I am working on a text search project, and using text blob to search for sentences from text. TextBlob pulls all the sentences with the keywords efficiently. However for effective research i also want to pull out one sentence before and one after which I am unable to figure. Below is the code I am using: def extraxt_sents(Text,word): search_words = set(word.split(',')) sents = ''.join([s.lower() for s in Text]) blob = TextBlob(sents) matches = [str(s) for s in blob.sentences if search_words &

Unable to get up and running with TextBlob

拥有回忆 提交于 2019-12-10 10:02:21
问题 This morning I set out to install the TextBlob module found at https://textblob.readthedocs.org/en/latest/index.html Per the installation documentation I first ran: pip install -U textblob Now if I run that command I get the following: Requirement already up-to-date: textblob in /Library/Python/2.7/site-packages/textblob-0.5.0-py2.7.egg Requirement already up-to-date: PyYAML in /Library/Python/2.7/site-packages (from textblob) Cleaning up... While it would appear to be installed, when I try

Text classification performance

余生颓废 提交于 2019-12-08 06:11:21
问题 So i am using textblob python library, but the performance is lacking. I already serialize it and load it before the loop( using pickle ). It currently takes ~ 0.1( for small training data ) and ~ 0.3 on 33'000 test data. I need to make it faster, is it even possible ? Some code: # Pass trainings before loop, so we can make performance a lot better trained_text_classifiers = load_serialized_classifier_trainings(config["ALL_CLASSIFICATORS"]) # Specify witch classifiers are used by witch

TextBlob installation in windows

空扰寡人 提交于 2019-12-05 21:23:44
I have followed the instruction in Trouble installing TextBlob for Python for TextBlob installation in the Windows 7. It got installed but when I go to Python Idle and type import TextBlob it says No module named TextBlob How to solve this problem? Or can I directly place the libraries associated with the package in the Python Lib folder and try to import it in the program? If it is advisable please tell the procedure to do that. Will it work? Any help will be highly appreciated. Try this: from textblob import TextBlob Source: TextBlob package description In Windows, if you try installing

python textblob and text classification

醉酒当歌 提交于 2019-12-03 09:00:38
I'm trying do build a text classification model with python and textblob , the script is runing on my server and in the future the idea is that users will be able to submit their text and it will be classified. i'm loading the training set from csv : # -*- coding: utf-8 -*- import sys import codecs sys.stdout = open('yyyyyyyyy.txt',"w"); from nltk.tokenize import word_tokenize from textblob.classifiers import NaiveBayesClassifier with open('file.csv', 'r', encoding='latin-1') as fp: cl = NaiveBayesClassifier(fp, format="csv") print(cl.classify("some text")) csv is about 500 lines long (with

I cant import textblob package

不打扰是莪最后的温柔 提交于 2019-12-02 20:47:52
问题 I installed textblob using the command pip install . But now I am trying to import it and I get the following error: ModuleNotFoundError: No module named 'textblob' I am using Spyder in a windows 10 system from textblob import TextBlob C:\Users\Diego>pip install textblob Requirement already satisfied: textblob in c:\users\diego\appdata\local\programs\python\python36-32\lib\site-packages (0.15.2) Requirement already satisfied: nltk>=3.1 in c:\users\diego\appdata\local\programs\python\python36

Python 2.7 and Textblob - TypeError: The `text` argument passed to `__init__(text)` must be a string, not <type 'list'>

泪湿孤枕 提交于 2019-12-02 12:28:09
Update: Issue resolved. (see comment section below.) Ultimately, the following two lines were required to transform my .csv to unicode and utilize TextBlob: row = [cell.decode('utf-8') for cell in row], and text = ' '.join(row). Original question: I am trying to use a Python library called Textblob to analyze text from a .csv file. Error I receive when I call Textblob in my code is: Traceback (most recent call last): File "C:\Users\Marcus\Documents\Blog\Python\Scripts\Brooks\textblob_sentiment.py", line 30, in blob = TextBlob(row) File "C:\Python27\lib\site-packages\textblob\blob.py", line 344

Replace apostrophe/short words in python

只愿长相守 提交于 2019-12-01 06:40:43
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. abccd 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 like this one: contractions = { "ain't": "am not / are not", "aren't": "are not / am not", "can't":