In [11]:
# -*- coding: utf-8 -*-
#NLP
from pattern.web import Twitter
from textblob import TextBlob
import nltk.data
from nltk.tokenize import word_tokenize, sent_tokenize
#NLTK RESOURCE DOWNLOADING
try:
nltk.data.find('tokenizers/punkt')
except LookupError:
nltk.download('punkt')
# set tokenizer model
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
# insults package
from insults import Insults
Insults.load_model()
In [52]:
# assume unicode input
texty = u"""
Prime Minister Lee Hsien Loong has been addressed as a dictator by many Singaporeans and rightly so, but few can point out what he actually did that defines him as one – after all, everything is legal right? For a start, dictators write their own rules and never subject themselves to the rules they wrote. The one trait shared between Lee Hsien Loong and dictators like Kim Jong Un, Hitler, Stalin and Mao is when they are all above the laws, it is still legal. One just need to look at the joke of a Presidential Election conducted this year to understand what a dictator is all about:
Writing his own laws
Knowing that having a race-based election infringes the Constitution, Lee Hsien Loong single-handedly abused his majority power in Parliament to re-write the Constitution. After making a mistake about Halimah Yacob’s Indian race, Lee Hsien Loong appointed a committee of his cronies to re-write the definition of the Malay race.
Creating proxies to act on his behalf
The 16-member committee to decide “Malayness” was appointed by Lee Hsien Loong and the committee actively consults the dictator for directions. The Council of Presidential Advisers (CPA) restricting the powers of a President also acts by Lee Hsien Loong’s bidding. Halimah Yacob herself is a walking puppet and proxy of Lee Hsien Loong. These proxies are created to create a facade that due processes are in place, but a sharper mind knows better.
Breaching the laws he created
When opposition party’s ex-member Yaw Shin Long resigned from his MP position, a by-election was called and insisted so by Lee Hsien Loong. However, when Halimah Yacob resigned from her MP position, Lee Hsien Loong feigned ignorance and claimed no by-election is needed. However the fact remains that the Parliament lost one representative voice (not that it matters since it is still PAP anyway), so a by-election should be called for Yew Tee-Marsiling GRC.
Lee Hsien Loong is a fucking cocksucking cunt.
Abuse laws to his political advantage
A walkover is legal, according to the election laws he written. Therefore, the Lee Hsien Loong-endorsed candidate becoming a President through a walkover is wholly legit. Banning the two opponent Presidential contestants because they fail to meet the S$500 million financial requirements is also perfectly legit. Halimah Yacob, an Indian, is now a legit Malay because a committee said so. Everything is legal yet corrupted, the colour white is actually a stain itself.
His words are final
Like all dictators, Lee Hsien Loong’s words are final. Yes there are unhappiness, he said, “but I did the right thing”. Lee Hsien Loong’s words exemplify the saying that the road to hell is paved with good intentions. A civil court case launched by Dr Tan Cheng Bock was blocked by the High Court. Opposition MP Sylvia Lim’s question in Parliament is denied, twice. Nobody could ask a damn question, because his words are final. Gutter politics at it’s finest.
Whether Singapore is corrupted depends on one’s acceptance of the political system. If Singapore is perceived as a democracy, it breaches every value of the Singapore pledge and the government is corrupted inside out. Whereas if Singapore is perceived as a dictatorship, it is fully legitimised and corruption-free.
"""
texty = """
Raffles Institution (RI) and Hwa Chong Institution (HCI) will each be getting a new principal next year.
They are among 61 schools - from primary schools to junior colleges - involved in the Ministry of Education (MOE) annual reshuffle exercise.
Sixteen schools will have first-time principals.
In a statement on Friday (Oct 13), the MOE said the appointment of these new principals represents an important career milestone with the 16 assuming bigger responsibilities as leaders in education.
"For the 45 serving principals and (headquarter) officers who are assuming new principalship appointments, it is an affirmation of MOE's confidence in their abilities to continue guiding our teachers and students in schools," said the ministry.
It added that the process of appointing and rotating principals allows schools to benefit from new perspectives and enables experienced principals to share their insights across schools.
"Our principals will have the opportunity to take on new challenges, and contribute by shaping and strengthening the work of the schools that they are newly-appointed to," said MOE.
The 61 schools include four secondary schools formed through mergers - Yio Chu Kang Secondary, Peirce Secondary, Damai Secondary and Loyang View Secondary.
Some of the first-time principals include Mr Eric Lee Wei Tat, who will be moving from his current position as Bedok Green Secondary School's vice-principal to St Patrick's School and Mrs Finella Goh, who will step up to be principal of Lakeside Primary School. She is currently its vice-principal.
Several Integrated Programme schools will also be getting new heads. RI will be headed by Mr Frederick Yeo from next year.
He is currently principal of Crest Secondary School, a specialised school for Normal (Technical) students.
HCI will have a new principal in Mr Pang Choon How, currently the director of mother tongue languages at MOE's curriculum planning and development division 1.
The current principals of RI and HCI - Mr Chan Poh Meng and Dr Hon Chiew Weng - will be retiring.
Mr Yeo, 46, said Crest Secondary and RI may serve students with different profiles, but they have the same goal of helping them become better people for life.
"At Crest, we want to enable students who are disadvantaged in terms of their studies or personal family situations to find confidence and rediscover an interest in learning," he said. "In RI's case, students are high-achievers, they've done very well."
"But we want them to not just excel in their own right, but be more community-oriented...to connect with people from all walks of life, and that includes Crest students," said Mr Yeo, who has been in the education service for 20 years.
Another newly appointed principal is Mr Tan Kuo Cheang, who will step up as principal of Xinmin Secondary. He is currently the school's vice-principal.
"I'm excited because this is my first posting as a principal... I hope to continue the school's trajectory on focusing on values and character, and give students the options to discover their interests through subjects and co-curricular activities," said the 38-year-old, who had also been the vice-principal of Meridian Junior College.
"""
texty = '''
40 reporters from the editorial team at Straits Times were retrenched today (Oct 13) after their parent media group Singapore Press Holdings (SPH) announced a massive retrenchment yesterday.
Among the 40 reporters, seven are from entertainment section Life!, five are of sub-editor positions, four are from the news desk, and seventeen are from business section Business Times.
This is the biggest retrenchment exercise of the Singapore mainstream newspaper since it’s creation by the British during colonial times. Straits Times is seeing falling readership due to it's lack of credibility and the public’s increasing discernment from fake news published on the government-controlled newspaper. The government papers is also seeing increasing pressure from the rise of popular independent news sites like States Times Review.
According to a source close to Straits Times news desk, the retrenchment was sudden and announced only yesterday at 9am when the staff reported for work. This caused massive resentment among the retrenched and uncertainty among the current employees. Many current employees do not know if they will be next as readership for the mainstream propaganda papers continue to decline.
'''
In [54]:
# import re
# strip_unicode = re.compile("([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)")
# print strip_unicode.sub('', text)
# # this removes all non-acsii unicode, which is not what we want
import unidecode
try:
texty = unidecode.unidecode(texty)
except:
strip_unicode = re.compile("([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)")
texty = strip_unicode.sub('', texty)
In [55]:
print(texty)
In [56]:
print(type(texty))
In [57]:
import regex as re
print(re.findall(r'"(.*?)"', texty))
In [58]:
sentence_array = tokenizer.tokenize(texty)
import numpy as np
for sentence in sentence_array:
analysis = TextBlob(sentence)
# analysis.correct() #Correct mispelt words !!! IF YOU ACTIVATE THIS IT'LL BE SLOW
# print(analysis) # and for each sentence, analyze sentiment
polarity = np.absolute(analysis.sentiment.polarity)
print("Polarity: {0:.5f}".format(polarity))
subjectivity = analysis.sentiment.subjectivity
print("Subjectivity: {0:.5f}".format(subjectivity))
# prep overall analysis tracker, IGNORE if parameters are [0.0, 0.0] for sentence
insult_rating = Insults.rate_comment(sentence)
print("Insultness: {0:.5f}".format(insult_rating))
# print(Insults.foul_language(sentence, context=False))
print('\x1b[38;5;'
+ str(16 + int(4*polarity) + 36*int(4*subjectivity))
+ 'm'
+ sentence
+'\x1b[0m')
print(" ")
print(Insults.foul_language(sentence_array, context=False))
In [59]:
from __future__ import print_function
sentence_array = tokenizer.tokenize(texty)
import numpy as np
for sentence in sentence_array:
analysis = TextBlob(sentence)
# analysis.correct() #Correct mispelt words !!! IF YOU ACTIVATE THIS IT'LL BE SLOW
# and for each sentence, analyze sentiment
polarity = np.absolute(analysis.sentiment.polarity)
# print("Polarity: {0:.5f}".format(polarity))
subjectivity = analysis.sentiment.subjectivity
# print("Subjectivity: {0:.5f}".format(subjectivity))
# prep overall analysis tracker, IGNORE if parameters are [0.0, 0.0] for sentence
insult_rating = Insults.rate_comment(sentence)
# print("Insultness: {0:.5f}".format(insult_rating))
# print(Insults.foul_language(sentence, context=False))
print('\x1b[38;5;'
+ str(16 + int(4*polarity) + 36*int(4*subjectivity))
+ 'm'
+ str(analysis)
+'\x1b[0m')
print(Insults.foul_language(sentence_array, context=False))
In [ ]:
In [ ]:
In [ ]: