variations of the output:
new_text - all adjectives used to describe the situation;
new_text2 - all adjectives, split
new_text3 - all the adjectives, sorted alphabetically (with repetition)
new_text4 - alphabetical list of the adjectives, unique only (no repetition)
from urllib.request import urlopen
from urllib.parse import urlencode
import json
from textblob import TextBlob
api_url = "https://hub.xpub.nl/soupboat/pad/api/1.2.15/"
with open("/opt/etherpad/APIKEY.txt") as f:
api_key = f.read()
# wrap in a convenient function
def ep (api_fn, api_url, api_key, **data):
data['apikey'] = api_key
return json.load(urlopen(f"{api_url}{api_fn}", data=urlencode(data).encode()))
input_padid = "alnik-petitions" # "input" is the ID of the pad we use as a source - for new ones, change it here
output_padid = "alnik-petitions-processed" # "output" is the ID of the pad where we place the output - for new ones, change it here
input_text = ep("getText", api_url, api_key, padID=input_padid)
input_text = input_text['data']['text']
input_blob = TextBlob(input_text)
new_text = ""
for word, tag in input_blob.tags:
if tag == "JJ":
print (word)
new_text += word + "\n"
ep("setText", api_url, api_key, padID=output_padid, text=new_text3) #change here which type of list to print
married final rental impossible rental hectic last few ingernational crazy Dutch Huge Good absolute decent somewhere safe next unlikely disgraceful single single different private few available remote new international come 2-3 furious great impossible stressful able hard xenophobic impossible international second egregious ’ next able mechanical concerned particular international frank disappointed entrepreneurial embarrassing major many real serious Dutch decisive temporary real creative decisive international right academic few first difficult extra few many available many stressful ridiculous many enough honest right temporary outside impossible other available good non-dutch international personal Dutch ‘ Dutch unacceptable reasonable able local independent studio/apartment many False eg local aware sad reflect poor genuine serious bad local local hefty foreign unable encouraging full local huge acceptable careful native own force many main short huge new enough nice real sure
{'code': 0, 'message': 'ok', 'data': None}
import nltk
new_text
'married\nfinal\nrental\nimpossible\nrental\nhectic\nlast\nfew\ningernational\ncrazy\nDutch\nHuge\nGood\nabsolute\ndecent\nsomewhere\nsafe\nnext\nunlikely\ndisgraceful\nsingle\nsingle\ndifferent\nprivate\nfew\navailable\nremote\nnew\ninternational\ncome\n2-3\nfurious\ngreat\nimpossible\nstressful\nable\nhard\nxenophobic\nimpossible\ninternational\nsecond\negregious\n’\nnext\nable\nmechanical\nconcerned\nparticular\ninternational\nfrank\ndisappointed\nentrepreneurial\nembarrassing\nmajor\nmany\nreal\nserious\nDutch\ndecisive\ntemporary\nreal\ncreative\ndecisive\ninternational\nright\nacademic\nfew\nfirst\ndifficult\nextra\nfew\nmany\navailable\nmany\nstressful\nridiculous\nmany\nenough\nhonest\nright\ntemporary\noutside\nimpossible\nother\navailable\ngood\nnon-dutch\ninternational\npersonal\nDutch\n‘\nDutch\nunacceptable\nreasonable\nable\nlocal\nindependent\nstudio/apartment\nmany\nFalse\neg\nlocal\naware\nsad\nreflect\npoor\ngenuine\nserious\nbad\nlocal\nlocal\nhefty\nforeign\nunable\nencouraging\nfull\nlocal\nhuge\nacceptable\ncareful\nnative\nown\nforce\nmany\nmain\nshort\nhuge\nnew\nenough\nnice\nreal\nsure\n'
new_text.split(' ')
['married\nfinal\nrental\nimpossible\nrental\nhectic\nlast\nfew\ningernational\ncrazy\nDutch\nHuge\nGood\nabsolute\ndecent\nsomewhere\nsafe\nnext\nunlikely\ndisgraceful\nsingle\nsingle\ndifferent\nprivate\nfew\navailable\nremote\nnew\ninternational\ncome\n2-3\nfurious\ngreat\nimpossible\nstressful\nable\nhard\nxenophobic\nimpossible\ninternational\nsecond\negregious\n’\nnext\nable\nmechanical\nconcerned\nparticular\ninternational\nfrank\ndisappointed\nentrepreneurial\nembarrassing\nmajor\nmany\nreal\nserious\nDutch\ndecisive\ntemporary\nreal\ncreative\ndecisive\ninternational\nright\nacademic\nfew\nfirst\ndifficult\nextra\nfew\nmany\navailable\nmany\nstressful\nridiculous\nmany\nenough\nhonest\nright\ntemporary\noutside\nimpossible\nother\navailable\ngood\nnon-dutch\ninternational\npersonal\nDutch\n‘\nDutch\nunacceptable\nreasonable\nable\nlocal\nindependent\nstudio/apartment\nmany\nFalse\neg\nlocal\naware\nsad\nreflect\npoor\ngenuine\nserious\nbad\nlocal\nlocal\nhefty\nforeign\nunable\nencouraging\nfull\nlocal\nhuge\nacceptable\ncareful\nnative\nown\nforce\nmany\nmain\nshort\nhuge\nnew\nenough\nnice\nreal\nsure\n']
new_text
'married\nfinal\nrental\nimpossible\nrental\nhectic\nlast\nfew\ningernational\ncrazy\nDutch\nHuge\nGood\nabsolute\ndecent\nsomewhere\nsafe\nnext\nunlikely\ndisgraceful\nsingle\nsingle\ndifferent\nprivate\nfew\navailable\nremote\nnew\ninternational\ncome\n2-3\nfurious\ngreat\nimpossible\nstressful\nable\nhard\nxenophobic\nimpossible\ninternational\nsecond\negregious\n’\nnext\nable\nmechanical\nconcerned\nparticular\ninternational\nfrank\ndisappointed\nentrepreneurial\nembarrassing\nmajor\nmany\nreal\nserious\nDutch\ndecisive\ntemporary\nreal\ncreative\ndecisive\ninternational\nright\nacademic\nfew\nfirst\ndifficult\nextra\nfew\nmany\navailable\nmany\nstressful\nridiculous\nmany\nenough\nhonest\nright\ntemporary\noutside\nimpossible\nother\navailable\ngood\nnon-dutch\ninternational\npersonal\nDutch\n‘\nDutch\nunacceptable\nreasonable\nable\nlocal\nindependent\nstudio/apartment\nmany\nFalse\neg\nlocal\naware\nsad\nreflect\npoor\ngenuine\nserious\nbad\nlocal\nlocal\nhefty\nforeign\nunable\nencouraging\nfull\nlocal\nhuge\nacceptable\ncareful\nnative\nown\nforce\nmany\nmain\nshort\nhuge\nnew\nenough\nnice\nreal\nsure\n'
new_text.split('\n')
['married', 'final', 'rental', 'impossible', 'rental', 'hectic', 'last', 'few', 'ingernational', 'crazy', 'Dutch', 'Huge', 'Good', 'absolute', 'decent', 'somewhere', 'safe', 'next', 'unlikely', 'disgraceful', 'single', 'single', 'different', 'private', 'few', 'available', 'remote', 'new', 'international', 'come', '2-3', 'furious', 'great', 'impossible', 'stressful', 'able', 'hard', 'xenophobic', 'impossible', 'international', 'second', 'egregious', '’', 'next', 'able', 'mechanical', 'concerned', 'particular', 'international', 'frank', 'disappointed', 'entrepreneurial', 'embarrassing', 'major', 'many', 'real', 'serious', 'Dutch', 'decisive', 'temporary', 'real', 'creative', 'decisive', 'international', 'right', 'academic', 'few', 'first', 'difficult', 'extra', 'few', 'many', 'available', 'many', 'stressful', 'ridiculous', 'many', 'enough', 'honest', 'right', 'temporary', 'outside', 'impossible', 'other', 'available', 'good', 'non-dutch', 'international', 'personal', 'Dutch', '‘', 'Dutch', 'unacceptable', 'reasonable', 'able', 'local', 'independent', 'studio/apartment', 'many', 'False', 'eg', 'local', 'aware', 'sad', 'reflect', 'poor', 'genuine', 'serious', 'bad', 'local', 'local', 'hefty', 'foreign', 'unable', 'encouraging', 'full', 'local', 'huge', 'acceptable', 'careful', 'native', 'own', 'force', 'many', 'main', 'short', 'huge', 'new', 'enough', 'nice', 'real', 'sure', '']
new_text2 = new_text.split('\n')
new_text2
['married', 'final', 'rental', 'impossible', 'rental', 'hectic', 'last', 'few', 'ingernational', 'crazy', 'Dutch', 'Huge', 'Good', 'absolute', 'decent', 'somewhere', 'safe', 'next', 'unlikely', 'disgraceful', 'single', 'single', 'different', 'private', 'few', 'available', 'remote', 'new', 'international', 'come', '2-3', 'furious', 'great', 'impossible', 'stressful', 'able', 'hard', 'xenophobic', 'impossible', 'international', 'second', 'egregious', '’', 'next', 'able', 'mechanical', 'concerned', 'particular', 'international', 'frank', 'disappointed', 'entrepreneurial', 'embarrassing', 'major', 'many', 'real', 'serious', 'Dutch', 'decisive', 'temporary', 'real', 'creative', 'decisive', 'international', 'right', 'academic', 'few', 'first', 'difficult', 'extra', 'few', 'many', 'available', 'many', 'stressful', 'ridiculous', 'many', 'enough', 'honest', 'right', 'temporary', 'outside', 'impossible', 'other', 'available', 'good', 'non-dutch', 'international', 'personal', 'Dutch', '‘', 'Dutch', 'unacceptable', 'reasonable', 'able', 'local', 'independent', 'studio/apartment', 'many', 'False', 'eg', 'local', 'aware', 'sad', 'reflect', 'poor', 'genuine', 'serious', 'bad', 'local', 'local', 'hefty', 'foreign', 'unable', 'encouraging', 'full', 'local', 'huge', 'acceptable', 'careful', 'native', 'own', 'force', 'many', 'main', 'short', 'huge', 'new', 'enough', 'nice', 'real', 'sure', '']
sorted(new_text2)
['', '2-3', 'Dutch', 'Dutch', 'Dutch', 'Dutch', 'False', 'Good', 'Huge', 'able', 'able', 'able', 'absolute', 'academic', 'acceptable', 'available', 'available', 'available', 'aware', 'bad', 'careful', 'come', 'concerned', 'crazy', 'creative', 'decent', 'decisive', 'decisive', 'different', 'difficult', 'disappointed', 'disgraceful', 'eg', 'egregious', 'embarrassing', 'encouraging', 'enough', 'enough', 'entrepreneurial', 'extra', 'few', 'few', 'few', 'few', 'final', 'first', 'force', 'foreign', 'frank', 'full', 'furious', 'genuine', 'good', 'great', 'hard', 'hectic', 'hefty', 'honest', 'huge', 'huge', 'impossible', 'impossible', 'impossible', 'impossible', 'independent', 'ingernational', 'international', 'international', 'international', 'international', 'international', 'last', 'local', 'local', 'local', 'local', 'local', 'main', 'major', 'many', 'many', 'many', 'many', 'many', 'many', 'married', 'mechanical', 'native', 'new', 'new', 'next', 'next', 'nice', 'non-dutch', 'other', 'outside', 'own', 'particular', 'personal', 'poor', 'private', 'real', 'real', 'real', 'reasonable', 'reflect', 'remote', 'rental', 'rental', 'ridiculous', 'right', 'right', 'sad', 'safe', 'second', 'serious', 'serious', 'short', 'single', 'single', 'somewhere', 'stressful', 'stressful', 'studio/apartment', 'sure', 'temporary', 'temporary', 'unable', 'unacceptable', 'unlikely', 'xenophobic', '‘', '’']
new_text3 = sorted(new_text2)
new_text3
['', '2-3', 'Dutch', 'Dutch', 'Dutch', 'Dutch', 'False', 'Good', 'Huge', 'able', 'able', 'able', 'absolute', 'academic', 'acceptable', 'available', 'available', 'available', 'aware', 'bad', 'careful', 'come', 'concerned', 'crazy', 'creative', 'decent', 'decisive', 'decisive', 'different', 'difficult', 'disappointed', 'disgraceful', 'eg', 'egregious', 'embarrassing', 'encouraging', 'enough', 'enough', 'entrepreneurial', 'extra', 'few', 'few', 'few', 'few', 'final', 'first', 'force', 'foreign', 'frank', 'full', 'furious', 'genuine', 'good', 'great', 'hard', 'hectic', 'hefty', 'honest', 'huge', 'huge', 'impossible', 'impossible', 'impossible', 'impossible', 'independent', 'ingernational', 'international', 'international', 'international', 'international', 'international', 'last', 'local', 'local', 'local', 'local', 'local', 'main', 'major', 'many', 'many', 'many', 'many', 'many', 'many', 'married', 'mechanical', 'native', 'new', 'new', 'next', 'next', 'nice', 'non-dutch', 'other', 'outside', 'own', 'particular', 'personal', 'poor', 'private', 'real', 'real', 'real', 'reasonable', 'reflect', 'remote', 'rental', 'rental', 'ridiculous', 'right', 'right', 'sad', 'safe', 'second', 'serious', 'serious', 'short', 'single', 'single', 'somewhere', 'stressful', 'stressful', 'studio/apartment', 'sure', 'temporary', 'temporary', 'unable', 'unacceptable', 'unlikely', 'xenophobic', '‘', '’']
sorted(set(new_text3))
['', '2-3', 'Dutch', 'False', 'Good', 'Huge', 'able', 'absolute', 'academic', 'acceptable', 'available', 'aware', 'bad', 'careful', 'come', 'concerned', 'crazy', 'creative', 'decent', 'decisive', 'different', 'difficult', 'disappointed', 'disgraceful', 'eg', 'egregious', 'embarrassing', 'encouraging', 'enough', 'entrepreneurial', 'extra', 'few', 'final', 'first', 'force', 'foreign', 'frank', 'full', 'furious', 'genuine', 'good', 'great', 'hard', 'hectic', 'hefty', 'honest', 'huge', 'impossible', 'independent', 'ingernational', 'international', 'last', 'local', 'main', 'major', 'many', 'married', 'mechanical', 'native', 'new', 'next', 'nice', 'non-dutch', 'other', 'outside', 'own', 'particular', 'personal', 'poor', 'private', 'real', 'reasonable', 'reflect', 'remote', 'rental', 'ridiculous', 'right', 'sad', 'safe', 'second', 'serious', 'short', 'single', 'somewhere', 'stressful', 'studio/apartment', 'sure', 'temporary', 'unable', 'unacceptable', 'unlikely', 'xenophobic', '‘', '’']
new_text4 = sorted(set(new_text3))