Using CountVectorizer to extract from text

train_documents = [line[1] for line in lines]
train_documents

output:
[‘0’,
‘1’,
‘1’,
‘0’,
‘1’,
‘0’,
‘0’,
‘1’,
‘0’,
‘0’,
‘1’,
‘1’,
‘0’,
‘1’,
‘0’,
‘0’,
‘0’]

from sklearn.feature_extraction.text import CountVectorizer

count_vectorizer = CountVectorizer(binary=‘true’)
train_documents = count_vectorizer.fit_transform(train_documents)

output:

ValueError Traceback (most recent call last)
in
1 count_vectorizer = CountVectorizer(binary=‘true’)
----> 2 train_documents = count_vectorizer.fit_transform(train_documents)

~\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py in fit_transform(self, raw_documents, y)
1218
1219 vocabulary, X = self.count_vocab(raw_documents,
-> 1220 self.fixed_vocabulary
)
1221
1222 if self.binary:

~\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py in _count_vocab(self, raw_documents, fixed_vocab)
1148 vocabulary = dict(vocabulary)
1149 if not vocabulary:
-> 1150 raise ValueError(“empty vocabulary; perhaps the documents only”
1151 " contain stop words")
1152

ValueError: empty vocabulary; perhaps the documents only contain stop words

CountVectorizer finds words in your text using the token_pattern regex. By default this only matches a word if it is at least 2 characters long, and will only generate counts for those words.

In your case, the words are only ‘0’ and ‘1’ which are both just 1 character, so they get excluded from the vocabulary, meaning that fit_transform fails.

You can fix this by passing in a different regex to token_pattern, but CountVectorizer only really makes sense when the input data is made up of words/sentences. If you are just looking to get a count of some non-text data you would be better off using something like OneHotEncoder

1 Like

Hi lrjball,

I should have gave you the complete project sorry about that. This might make more since:

with open(“C:/Users/user/Documents/Python/Data/sentiment labelled sentences/imdb_labelled.txt”, “r”) as text_file:
lines = text_file.read().split(’\n’)

lines

Out:

[‘A very, very, very slow-moving, aimless movie about a distressed, drifting young man. \t0’,
‘Not sure who was more lost - the flat characters or the audience, nearly half of whom walked out. \t0’,
‘Attempting artiness with black & white and clever camera angles, the movie disappointed - became even more ridiculous - as the acting was poor and the plot and lines almost non-existent. \t0’,
‘Very little music or anything to speak of. \t0’,
‘The best scene in the movie was when Gerardo is trying to find a song that keeps running through his head. \t1’,
“The rest of the movie lacks art, charm, meaning… If it’s about emptiness, it works I guess because it’s empty. \t0”,
‘Wasted two hours. \t0’,
‘Saw the movie today and thought it was a good effort, good messages for kids. \t1’,
‘A bit predictable. \t0’,
‘Loved the casting of Jimmy Buffet as the science teacher. \t1’,
‘And those baby owls were adorable. \t1’,
“The movie showed a lot of Florida at it’s best, made it look very appealing. \t1”,
‘The Songs Were The Best And The Muppets Were So Hilarious. \t1’,
‘It Was So Cool. \t1’,
‘This is a very “right on case” movie that delivers everything almost right in your face. \t1’,
‘It had some average acting from the main person, and it was a low budget as you clearly can see. \t0’,
‘This review is long overdue, since I consider A Tale of Two Sisters to be the single greatest film ever made. \t1’]

with open(“C:/Users/user/Documents/Python/Data/sentiment labelled sentences/yelp_labelled.txt”, “r”) as text_file:
lines = text_file.read().split(’\n’)
with open(“C:/Users/user/Documents/Python/Data/sentiment labelled sentences/amazon_cells_labelled.txt”, “r”) as text_file:
lines = text_file.read().split(’\n’)

lines = [line.split("\t") for line in lines if len(line.split("\t"))==2 and line.split("\t")[1]!=’’]

lines

Out

