Created
March 30, 2020 22:52
-
-
Save cyingfan/3fbc7f446e8f5ee49f7185ddbda75418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import nltk | |
# import nltk.tokenize | |
import random | |
import re | |
#import requests | |
# reg = r'<a href="/title/[^"]+"\n>([^<]+)</a>' | |
# r = requests.get('https://www.imdb.com/list/ls033759520/?sort=list_order,asc&st_dt=&mode=simple&page=1&ref_=ttls_vw_smp') | |
# movies = re.findall(reg, r.text) | |
# alltext = " ".join(movies).strip() | |
# tags = nltk.pos_tag(nltk.tokenize.word_tokenize(alltext)) | |
# filtered_tags = i for i in tags if i[1] in ['NNP', 'JJ', 'VBP', 'VBG', 'VBZ'] and i[0] != "'s" | |
filtered_tags = [('Conspiracy', 'NNP'), ('Theory', 'NNP'), ('Six', 'NNP'), ('Degrees', 'NNP'), ('Separation', 'NNP'), ('Book', 'NNP'), ('Life', 'NNP'), ('Sleeping', 'VBG'), ('Enemy', 'NNP'), ('Mona', 'NNP'), ('Lisa', 'NNP'), ('Smile', 'NNP'), ('Eat', 'NNP'), ('Pray', 'NNP'), ('Love', 'NNP'), ('Mechanic', 'NNP'), ('Italian', 'JJ'), ('Job', 'NNP'), ('Last', 'JJ'), ('Earth', 'NNP'), ('Omega', 'NNP'), ('Man', 'NNP'), ('Hundred', 'NNP'), ('Insomnia', 'VBZ'), ('Devil', 'NNP'), ('Advocate', 'NNP'), ('City', 'NNP'), ('Angels', 'NNP'), ('Revenge', 'NNP'), ('Nerds', 'NNP'), ('Double', 'NNP'), ('Indemnity', 'NNP'), ('Double', 'NNP'), ('Jeopardy', 'NNP'), ('Rules', 'NNP'), ('Engagement', 'NNP'), ('I.Q', 'NNP'), ('L.A', 'NNP'), ('Confidential', 'NNP'), ('Sex', 'NNP'), ('Tape', 'NNP'), ('Friends', 'NNP'), ('Benefits', 'NNP'), ('BMX', 'NNP'), ('Bandits', 'NNP'), ('LazyTown', 'NNP'), ('Tale', 'NNP'), ('Despereaux', 'NNP'), ('Ratatouille', 'NNP'), ('Paparazzi', 'NNP'), ('Get', 'NNP'), ('Gringo', 'NNP'), ('Man', 'NNP'), ('Face', 'NNP'), ('Anna', 'NNP'), ('King', 'NNP'), ('Charade', 'NNP'), ('Funny', 'NNP'), ('Face', 'NNP'), ('Jackal', 'NNP'), ('Shaft', 'NNP'), ('Dreamcatcher', 'NNP'), ('Theory', 'NNP'), ('Everything', 'NNP'), ('Thank', 'NNP'), ('Smoking', 'VBG'), ('Cloudy', 'NNP'), ('Meatballs', 'NNP'), ('Anaconda', 'NNP'), ('Arachnophobia', 'NNP'), ('Snakes', 'NNP'), ('Plane', 'NNP'), ('Tremors', 'NNP'), ('Legally', 'NNP'), ('Blonde', 'NNP'), ('Tree', 'NNP'), ('Life', 'NNP'), ('Patriot', 'NNP'), ('Lethal', 'NNP'), ('Weapon', 'NNP'), ('Rush', 'NNP'), ('Hour', 'NNP'), ('Cheaper', 'NNP'), ('Dozen', 'NNP'), ('Box', 'NNP'), ('Number', 'NNP'), ('Parent', 'NNP'), ('Trap', 'NNP'), ('Woman', 'NNP'), ('Top', 'NNP'), ('Butterfly', 'NNP'), ('Effect', 'NNP'), ('Last', 'JJ'), ('King', 'NNP'), ('Scotland', 'NNP'), ('Proposal', 'NNP'), ('Star', 'NNP'), ('Blazers', 'NNP'), ('Johnny', 'NNP'), ('English', 'NNP'), ('Zootopia', 'NNP'), ('Six', 'NNP'), ('Million', 'NNP'), ('Dollar', 'NNP'), ('Man', 'NNP'), ('Rome', 'NNP'), ('Gods', 'NNP'), ('Egypt', 'NNP'), ('Boogie', 'NNP'), ('Nights', 'NNP'), ('Law', 'NNP'), ('Abiding', 'NNP'), ('Citizen', 'NNP'), ('Shakespeare', 'NNP'), ('Love', 'NNP'), ('Hide', 'NNP'), ('Seek', 'NNP'), ('Mother', 'NNP'), ('Day', 'NNP'), ('Man', 'NNP'), ('Bowfinger', 'VBP'), ('Hologram', 'NNP'), ('King', 'NNP'), ('Harry', 'NNP'), ('Met', 'NNP'), ('Sally', 'NNP'), ('Perfect', 'JJ'), ('Murder', 'NNP'), ('Frida', 'NNP'), ('Hunt', 'NNP'), ('Red', 'NNP'), ('October', 'NNP'), ('Monster-in-Law', 'NNP'), ('Good', 'NNP'), ('Luck', 'NNP'), ('Chuck', 'NNP'), ('Into', 'NNP'), ('Blue', 'NNP'), ('Cyborg', 'NNP'), ('No', 'NNP'), ('Strings', 'NNP'), ('Attached', 'NNP'), ('Pi', 'NNP'), ('Baghdad', 'NNP'), ('Messi', 'NNP'), ('Office', 'NNP'), ('Space', 'NNP'), ('Fahrenheit', 'NNP'), ('Look', 'NNP'), ('Talking', 'VBG'), ('Nine', 'NNP'), ('Lives', 'VBZ'), ('Snowpiercer', 'NNP'), ('Assassin', 'NNP'), ('Creed', 'NNP'), ('Urban', 'NNP'), ('Legend', 'NNP'), ('Pacifier', 'NNP'), ('Mad', 'NNP'), ('Max', 'NNP'), ('Fury', 'NNP'), ('Road', 'NNP'), ('Cobra', 'NNP'), ('Boss', 'NNP'), ('Baby', 'NNP'), ('Cliffhanger', 'NNP'), ('Matrix', 'NNP'), ('Army', 'NNP'), ('Emoji', 'NNP'), ('Movie', 'NNP'), ('Breakfast', 'NNP'), ('Club', 'NNP'), ('Wedding', 'NNP'), ('Singer', 'NNP'), ('White', 'NNP')] | |
w1 = [i[0] for i in filtered_tags if i[1] == 'JJ'] | |
w2 = [i[0] for i in filtered_tags if i[1] in ['VBP', 'VBG', 'VBZ', 'NNP']] | |
w3 = words = [i[0] for i in filtered_tags if i[1] in ['NNP']] | |
for i in range(10): | |
variations = [ \ | |
[random.choice(w1), random.choice(w2), random.choice(w3)], \ | |
[random.choice(w2), random.choice(w2), random.choice(w3)], \ | |
[random.choice(w1), random.choice(w3)], \ | |
[random.choice(w2), random.choice(w3)] | |
] | |
print(" ".join(random.choice(variations))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment