from textblob import TextBlob
import pandas as pd

testwords = ['good is bad, bad is good good', 'hello', 'fucking', 'best', 'beautiful', 'bad', 'wonderful', 'horrible',
             'haha', 'ok', 'accaptable', 'jnfjanfjanfja']
testparagraph = """
Google was bound to make it in here somehow. Here are some intern perks at Google:
1. Google pays for flights from anywhere in the world to your office and from your office to anywhere in the world,
before and after your internship. (This is standard for most companies)

2. Google gives us free, and in my opinion, luxury housing. Although we share an apartment we three others, it's
equipped with a nice TV, a patio, a kitchen with a dishwasher, 2 baths, a washer and dryer, and biweekly cleaning. We
also have access to a 24-hour gym, a hot tub, a swimming pool, a games room, and a park.

3. Google buses pick us from corp housing and drop us back to corp housing many times during the day.

4. Google bikes are temporary bikes available in and around Google to use to cycle around campus. You can rent a bike
for free.

5. Google has over 20 gourmet cafeterias all over campus with almost all types of cuisine almost everyday. They serve 3
meals on all weekdays, with few exceptions.

6. Everyone is less than 100 feet away from a microkitchen, stuffed with all sorts of snacks, fruits and drinks. They
also come with a automatic coffee machine and an espresso machine. If there's something you want in your microkitchen,
 it can be asked for.

7. Chess tables, board games, pool tables, table tennis tables and swimming pools can be found frequently around campus.
You're encouraged to use them, during work.

8. Interns get an hours worth of massage credits and get a professional massage. Massage chairs are scattered around
campus in case you want something automatic.

9. Weekly TGIF involves wine, beer, watching Larry and Sergey address the company, possibly asking them questions and
more. During work.

10. No work hours. Come and go when you want - just get work done and be present virtually at your meetings.

11. Request any electronic item you might need for use for your entire internship. Usually work related, but includes
laptops of choice, headphones, etc. You get to keep some of them. Interns can work on a chromebook, a chrome book pixel
or a 15" inch retina MacBook Pro, as of 2013.

12. Dogfood the newest stuff google makes.

13. Attend special internal hackathons to be the first to work on Google's coolest products.

14. Watch the first Loon launch.

15. Need to run errands at work? Borrow a google car and go anywhere you want for any amount of time.

16. The office never closes. Stay all night!

17. Nap pods. Sleep at work, in style.

18. Intern Boat Cruise in the bay. As crazy as they get.

19. Great pay on top of all the free stuff.

20. Heated toilet seats at work.

21. No clothing guidelines (this is the norm at most tech companies). Hair color, tattoos, piercings - it all runs as
long as you code.

22. The best internal tools. Can't say much more.

23. Volleyball courts, Soccer fields, and intra company sporting competitions. I'm sure they have more facilities I'm
not even aware of.

24. There are 5 or more full fledged high tech gyms at google including outdoor pull up bars and what not. When I say
high tech, I mean they count your reps for you. Free gym classes for everything you can imagine.

25. Free classes for random things - from python and C++ to salsa and more. You can take breaks from work to learn
something cool.

26. Free Google swag. Interns get a T shirt and a Patagonia backpack and a hoodie. Plus, you get to keep headphones and
if you're lucky, more valuable freebies.

27. You get to have a full fledge Hollywood movie featuring Owen Wilson and Vince Vaughn based on how cool your job is,
albeit more than slightly exaggerated. You also get free tickets to the red carpet premier a week before release. So
what if it's a crappy movie? Unlike Jobs or The Social Network, this is about the interns! It's about you.

28. Getting a full time job at google is very in demand and as a result, very hard. I won't reveal numbers but it is
orders if magnitude harder than the most selective college in America. Converting from an internship is much easier,
and that extra boost is great to have especially in a market where "Ex-Googler" is a status symbol.

29. Get to meet some legends. Just by being a little pushy and very lucky, you can easily set up meetings with Ken
Thompson and Jeff Dean. It's much easier to set up people with lesser known people all around google and just talk about
their projects and technology.

30. Last, but not least. The biggest perk of being at google are the people. The interns are extremely smart and
passionate but sociable and nice as well. The full timers are amazing too. All companies have great engineers,
but at Google you're surrounded by a city of so many of the smartest software engineers shaping the forefront of
technology today. The sheer quantity is mesmerizing. They are so well read (in code) and knowledgeable and very helpful.
If you make use of it, it's like infinite office hours with a professor who's always at your service!

Edit:
31. On-site haircuts two days a week, with professional stylists.

32. On-site laundry if you so please.

33. "Park at Google when you go to concerts at Shoreline.  Also, pick up free drinks and snacks at Google at the same
time.  Sometimes it's nice, after the concert, to play a game of pool or something with your friends while the
concertgoers are stuck in traffic." - Iain McClatchie
This summer they had artists ranging from John Mayer to Brad Paisley to Wiz Khalifa.

34. If you're lost or need any transport, you can call the GCar or the GShuttle to pick you up if you're anywhere around
campus.
187.9k Views · View Upvotes
Upvote2.7kDownvoteComments27+
Share
Bogdan Cristian Tătăroiu
Bogdan Cristian Tătăroiu, Intern at Dropbox, formerly at Twitter and Facebook
Updated Aug 15, 2013 · Featured in Forbes · Upvoted by Oliver Emberton, Founder of Silktide and Ryhan Hassan, Interned
at Apple, Google. Joining Dropbox.
Dropbox has by far the most perks I've seen in any Silicon Valley company.

The major event that stood out to me this summer was Parent's Weekend, where they flew out all intern parents down to
their San Francisco office, housed them for 2 nights, organised a bunch of talks explaining Dropbox to them, where we
stand now, our future products, our vision etc. and basically helped them understand why all of us working here are so
excited about what we're doing.

It was an awesome family-like experience all round and for me personally it was made even better by the fact that it was
my father's first trip to the United States and my mother's second and they finally got to understand why I chose to do
what I do and be where I am right now.

Other than that:
They completely cover your housing - either 2 people in a 2 bedroom apartment or, if you're lucky, 1 person in a 1
bedroom apartment.
They have shuttles which pick you up from corporate housing locations and take you back from the office to _anywhere_
in SF.
The Tuckshop (our in-house restaurant) literally makes better food than I find in most restaurants I eat in over the
weekend in SF.
They cover expenses: phone plan, caltrain gopass, muni & bart pass, flights.
Giant music room with everything from grand piano to electric guitars and drumset
Massages, haircuts, professional ping pong training, on-site gym.
No work hours - come and go as you please.
We host Hack Week, where the entire company stops what they are normally doing, brings in guests (expenses covered) and
works on anything.
The quality of the people you work with is incredible. Every once in a while there comes a tech company that becomes a
magnet for engineering talent - first it was Google, then it was Facebook, now Dropbox seems to be following in their
footsteps.
We have an internal joke that if the file syncing business goes bust, we can just turn into a restaurant and t-shirt
company and we'll be fine. That's reflected in the amount of swag you get here.
Request anything from IT department (we got StarCraft II licences for a hack week AI).
100$ monthly Exec credit
Saving the best for last, you can set your own Dropbox space quota for life.

The list goes on and on and while some of the perks I mentioned can be found at other companies, if you actually see
them first hand, they always have a slight twist which makes them even better.
"""