[[‘So there is no way for me to plug it in here in the US unless I go by a converter.’,
‘0’],
[‘Good case, Excellent value.’, ‘1’],
[‘Great for the jawbone.’, ‘1’],
[‘Tied to charger for conversations lasting more than 45 minutes.MAJOR PROBLEMS!!’,
‘0’],
[‘The mic is great.’, ‘1’],
[‘I have to jiggle the plug to get it to line up right to get decent volume.’,
‘0’],
[‘If you have several dozen or several hundred contacts, then imagine the fun of sending each of them one by one.’,
‘0’],
[‘If you are Razr owner…you must have this!’, ‘1’],
[‘Needless to say, I wasted my money.’, ‘0’],
[‘What a waste of money and time!.’, ‘0’],
[‘And the sound quality is great.’, ‘1’],
[‘He was very impressed when going from the original battery to the extended battery.’,
‘1’],
[‘If the two were seperated by a mere 5+ ft I started to notice excessive static and garbled sound from the headset.’,
‘0’],
[‘Very good quality though’, ‘1’],
[‘The design is very odd, as the ear “clip” is not very comfortable at all.’,
‘0’],
[‘Highly recommend for any one who has a blue tooth phone.’, ‘1’],
[‘I advise EVERYONE DO NOT BE FOOLED!’, ‘0’],
[‘So Far So Good!.’, ‘1’],
[‘Works great!.’, ‘1’],
[‘It clicks into place in a way that makes you wonder how long that mechanism would last.’,
‘0’],
[“I went on Motorola’s website and followed all directions, but could not get it to pair again.”,
‘0’],
[‘I bought this to use with my Kindle Fire and absolutely loved it!’, ‘1’],
[‘The commercials are the most misleading.’, ‘0’],
[“I have yet to run this new battery below two bars and that’s three days without charging.”,
‘1’],
[‘I bought it for my mother and she had a problem with the battery.’, ‘0’],
[‘Great Pocket PC / phone combination.’, ‘1’],
[“I’ve owned this phone for 7 months now and can say that it’s the best mobile phone I’ve had.”,
‘1’],
[“I didn’t think that the instructions provided were helpful to me.”, ‘0’],
[‘People couldnt hear me talk and I had to pull out the earphone and talk on the phone.’,
‘0’],
[“Doesn’t hold charge.”, ‘0’],
[‘This is a simple little phone to use, but the breakage is unacceptible.’,
‘0’],
[‘This product is ideal for people like me whose ears are very sensitive.’,
‘1’],
[‘It is unusable in a moving car at freeway speed.’, ‘0’],
[‘I have two more years left in this contract and I hate this phone.’, ‘0’],
[‘Car charger as well as AC charger are included to make sure you never run out of juice.Highy recommended’,
‘1’],
[‘You need at least 3 mins to get to your phone book from the time you first turn on the phone.Battery life is short.’,
‘0’],
[‘It has kept up very well.’, ‘1’],
[‘Poor Talk Time Performance.’, ‘0’],
[‘The case is great and works fine with the 680.’, ‘1’],
[‘worthless product.’, ‘0’],
[‘It has a great camera thats 2MP, and the pics are nice and clear with great picture quality.’,
‘1’],
[‘I was not impressed by this product.’, ‘0’],
[‘Nice headset priced right.’, ‘1’],
[‘I only hear garbage for audio.’, ‘0’],
[‘Excellent bluetooth headset.’, ‘1’],
[‘It has all the features I want’, ‘1’],
[‘Who in their right mind is gonna buy this battery?.’, ‘0’],
[‘AFTER ARGUING WITH VERIZON REGARDING THE DROPPED CALLS WE RETURNED THE PHONES AFTER TWO DAYS.’,
‘0’],
[‘This case seems well made.’, ‘1’],
[‘Disappointed with battery.’, ‘0’],
[“Not loud enough and doesn’t turn on like it should.”, ‘0’],
[‘good protection and does not make phone too bulky.’, ‘1’],
[‘A usable keyboard actually turns a PDA into a real-world useful machine instead of just a neat gadget.’,
‘1’],
[“This phone is pretty sturdy and I’ve never had any large problems with it.”,
‘1’],
[‘I love this thing!’, ‘1’],
[‘Everything about it is fine and reasonable for the price i.e.’, ‘1’],
[‘VERY DISAPPOINTED.’, ‘0’],
[‘I even dropped this phone into a stream and it was submerged for 15 seconds and it still works great!’,
‘1’],
[‘I have been very happy with the 510 and have had NO complaints from any one regarding my sound quality on their end.’,
‘1’],
[‘The buttons for on and off are bad.’, ‘0’],
[“Essentially you can forget Microsoft’s tech support.”, ‘0’],
[‘I really recommend this faceplates since it looks very nice, elegant and cool.’,
‘1’],
[“These headphones were a great find - and I think they are perhaps the best purchase I’ve made in the last several years - seriously.”,
‘1’],
[‘Buy a different phone - but not this.’, ‘0’],
[‘You have to hold the phone at a particular angle for the other party to hear you clearly.’,
‘0’],
[“The one big drawback of the MP3 player is that the buttons on the phone’s front cover that let you pause and skip songs lock out after a few seconds.”,
‘0’],
[‘A week later after I activated it, it suddenly died.’, ‘0’],
[‘It feels more comfortable than most headsets because I wear glasses and that gets in the way sometimes.’,
‘1’],
[‘Great for iPODs too.’, ‘1’],
[‘This device is great in several situations:1.)’, ‘1’],
[“Mic Doesn’t work.”, ‘0’],
[‘Even in my BMW 3 series which is fairly quiet, I have trouble hearing what the other person is saying.’,
‘0’],
[‘Great choice!’, ‘1’],
[‘Nice docking station for home or work.’, ‘1’],
[‘This is a beautiful phone.’, ‘1’],
[‘Love this product.’, ‘1’],
[‘Do Not Buy for D807…wrongly advertised for D807.’, ‘0’],
[‘This is a great little item.’, ‘1’],
[‘I love this phone , It is very handy and has a lot of features .’, ‘1’],
[‘I purchased this and within 2 days it was no longer working!!!’, ‘0’],
[‘I wear it everyday and it holds up very well.’, ‘1’],
[‘Not a good bargain.’, ‘0’],
[‘Well packaged, arrived on time, and works as intended.’, ‘1’],
[‘The battery runs down quickly.’, ‘0’],
[‘This item worked great, but it broke after 6 months of use.’, ‘0’],
[‘The headsets are easy to use and everyone loves them.’, ‘1’],
[‘This phone works great.’, ‘1’],
[‘The construction of the headsets is poor.’, ‘0’],
[‘Product was excellent and works better than the verizon one and Boy was it cheaper!’,
‘1’],
[‘The phone loads super!’, ‘1’],
[‘For a product that costs as much as this one does, I expect it to work far better and with greater ease than this thing does.’,
‘0’],
[‘Made very sturdy.’, ‘1’],
[‘Worked great!.’, ‘1’],
[‘The ear buds only play music in one ear.’, ‘0’],
[‘Dont waste your money…’, ‘0’],
[‘Will order from them again!’, ‘1’],
[‘If you plan to use this in a car forget about it.’, ‘0’],
[‘I found this product to be waaay too big.’, ‘0’],
[“Best I’ve found so far … I’ve tried 2 other bluetooths and this one has the best quality (for both me and the listener) as well as ease of using.”,
‘1’],
[“I’m very disappointed with my decision.”, ‘0’],
[‘Integrated seamlessly with the Motorola RAZR phone.’, ‘1’],
[‘Buyer Beware, you could flush money right down the toilet.’, ‘0’],
[‘Definitely a bargain.’, ‘1’],
[‘The price was very good and with the free shipping and all it was a good purchase.’,
‘1’],
[‘I received my supposedly new motorola 375 and apparently there was not a match between the phone and the charger.’,
‘0’],
[‘Pros:-Good camera - very nice pictures , also has cool styles like black and white, and more.’,
‘1’],
[“That’s a huge design flaw (unless I’m not using it correctly, which I don’t think is the case).”,
‘0’],
[‘I love my 350 headset… My Jabra350 bluetooth headset is great, the reception is very good and the ear piece is a comfortable fit.’,
‘1’],
[‘The camera, although rated at an impressive 1.3 megapixels, renders images that fall well below expectations of such a relatively high resolution.’,
‘0’],
[‘I purcashed this for the car charger and it does not work.’, ‘0’],
[‘Sound quality on both end is excellent, I use headset to call my wife and ask my wife to use headset to call me !2.’,
‘1’],
[‘This phone is slim and light and the display is beautiful.’, ‘1’],
[‘its a little geeky but i think thats its sex on toast and it rocks and oozes sex right down to its battery embedded sleek stylish leather case.’,
‘1’],
[‘Great product, fast shipping!.’, ‘1’],
[‘Absolutely great.’, ‘1’],
[‘The keyboard is a nice compromise between a full QWERTY and the basic cell phone number keypad.’,
‘1’],
[“i got this phone around the end of may and i’m completely unhappy with it.”,
‘0’],
[‘It is very comfortable on the ear.’, ‘1’],
[‘It has been a winner for us.’, ‘1’],
[")Setup couldn’t have been simpler.", ‘1’],
[“I’ve tried several different earpieces for my cell phone and this Jabra one is the first one I’ve found that fits my ear comfortably.”,
‘1’],
[‘Could not get strong enough signal.’, ‘0’],
[‘Iam very pleased with my purchase.’, ‘1’],
[‘Bad Quality.’, ‘0’],
[‘Gets the job done.’, ‘1’],
[‘Great audio!.’, ‘1’],
[‘Basically the service was very bad.’, ‘0’],
[‘it did not work in my cell phone plug i am very up set with the charger!.’,
‘0’],
[“I’ve only had my bluetooth for a few weeks, but I really like it.”, ‘1’],
[‘The BT headset was such a disapoinment.’, ‘0’],
[“It is so small and you don’t even realize that it is there after a while of getting used to it.”,
‘1’],
[‘The accompanied software is almost brilliant.’, ‘1’],
[‘Headset works great & was packaged nicely to avoid any damage.’, ‘1’],
[’!I definitly recommend!!’, ‘1’],
[‘Buyer–Be Very Careful!!!.’, ‘0’],
[‘The majority of the Logitech earbud headsets failed.’, ‘0’],
[‘Very good stuff for the price.’, ‘1’],
[‘My headset works just peachy-keen.’, ‘1’],
[‘In my house I was getting dropped coverage upstairs and no coverage in my basement.’,
‘0’],
[‘Voice recognition is tremendous!’, ‘1’],
[‘What a waste.’, ‘0’],
[‘During several different 2 minute calls, I experienced 5 drops and it was in an area that had 5 bars.’,
‘0’],
[‘I was not happy with this item.’, ‘0’],
[‘very disappointed.’, ‘0’],
[‘The phone takes FOREVER to charge like 2 to 5 hours literally.’, ‘0’],
[“I got this phone on reccomendation from a relative and I’m glad I did.”,
‘1’],
[‘What a waste of time!’, ‘0’],
[‘Its reception is very very poor.’, ‘0’],
[‘Items stated as included from the description ARE NOT INCLUDED.’, ‘0’],
[‘After 3 months, screen just went black all of a sudden.’, ‘0’],
[‘I Was Hoping for More.’, ‘0’],
[‘Audio Quality is poor, very poor.’, ‘0’],
[‘I had absolutely no problem with this headset linking to my 8530 Blackberry Curve!’,
‘1’],
[“I know that sounds funny, but to me it seemed like sketchy technology that wouldn’t work well.Well, this one works great.”,
‘1’],
[“I’ve bought $5 wired headphones that sound better than these.”, ‘0’],
[‘This phone is very fast with sending any kind of messages and web browsing is significantly faster than previous phones i have used.’,
‘1’],
[‘Nice quality build, unlike some cheap s*** out there.’, ‘1’],
[‘This item is fantastic and works perfectly!’, ‘1’],
[‘And I just love the colors!’, ‘1’],
[‘W810i is just SUPERB.’, ‘1’],
[‘All I can do is whine on the Internet, so here it goes.The more I use the thing the less I like it.’,
‘0’],
[‘Great charger.’, ‘1’],
[‘This is essentially a communications tool that does not communicate.’, ‘0’],
[‘Works like a charm; it work the same as the one I got with the phone.’,
‘1’],
[“I still maintain that monkeys shouldn’t make headphones, we just obviously don’t share enough DNA to copy the design over to humans.”,
‘0’],
[‘Great Value.’, ‘1’],
[“Doesn’t work at all… I bougth it for my L7c and its not working.”, ‘0’],
[‘The look of it is very sharp and the screen is nice and clear, with great graphics.’,
‘1’],
[“doesn’t last long.”, ‘0’],
[‘One thing I hate is the mode set button at the side.’, ‘0’],
[‘EXCELLENT SERVICE!!!.’, ‘1’],
[‘Thank you for wasting my money.’, ‘0’],
[‘How can that be?The audio quality is poor.’, ‘0’],
[‘The iGo chargers and tips are really great.’, ‘1’],
[‘The file browser offers all the options that one needs.Handsfree is great.’,
‘1’],
[‘Superb Phone on a Great Network.’, ‘1’],
[“I connected my wife’s bluetooth,(Motorola HS850) to my phone and it worked like a charm whether the phone was in my pocket or the case.”,
‘1’],
[‘I put the latest OS on it (v1.15g), and it now likes to slow to a crawl and lock up every once in a while.’,
‘0’],
[‘It only recognizes the Phone as its storage device.’, ‘0’],
[‘If you like a loud buzzing to override all your conversations, then this phone is for you!’,
‘0’],
[“Don’t buy this product.”, ‘0’],
[“I’ve had this bluetoooth headset for some time now and still not comfortable with the way it fits on the ear.”,
‘0’],
[‘The sound quality is good and functionality is awesome.’, ‘1’],
[‘I have this phone and it is a thorn in my side, I really abhor it.’, ‘0’],
[‘I recently had problems where I could not stay connected for more than 10 minutes before being disconnected.’,
‘0’],
[‘Incredible!.’, ‘1’],
[‘Design Flaw?.’, ‘0’],
[‘Great phone!.’, ‘1’],
[‘Waste of 13 bucks.’, ‘0’],
[“But when I check voice mail at night, the keypad backlight turns off a few seconds into the first message, and then I’m lost.”,
‘0’],
[‘The replacement died in a few weeks.’, ‘0’],
[‘Any ring tone…Overall good phone to buy…’, ‘1’],
[‘Lately they have been extremely nice and helpful on the phone.’, ‘1’],
[‘I have had problems wit hit dropping signal and more.’, ‘0’],
[‘Not impressed.’, ‘0’],
[‘Light weight, I hardly notice it is there.’, ‘1’],
[“You’ll love how thin it is.”, ‘1’],
[‘Bad Choice.’, ‘0’],
[“The pleather case doesn’t fit.”, ‘0’],
[‘useless phone, simply deaf.’, ‘0’],
[‘The color is even prettier than I thought it would be, and the graphics are incredibly sharp.’,
‘1’],
[‘All in all I think it was a good investment.’, ‘1’],
[‘It makes very strange ticking noises before it ends the call.’, ‘0’],
[‘The best electronics of the available FM Transmitters.’, ‘1’],
[‘Battery lasts only a few hours.’, ‘0’],
[‘great headset, very impressed - H500.’, ‘1’],
[‘The “1.2” mega pixel camera, being a part of a phone, is reasonably good7.’,
‘1’],
[“I’ve had this for nearly 2 years and it has worked great for me.”, ‘1’],
[‘Good transmit audio.’, ‘1’],
[‘We are sending it back.’, ‘0’],
[‘I did not bother contacting the company for few dollar product but I learned the lesson that I should not have bought this form online anyway.’,
‘0’],
[‘If you hate earbugs, avoid this phone by all means.’, ‘0’],
[‘Great price also!’, ‘1’],
[“The range is very decent, I’ve been able to roam around my house with the phone in the living room with no reception/sound quality issues.”,
‘1’],
[‘fast service.’, ‘1’],
[‘I would highly recommend this.’, ‘1’],
[‘I would recommend this.’, ‘1’],
[‘I also didn’t like the “on” button, it felt like it would crack with use.’,
‘0’],
[‘WORST PHONE EVER.’, ‘0’],
[“I’m still infatuated with this phone.”, ‘1’],
[‘Freezes frequently4.’, ‘0’],
[“It’s kind of embarrassing to use because of how it looks and mostly it’s embarrassing how child-like the company is.”,
‘0’],
[‘Simple, lightweight and great fit.’, ‘1’],
[“All in all, I’d expected a better consumer experience from Motorola.”, ‘0’],
[“There’s a horrible tick sound in the background on all my calls that I have never experienced before.”,
‘0’],
[‘These are certainly very comfortable and functionality is decent.’, ‘1’],
[“I usually don’t like headbands but this one is very lightweight & doesn’t mess up my hair.”,
‘1’],
[“I’m a bit disappointed.”, ‘0’],
[‘I have had this phone for over a year now, and I will tell you, its not that great.’,
‘0’],
[‘I ordered this for sony Ericsson W810i but I think it only worked once (thats when I first used it).’,
‘0’],
[‘The battery is completely useless to me.’, ‘0’],
[‘What a big waste of time.’, ‘0’],
[“Don’t waste your $$$ on this one.”, ‘0’],
[‘Great sound and service.’, ‘1’],
[‘Really pleased with this product so far.’, ‘1’],
[‘One of my favorite purchases ever.’, ‘1’],
[‘best bluetooth on the market.’, ‘1’],
[‘Authentic leather with nice shine and comfort .I recommend you this case !!’,
‘1’],
[‘I was very excited to get this headset because I thought it was really cute.’,
‘1’],
[‘Do not make the same mistake as me.’, ‘0’],
[‘Big Disappointment with calendar sync.’, ‘0’],
[‘the phone was unusable and was not new.’, ‘0’],
[‘Worst Customer Service Ever.’, ‘0’],
[‘No additional ear gels provided, and no instructions whatsoever.’, ‘0’],
[‘It defeats the purpose of a bluetooth headset.’, ‘0’],
[‘Worth every penny.’, ‘1’],
[‘Excellent wallet type phone case.’, ‘1’],
[‘Nice headphones for the price and they work great!’, ‘1’],
[‘Internet is excrutiatingly slow.’, ‘0’],
[‘It is very comfortable to wear as well, which is probably the most important aspect about using a case.’,
‘1’],
[“It’s fits like a glove and is strong, secure, and durable.”, ‘1’],
[‘O my gosh the best phone I have ever had.’, ‘1’],
[“It’s very attractive and appears to be of good quality.”, ‘1’],
[‘I love all the features and form factor.’, ‘1’],
[‘This product had a strong rubber/petroleum smell that was unbearable after a while and caused me to return it’,
‘0’],
[‘poor quality and service.’, ‘0’],
[‘The cable looks so thin and flimsy, it is scary.’, ‘0’],
[‘Great Earpiece.’, ‘1’],
[‘Excellent hands free tool.’, ‘1’],
[‘Great for using with your home stereo.’, ‘1’],
[‘Good product - incredible value.’, ‘1’],
[“Only had this a month but it’s worked flawlessly so far.”, ‘1’],
[‘Works great.’, ‘1’],
[‘Absolutel junk.’, ‘0’],
[“THAT one didn’t work either.”, ‘0’],
[‘Battery life is real good.’, ‘1’],
[‘Returned 8 hours later.’, ‘0’],
[“It’s a great item.”, ‘1’],
[“Don’t waste your money!.”, ‘0’],
[‘Love this headset!’, ‘1’],
[‘Not only will it drain your player, but may also potentially fry it.’, ‘0’],
[‘Worked perfectly!’, ‘1’],
[“Unreliable - I’m giving up.”, ‘0’],
[‘I gave it 5 stars because of the sound quality.’, ‘1’],
[‘Avoid this one if you can.’, ‘0’],
[‘Reversible plug works great.’, ‘1’],
[‘I wasted my little money with this earpiece.’, ‘0’],
[‘Very good phone.’, ‘1’],
[‘Best of all is the rotating feature, very helpful.’, ‘1’],
[‘Comfort for our whole family.’, ‘1’],
[‘Good product, good seller.’, ‘1’],
[‘I love this bluetooth!’, ‘1’],
[“First of all, it doesn’t wear well.”, ‘0’],
[‘I am very impressed with this headset from Plantronics.’, ‘1’],
[‘I got it because it was so small and adorable.’, ‘1’],
[‘Great phone!.’, ‘1’],
[“I wouldn’t recommend buying this product.”, ‘0’],
[‘Piece of Junk.’, ‘0’],
[‘Poorly contstruct hinge.’, ‘0’],
[‘This item is great, installed it, let it charged up overnite and it has been working good every since with no problems’,
‘1’],
[‘Great Phone.’, ‘1’],
[“Don’t buy it.”, ‘0’],
[‘Excellent Phone.’, ‘1’],
[‘DO NOT PURCHASE THIS PHONE.’, ‘0’],
[‘The voice recognition thru the handset is excellent.’, ‘1’],
[“This is hands down the best phone I’ve ever had.”, ‘1’],
[‘Works great, when my cat attacked the phone he scratched the protective strip instead of destroying the screen.’,
‘1’],
[‘This one works and was priced right.’, ‘1’],
[‘Customer service was terrible.’, ‘0’],
[‘Battery life still not long enough in Motorola Razor V3i.’, ‘0’],
[‘Sending it back.’, ‘0’],
[‘Now I know that I made a wise decision.’, ‘1’],
[‘Someone shouldve invented this sooner.’, ‘1’],
[‘Good price.’, ‘1’],
[‘Everything worked on the first try.The device was certainly engineered in a clever way and the construction feels good.’,
‘1’],
[‘I received it quickly and it works great!!’, ‘1’],
[‘Has been working great.’, ‘1’],
[“As many people complained, I found this headset’s microphone was very weak.”,
‘0’],
[‘My 5-year old Nokia 2160 from Tracfone holds the charge a lot better than this.’,
‘0’],
[‘They do not care about the consumer one bit.’, ‘0’],
[‘This is a good battery, and it got here really fast.’, ‘1’],
[‘The instruction manual is lacking.’, ‘0’],
[‘Also its slim enough to fit into my alarm clock docking station without removing the case.’,
‘1’],
[‘Phone now holds charge like it did when it was new.’, ‘1’],
[‘The battery is unreliable as well as the service use antena.’, ‘0’],
[“It’s uncomfortable and the sound quality is quite poor compared with the phone (Razr) or with my previous wired headset (that plugged into an LG).”,
‘0’],
[‘We have gotten a lot of compliments on it.’, ‘1’],
[‘This is definitely a must have if your state does not allow cell phone usage while driving.’,
‘1’],
[‘I want my money back.’, ‘0’],
[‘I love this device.’, ‘1’],
[‘I am also very happy with the price.’, ‘1’],
[‘I ordered this product first and was unhappy with it immediately.’, ‘0’],
[‘The Ngage is still lacking in earbuds.’, ‘0’],
[‘I was able to do voice dialing in the car with no problem.’, ‘1’],
[‘I have 2-3 bars on my cell phone when I am home, but you cant not hear anything.’,
‘0’],
[‘good item, low price.’, ‘1’],
[‘However-the riingtones are not the best, and neither are the games.’, ‘0’],
[‘The plug did not work very well.’, ‘0’],
[‘AMAZON SUCKS.’, ‘0’],
[‘Rip off---- Over charge shipping.’, ‘0’],
[‘VERY comfortable.’, ‘1’],
[‘The battery is working well as a replacement for the original that came with the phone over 2 years ago.’,
‘1’],
[‘The reception is excellent!’, ‘1’],
[‘It fits comfortably in either ear, the sound is clear and loud, and the charge lasts a couple of days.’,
‘1’],
[“very clear, quality sound and you don’t have to mess with the sound on your iPod since you have the sound buttons on the headset.”,
‘1’],
[“1. long lasting battery (you don’t have to recharge it as frequentyly as some of the flip phones)2.”,
‘0’],
[‘Obviously there is a problem with the adhesive.’, ‘0’],
[‘Very disappointing.’, ‘0’],
[‘It was an inexpensive piece, but I would still have expected better quality.’,
‘0’],
[‘It is practically useless and did not add any kind of boost to my reception after I bought it.’,
‘0’],
[‘Excellent sound quality.’, ‘1’],
[‘Was not happy.’, ‘0’],
[‘A PIECE OF JUNK THAT BROKE AFTER BEING ON MY PHONE FOR 2 DAYS!!!’, ‘0’],
[‘New Battery works great in phone.’, ‘1’],
[‘Worst customer service.’, ‘0’],
[“I’ve dropped my phone more times than I can say, even on concrete and my phone is still great (knock on wood!).”,
‘1’],
[‘Reception is terrible and full of static.’, ‘0’],
[‘Good audio quality.’, ‘1’],
[‘This little device has transformed my organizational capability and made my life a whole lot easier.’,
‘1’],
[‘I was sitting in my vehicle, with the cradle on my belt, and the headset lost signal.’,
‘0’],
[‘Were JERKS on the phone.’, ‘0’],
[‘Works like a charm… Works as advertised.’, ‘1’],
[‘Comfortable, Nice Range, Good Battery Life.’, ‘1’],
[‘Their network coverage in Los Angeles is horrible.’, ‘0’],
[‘Excellent starter wireless headset.’, ‘0’],
[‘The loudspeaker option is great, the bumpers with the lights is very … appealing.’,
‘0’],
[‘The only thing that I think could improve is the sound leaks out from the headset.’,
‘0’],
[‘First off the reception sucks, I have never had more than 2 bars, ever.’,
‘0’],
[‘The phone gets EXTREMELY HOT!’, ‘0’],
[‘The microphone also works well, but (according to people I have called) it applifies everything.’,
‘1’],
[‘Nice design and quality.’, ‘1’],
[‘Also, if your phone is dropped, this case is not going to save it, specially when dropped face down.’,
‘0’],
[‘It is light, easy to use, and has very clear reception and transmission.’,
‘1’],
[‘bad fit, way too big.’, ‘0’],
[‘It definitely was not as good as my S11.’, ‘1’],
[‘awesome device.’, ‘1’],
[‘Waste of money.’, ‘0’],
[‘I had ordered a motorola data cable, got a very well finished and working product.’,
‘1’],
[‘Love This Phone.’, ‘1’],
[“I was looking for this headset for a long time and now that I’ve got it I couldn’t be happier.”,
‘1’],
[“I’ll be drivng along, and my headset starts ringing for no reason.”, ‘0’],
[‘Display is excellent and camera is as good as any from that year.’, ‘1’],
[‘Battery life is also great!’, ‘1’],
[“The worst phone I’ve ever had… Only had it for a few months.”, ‘0’],
[‘Not a good item… It worked for a while then started having problems in my auto reverse tape player.’,
‘0’],
[‘This is so embarassing and also my ears hurt if I try to push the ear plug into my ear.’,
‘0’],
[‘Protects the phone on all sides.’, ‘1’],
[‘This is a VERY average phone with bad battery life that operates on a weak network.’,
‘0’],
[‘Clear Skype Calls, Long Battery Life, Long Range.’, ‘1’],
[‘Soyo technology sucks.’, ‘0’],
[‘Great Hands Free Device.’, ‘1’],
[‘you can even take self portraits with the outside (exterior) display, very cool.’,
‘1’],
[‘Same problem as others have mentioned.’, ‘0’],
[‘After trying many many handsfree gadgets this is the one that finally works well.’,
‘1’],
[‘Magical Help.’, ‘1’],
[‘The worst piece of crap ever along with the Verizon customer service.’,
‘0’],
[‘Poor sound quality.’, ‘0’],
[‘The best phone in market :).’, ‘1’],
[‘It worked very well.’, ‘1’],
[‘The company shipped my product very promptly and it works well.’, ‘1’],
[‘Exactly what I wanted.’, ‘1’],
[‘The picture resolution is far below what other comparably-priced phones are offering today.’,
‘0’],
[‘This is a great deal.’, ‘1’],
[‘Excellent product, I am very satisfied with the purchase.’, ‘1’],
[‘I highly recommend these and encourage people to give them a try.’, ‘1’],
[“Better than you’d expect.”, ‘1’],
[‘Using all earpieces, left or right, this thing will not stay on my ear.’,
‘0’],
[‘Great product and price.’, ‘1’],
[‘Sounds good reasonably priced and effective, Its that simple !’, ‘1’],
[“Still Waiting… I’m sure this item would work well… if I ever recieve it!”,
‘0’],
[‘what a disappointment’, ‘0’],
[‘Very prompt service.’, ‘1’],
[‘Excellent product for the price.’, ‘1’],
[‘Very pleased with this headset.’, ‘1’],
[“don’t waste your money and time.”, ‘0’],
[‘I especially love the long battery life.’, ‘1’],
[“It’s so stupid to have to keep buying new chargers, car chargers, cradles, headphones and car kits every time a new phone comes out.”,
‘0’],
[‘Works great.’, ‘1’],
[‘Plantronics Bluetooth Excelent Buy.’, ‘1’],
[‘I came over from Verizon because cingulair has nicer cell phones… the first thing I noticed was the really bad service.’,
‘0’],
[“I’ll be looking for a new earpiece.”, ‘0’],
[‘I highly recommend this device to everyone!’, ‘1’],
[‘Jawbone Era is awesome too!’, ‘1’],
[‘We received a WHITE colored battery that goes DEAD after a couple hoursTHe original used to last a week - but still lasts longer than thereplacement’,
‘0’],
[‘After a year the battery went completely dead on my headset.’, ‘0’],
[‘I have used several phone in two years, but this one is the best.’, ‘1’],
[‘An Awesome New Look For Fall 2000!.’, ‘1’],
[“This is the first phone I’ve had that has been so cheaply made.”, ‘0’],
[‘Att is not clear, sound is very distorted and you have to yell when you talk.’,
‘0’],
[‘The plastic breaks really easy on this clip.’, ‘0’],
[‘Price is good too.’, ‘1’],
[“Don’t make the same mistake I did.”, ‘0’],
[‘Oh and I forgot to also mention the weird color effect it has on your phone.’,
‘0’],
[“I’m using it with an iriver SPINN (with case) and it fits fine.”, ‘1’],
[“Also the area where my unit broke).- I’m not too fond of the magnetic strap.”,
‘0’],
[‘Overall, I am psyched to have a phone which has all my appointments and contacts in and gets great reception.’,
‘1’],
[‘every thing on phone work perfectly, she like it.’, ‘1’],
[“Another note about this phone’s appearance is that it really looks rather bland, especially in the all black model.”,
‘0’],
[“IT’S REALLY EASY.”, ‘1’],
[‘My Sanyo has survived dozens of drops on blacktop without ill effect.’,
‘1’],
[‘Fantastic earphones.’, ‘1’],
[‘It finds my cell phone right away when I enter the car.’, ‘1’],
[‘Low Quality.’, ‘0’],
[‘I highly recommend this modest priced cellular phone.’, ‘1’],
[“But it does get better reception and clarity than any phone I’ve had before.”,
‘1’],
[‘Warning - Stay away.’, ‘0’],
[‘I wish I could return the unit and get back my money.’, ‘0’],
[‘Awsome Device Works Great!!.’, ‘1’],
[‘I used to talk on it for 1 - 1 1/2 hours and the battery would be literally drained and dying.’,
‘0’],
[“If you don’t find it, too bad, as again the unit comes with one earpad only.I would not recommend this to anyone.”,
‘0’],
[‘Very Displeased.’, ‘0’],
[‘I might have gotten a defect, but I would not risk buying it again because of the built quality alone.’,
‘0’],
[‘They made this case too small and is very difficult to install.’, ‘0’],
[‘Restored my phone to like new performance.’, ‘1’],
[‘I would recommend purchasing the Jabra JX-10 series 2 which works flawlessly with my Moto Q, go figure.’,
‘1’],
[‘I searched the Internet, and found this one to be the best value.’, ‘1’],
[‘Does not fit.’, ‘0’],
[‘Very happy with this product.’, ‘1’],
[‘The screen size is big, key pad lit well enough, and the camera quality is excellent for a camera phone.’,
‘1’],
[“There’s really nothing bad I can say about this headset.”, ‘0’],
[“i’m glad i found this product on amazon it is hard to find, it wasn’t high priced.”,
‘1’],
[‘Portable and it works.’, ‘1’],
[‘My colleague & I now get great reception.A little expensive, but performance is great.’,
‘1’],
[‘I even fully charged it before I went to bed and turned off blue tooth and wi-fi and noticed that it only had 20 % left in the morning.’,
‘0’],
[“I’ve also had problems with the phone reading the memory card in which I always turn it on and then off again.”,
‘0’],
[‘Not good when wearing a hat or sunglasses.’, ‘0’],
[‘Timely shipment and quality product.’, ‘1’],
[‘Nice solid keyboard.’, ‘1’],
[‘Very well made and fits my Surefire GX2 perfectly.’, ‘1’],
[‘Horrible phone.’, ‘0’],
[‘BT50 battery junk!.’, ‘0’],
[‘We would recommend these to others.’, ‘1’],
[‘Cant get the software to work with my computer.’, ‘0’],
[‘Disappointed!.’, ‘0’],
[‘poor voice clarity.’, ‘0’],
[‘The battery works great!’, ‘1’],
[‘No buyers remorse on this one!.’, ‘0’],
[‘Very disappointed in AccessoryOne.’, ‘0’],
[‘I find this inexcusable and so will probably be returning this phone and perhaps changing carriers.’,
‘0’],
[‘Looks great and is strong."’, ‘1’],
[‘I have had TMobile service for 2 or 3 years now, and I am pretty happy with it.’,
‘1’],
[‘The update procedure is difficult and cumbersome.’, ‘0’],
[‘Disappointment… I hate anything that goes in my ear.’, ‘0’],
[‘Great software for Motorolas.’, ‘1’],
[‘The delivery was on time.’, ‘1’],
[‘Very easy to use.’, ‘1’],
[“Uncomfortable In the Ear, Don’t use with LG VX9900 (EnV).”, ‘0’],
[‘The volume switch rocketed out of the unit to a destination unknown.’, ‘0’],
[‘It holds a charge for a long time, is reasonably comfortable under long-wearing conditions and the quality of sound is tremendous.’,
‘1’],
[“I’d like to return it.”, ‘0’],
[“The keyboard is really worthwhile in usefulness and is sturdy enough I don’t expect any problems.”,
‘1’],
[“Verizon’s bills, however, are difficult to understand even though their pricing plans are simple.”,
‘0’],
[‘After charging overnight, these batteries work great.’, ‘1’],
[“You won’t regret it!”, ‘1’],
[‘I love this phone!.’, ‘1’],
[‘A Disappointment.’, ‘0’],
[‘Its not user friendly.’, ‘0’],
[‘Unfortunately the ability to actually know you are receiving a call is a rather important feature and this phone is pitiful in that respect.’,
‘0’],
[‘Then I exchanged for the same phone, even that had the same problem.’, ‘0’],
[‘This results in the phone being either stuck at max volume or mute.’, ‘0’],
[‘This PDA rocks.’, ‘1’],
[‘It is super charged up for use as a small hybrid palmtop/camera/cellphone, and excels in those roles.’,
‘1’],
[‘I would definitely recommend the Jabra BT250v for those who are looking for comfort, clarity and a great price!’,
‘1’],
[‘I had Verizon 2 years ago and really liked their service.’, ‘1’],
[‘Pretty piece of junk.’, ‘0’],
[‘Plug was the wrong size.’, ‘0’],
[‘Works as described.’, ‘1’],
[“Save your money… I’ve had this item for 11 months now.”, ‘0’],
[‘Bad Purchase.’, ‘0’],
[‘WELL IM SATISFIED.’, ‘1’],
[‘The bose noise cancelling is amazing, which is very important for a NYC commuter.’,
‘1’],
[‘This battery is an excellent bargain!’, ‘1’],
[‘Defective crap.’, ‘0’],
[‘I would have given no star if I was able.’, ‘0’],
[‘I wear glasses and it fits fine with them.’, ‘1’],
[‘The sound quality for the device is unacceptable.Unless you are in a really quiet area, you almost hear nothing.’,
‘0’],
[‘I would not recommend this item to anyone.’, ‘0’],
[‘The holster that arrived did not match the photo in the ad.’, ‘0’],
[‘great…no problems at all!.’, ‘1’],
[‘As an earlier review noted, plug in this charger and nothing happens.’,
‘0’],
[‘This frog phone charm is adorable and very eye catching.’, ‘1’],
[‘You never know if you pushed it hard enough or the right number of times for the function you want or not.’,
‘0’],
[‘The sound is clear and the people I talk to on it are amazed at the quality too.’,
‘1’],
[‘I got the aluminum case for my new Palm VX and it worked really well–it has protected my handheld perfectly so far.’,
‘1’],
[‘very good product, well made.’, ‘1’],
[‘Mobile Phone Tools are a must have.’, ‘1’],
[‘I am very impressed with the job that Motorola did on the sturdiness of this phone.’,
‘1’],
[‘I received my orders well within the shipping timeframe, everything was in good working order and overall, I am very excited to have this source.’,
‘1’],
[‘The phone is sturdy and waterproof.’, ‘1’],
[‘I am not impressed with this and i would not recommend this item to anyone.’,
‘0’],
[‘My only complaint is the standard sound volume is a little low even when turned up to 5(of 5)’,
‘0’],
[‘Thanks again to Amazon for having the things I need for a good price!’,
‘1’],
[‘I ended up sliding it on the edge of my pants or back pockets instead.’,
‘1’],
[‘I had to go to a store and bought a new NOKIA phone which is working great.’,
‘1’],
[‘Works great!.’, ‘1’],
[‘REALLY UGLY.’, ‘0’],
[‘horrible, had to switch 3 times.’, ‘0’],
[‘The noise shield is incrediable.’, ‘1’],
[‘No real improvement.’, ‘0’],
[‘Razr Battery - Good buy.’, ‘1’],
[‘Keep up the good work Amazon!!’, ‘1’],
[‘They refuse to refund or replace.’, ‘0’],
[“Unfortunately it’s easy to accidentally activate them with the gentle-touch buttons if you accidentally touch the phone to your face while listening.”,
‘0’],
[‘So I basically threw my money out the window for nothing.’, ‘0’],
[‘Great case and price!’, ‘1’],
[‘All it took was one drop from about 6 inches above the kitchen counter and it was cracked.I am not impressed and I am not laughing.’,
‘0’],
[‘Bluetooth range is good - a few days ago I left my phone in the trunk, got a call, and carried the conversation without a hitch.’,
‘1’],
[‘Small, sleek, impressive looking, practical setup with ample storage in place.’,
‘1’],
[‘The eargels channel the sound directly into your ear and seem to increase the sound volume and clarity.’,
‘1’],
[‘none of the new ones have ever quite worked properly.’, ‘0’],
[‘I am glad I purchased it.’, ‘1’],
[“I’ve missed numerous calls because of this reason.”, ‘0’],
[‘Perhaps my phone is defective, but people cannot hear me when I use this.’,
‘0’],
[“Don’t buy this product.”, ‘0’],
[‘sucked, most of the stuff does not work with my phone.’, ‘0’],
[“No shifting, no bubbling, no peeling, not even a scratch, NOTHING!I couldn’t be more happier with my new one for the Droid.”,
‘1’],
[‘Worst software ever used… If I could give this zero stars I would.’,
‘0’],
[‘Trying to make a call on these is an exercise in frustration.’, ‘0’],
[‘The case is a flimsy piece of plastic and has no front or side protection whatsoever.’,
‘0’],
[‘I own a Jabra Earset and was very happy with it, but the sound quality, especially outgoing, on this is better.’,
‘1’],
[“I love the camera, it’s really pretty good quality.”, ‘1’],
[‘Thank you for such great service.’, ‘1’],
[‘Its a total package.’, ‘1’],
[‘The seller is very understanding and patient, I would definitely buy from them again.’,
‘1’],
[‘I give Wirefly 1 star.I will contact Cingular/AT&T; and inform them of this practice.’,
‘0’],
[“It’s AGGRAVATING!”, ‘0’],
[‘Great product for the price!.’, ‘1’],
[‘I have purchased these for both family and friends, and all enjoy their clarity and ease of use’,
‘1’],
[‘Virgin Wireless rocks and so does this cheap little phone!’, ‘1’],
[“None of it works, just don’t buy it.”, ‘0’],
[“Muddy, low quality sound, and the casing around the wire’s insert was poorly super glued and slid off.”,
‘0’],
[‘Please dont waste your money.’, ‘0’],
[“All in all, I’m quite satisfied with this purchase.”, ‘1’],
[“If you are looking for a good quality Motorola Headset keep looking, this isn’t it.”,
‘0’],
[‘Yet Plantronincs continues to use the same flawed charger design.’, ‘0’],
[‘Disapointing Results.’, ‘0’],
[‘Cumbersome design.’, ‘0’],
[‘Great it was new packaged nice works good, no problems and it came in less time then I expected!!!’,
‘1’],
[‘Great Product.’, ‘1’],
[“It’s A PIECE OF CRAP!”, ‘0’],
[‘My experience was terrible… This was my fourth bluetooth headset, and while it was much more comfortable than my last Jabra (which I HATED!!!’,
‘0’],
[‘This fixes all the problems.’, ‘1’],
[‘Worst ever.’, ‘0’],
[‘I am very happy’, ‘1’],
[“I’ve had no trouble accessing the Internet, downloading ringtones or performing any of the functions.”,
‘1’],
[‘I can barely ever hear on it and am constantly saying “what?”’, ‘0’],
[‘The battery life is highly unacceptable.’, ‘0’],
[‘That company is a joke.’, ‘0’],
[‘It does everything the description said it would.’, ‘1’],
[‘Due to this happening on every call I was forced to stop using this headset.’,
‘0’],
[‘It works great with a car charger, especially if you cannot plug in two adapters at the same time.’,
‘1’],
[‘Verizon tech support walked my through a few procedures, none of which worked and I ended up having to do a hard re-set, wiping out all my data.’,
‘0’],
[‘Voice Quality, Signal Strength, Dropped Calls.’, ‘0’],
[“It plays louder than any other speaker of this size; the price is so low that most would think the quality is lacking, however, it’s not.”,
‘1’],
[‘Better than expected.’, ‘1’],
[‘It feels poorly constructed, the menus are difficult to navigate, and the buttons are so recessed that it is difficult to push them.’,
‘0’],
[‘Battery is holding up well.’, ‘1’],
[“Also difficult to put on.I’d recommend avoiding this product.”, ‘0’],
[“I only used it two days, and it wasn’t always easy to hear with.”, ‘0’],
[‘I got the car charger and not even after a week the charger was broken…I went to plug it in and it started smoking.’,
‘0’],
[‘Sprint - terrible customer service.’, ‘0’],
[‘Linked to my phone without effort.’, ‘1’],
[‘THey are so cool!’, ‘1’],
[‘Easy to use.’, ‘1’],
[‘Better Than New.’, ‘1’],
[‘What possesed me to get this junk, I have no idea…’, ‘0’],
[‘Piece of trash.’, ‘0’],
[‘A pretty good product.’, ‘1’],
[‘This is a great phone!.’, ‘1’],
[‘For the price on Amazon, it is an excellent product, which I would highly recommend.’,
‘1’],
[“Their Research and Development division obviously knows what they’re doing.”,
‘1’]]

train_documents = [line[0] for line in lines]
train_documents

Out

[‘So there is no way for me to plug it in here in the US unless I go by a converter.’,
‘Good case, Excellent value.’,
‘Great for the jawbone.’,
‘Tied to charger for conversations lasting more than 45 minutes.MAJOR PROBLEMS!!’,
‘The mic is great.’,
‘I have to jiggle the plug to get it to line up right to get decent volume.’,
‘If you have several dozen or several hundred contacts, then imagine the fun of sending each of them one by one.’,
‘If you are Razr owner…you must have this!’,
‘Needless to say, I wasted my money.’,
‘What a waste of money and time!.’,
‘And the sound quality is great.’,
‘He was very impressed when going from the original battery to the extended battery.’,
‘If the two were seperated by a mere 5+ ft I started to notice excessive static and garbled sound from the headset.’,
‘Very good quality though’,
‘The design is very odd, as the ear “clip” is not very comfortable at all.’,
‘Highly recommend for any one who has a blue tooth phone.’,
‘I advise EVERYONE DO NOT BE FOOLED!’,
‘So Far So Good!.’,
‘Works great!.’,
‘It clicks into place in a way that makes you wonder how long that mechanism would last.’,
“I went on Motorola’s website and followed all directions, but could not get it to pair again.”,
‘I bought this to use with my Kindle Fire and absolutely loved it!’,
‘The commercials are the most misleading.’,
“I have yet to run this new battery below two bars and that’s three days without charging.”,
‘I bought it for my mother and she had a problem with the battery.’,
‘Great Pocket PC / phone combination.’,
“I’ve owned this phone for 7 months now and can say that it’s the best mobile phone I’ve had.”,
“I didn’t think that the instructions provided were helpful to me.”,
‘People couldnt hear me talk and I had to pull out the earphone and talk on the phone.’,
“Doesn’t hold charge.”,
‘This is a simple little phone to use, but the breakage is unacceptible.’,
‘This product is ideal for people like me whose ears are very sensitive.’,
‘It is unusable in a moving car at freeway speed.’,
‘I have two more years left in this contract and I hate this phone.’,
‘Car charger as well as AC charger are included to make sure you never run out of juice.Highy recommended’,
‘You need at least 3 mins to get to your phone book from the time you first turn on the phone.Battery life is short.’,
‘It has kept up very well.’,
‘Poor Talk Time Performance.’,
‘The case is great and works fine with the 680.’,
‘worthless product.’,
‘It has a great camera thats 2MP, and the pics are nice and clear with great picture quality.’,
‘I was not impressed by this product.’,
‘Nice headset priced right.’,
‘I only hear garbage for audio.’,
‘Excellent bluetooth headset.’,
‘It has all the features I want’,
‘Who in their right mind is gonna buy this battery?.’,
‘AFTER ARGUING WITH VERIZON REGARDING THE DROPPED CALLS WE RETURNED THE PHONES AFTER TWO DAYS.’,
‘This case seems well made.’,
‘Disappointed with battery.’,
“Not loud enough and doesn’t turn on like it should.”,
‘good protection and does not make phone too bulky.’,
‘A usable keyboard actually turns a PDA into a real-world useful machine instead of just a neat gadget.’,
“This phone is pretty sturdy and I’ve never had any large problems with it.”,
‘I love this thing!’,
‘Everything about it is fine and reasonable for the price i.e.’,
‘VERY DISAPPOINTED.’,
‘I even dropped this phone into a stream and it was submerged for 15 seconds and it still works great!’,
‘I have been very happy with the 510 and have had NO complaints from any one regarding my sound quality on their end.’,
‘The buttons for on and off are bad.’,
“Essentially you can forget Microsoft’s tech support.”,
‘I really recommend this faceplates since it looks very nice, elegant and cool.’,
“These headphones were a great find - and I think they are perhaps the best purchase I’ve made in the last several years - seriously.”,
‘Buy a different phone - but not this.’,
‘You have to hold the phone at a particular angle for the other party to hear you clearly.’,
“The one big drawback of the MP3 player is that the buttons on the phone’s front cover that let you pause and skip songs lock out after a few seconds.”,
‘A week later after I activated it, it suddenly died.’,
‘It feels more comfortable than most headsets because I wear glasses and that gets in the way sometimes.’,
‘Great for iPODs too.’,
‘This device is great in several situations:1.)’,
“Mic Doesn’t work.”,
‘Even in my BMW 3 series which is fairly quiet, I have trouble hearing what the other person is saying.’,
‘Great choice!’,
‘Nice docking station for home or work.’,
‘This is a beautiful phone.’,
‘Love this product.’,
‘Do Not Buy for D807…wrongly advertised for D807.’,
‘This is a great little item.’,
‘I love this phone , It is very handy and has a lot of features .’,
‘I purchased this and within 2 days it was no longer working!!!’,
‘I wear it everyday and it holds up very well.’,
‘Not a good bargain.’,
‘Well packaged, arrived on time, and works as intended.’,
‘The battery runs down quickly.’,
‘This item worked great, but it broke after 6 months of use.’,
‘The headsets are easy to use and everyone loves them.’,
‘This phone works great.’,
‘The construction of the headsets is poor.’,
‘Product was excellent and works better than the verizon one and Boy was it cheaper!’,
‘The phone loads super!’,
‘For a product that costs as much as this one does, I expect it to work far better and with greater ease than this thing does.’,
‘Made very sturdy.’,
‘Worked great!.’,
‘The ear buds only play music in one ear.’,
‘Dont waste your money…’,
‘Will order from them again!’,
‘If you plan to use this in a car forget about it.’,
‘I found this product to be waaay too big.’,
“Best I’ve found so far … I’ve tried 2 other bluetooths and this one has the best quality (for both me and the listener) as well as ease of using.”,
“I’m very disappointed with my decision.”,
‘Integrated seamlessly with the Motorola RAZR phone.’,
‘Buyer Beware, you could flush money right down the toilet.’,
‘Definitely a bargain.’,
‘The price was very good and with the free shipping and all it was a good purchase.’,
‘I received my supposedly new motorola 375 and apparently there was not a match between the phone and the charger.’,
‘Pros:-Good camera - very nice pictures , also has cool styles like black and white, and more.’,
“That’s a huge design flaw (unless I’m not using it correctly, which I don’t think is the case).”,
‘I love my 350 headset… My Jabra350 bluetooth headset is great, the reception is very good and the ear piece is a comfortable fit.’,
‘The camera, although rated at an impressive 1.3 megapixels, renders images that fall well below expectations of such a relatively high resolution.’,
‘I purcashed this for the car charger and it does not work.’,
‘Sound quality on both end is excellent, I use headset to call my wife and ask my wife to use headset to call me !2.’,
‘This phone is slim and light and the display is beautiful.’,
‘its a little geeky but i think thats its sex on toast and it rocks and oozes sex right down to its battery embedded sleek stylish leather case.’]

train_documents = [line[1] for line in lines]
train_documents

Out

[‘0’,
‘1’,
‘1’,
‘0’,
‘1’,
‘0’,
‘0’,
‘1’,
‘0’,
‘0’,
‘1’,
‘1’,
‘0’,
‘1’,
‘0’,
‘1’,
‘0’,
‘1’,
‘1’,
‘0’,
‘0’,
‘1’]

from sklearn.feature_extraction.text import CountVectorizer

count_vectorizer = CountVectorizer(binary=‘true’)
train_documents = count_vectorizer.fit_transform(train_documents)

Out

NameError Traceback (most recent call last)
in
1 count_vectorizer = CountVectorizer(binary=‘true’)
----> 2 train_documents = count_vectorizer.fit_transform(train_documents)

NameError: name ‘train_documents’ is not defined

So this is a different error to the one you posted previously. In this case it is just that train_documents has not been defined yet, but you have referenced in the the line count_vectorizer.fit_transform(train_documents). Although, it does seem like you have assigned it in the earlier section.

Make sure you are running the code in order - I assume you are using a Jupyter notebook here or similar, in which case be aware that the order that you run the cells in matters (rather than just the order they appear on the screen). If you were to try putting all of this code into one cell and running it all at once I believe it would work.

Hi Irjball