blob = TextBlob(testparagraph)
# blob = blob.correct()
words = list(blob.tags)
word_type_list = ['JJ', 'NN', 'NR', 'NT', 'PN', 'AD']
words2 = list()
pair_list = list()
for i in range(0, len(words)):
    if words[i][1] in word_type_list:
        # print(words[i])
        words2.append(words[i])
last_noun_position = 0
last_PN_position = 0
for i in range(0, len(words2)):
    if last_noun_position > last_PN_position:
        last_position = last_noun_position
    else:
        last_position = last_PN_position
    if words2[i][1] in ['NN', 'NR', 'NT']:
        for j in range(last_position, i):
            if words2[j][1] == 'JJ':
                pair_list.append((words2[j], words2[i]))
        last_noun_position = i
    elif words2[i][1] == 'PN':
        for j in range(last_position, i):
            if words2[j][1] == 'JJ':
                pair_list.append((words2[j], words2[last_noun_position]))
        last_PN_position = i

result = dict()
for pair in pair_list:
    if pair[1][0] not in result:
        result[pair[1][0]] = TextBlob(pair[0][0]).sentiment.polarity
    else:
        result[pair[1][0]] += TextBlob(pair[0][0]).sentiment.polarity
result = pd.Series(result)
result.sort_values(ascending=False, inplace=True)
positive_reason = result[:5]
negative_reason = result[-5:].sort_values()
print('Top five positive reasons: ')
print(positive_reason)
print('Top five negative reasons: ')
print(negative_reason)
print('end')