Here is what I have by combining all into one cell. This might make it easier to read :smiley:

with open(“C:/Users/user/Documents/Python/Data/sentiment labelled sentences/imdb_labelled.txt”, “r”) as text_file:
lines = text_file.read().split(’\n’)
with open(“C:/Users/user/Documents/Python/Data/sentiment labelled sentences/yelp_labelled.txt”, “r”) as text_file:
lines = text_file.read().split(’\n’)
with open(“C:/Users/user/Documents/Python/Data/sentiment labelled sentences/amazon_cells_labelled.txt”, “r”) as text_file:
lines = text_file.read().split(’\n’)

lines = [line.split("\t") for line in lines if len(line.split("\t"))==2 and line.split("\t")[1]!=’’]

train_documents = [line[0] for line in lines]
train_documents = [line[1] for line in lines]

from sklearn.feature_extraction.text import CountVectorizer

count_vectorizer = CountVectorizer(binary=‘true’)
train_documents = count_vectorizer.fit_transform(train_documents)

Output:


ValueError Traceback (most recent call last)
in
14
15 count_vectorizer = CountVectorizer(binary=‘true’)
—> 16 train_documents = count_vectorizer.fit_transform(train_documents)

~\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py in fit_transform(self, raw_documents, y)
1218
1219 vocabulary, X = self.count_vocab(raw_documents,
-> 1220 self.fixed_vocabulary
)
1221
1222 if self.binary:

~\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py in _count_vocab(self, raw_documents, fixed_vocab)
1148 vocabulary = dict(vocabulary)
1149 if not vocabulary:
-> 1150 raise ValueError(“empty vocabulary; perhaps the documents only”
1151 " contain stop words")
1152

ValueError: empty vocabulary; perhaps the documents only contain stop words

See, now you are getting the original error again which is due to the text containing only '0' and '1', which are both too short. The reason for this issue is you have accidentally reassigned to the variable train_documents. Try it again, but instead change the final few lines to:

train_documents = [line[0] for line in lines]
train_labels = [line[1] for line in lines]

from sklearn.feature_extraction.text import CountVectorizer

count_vectorizer = CountVectorizer(binary=True)
train_documents = count_vectorizer.fit_transform(train_documents)

Now, train_documents contains all of the sentences, which can be passed to the count_vectorizer, and train_labels contains strings of either '0' or '1'.

Thanks @lrjball,

That worked.

No problem :slight_smile: