Skip to content

Web app that imagines how much cooler fortune cookies would be if the messages inside were movie plots. ๐ŸŽฌ๐Ÿ“ฝ๐Ÿฟ๐Ÿฅ 

License

Notifications You must be signed in to change notification settings

EricPostMaster/fortune-cookie-movies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

81 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Fortune Cookie Movies ๐Ÿฅ ๐Ÿ“ฝ๏ธ๐Ÿฟ

Question: What if fortune cookies were filled with movie plots where you were the main character???

Answer: They'd be way cooler. Try it yourself here!

How it started:

One day I was looking for interesting uses of Natural Language Processing (NLP) and happened upon Alex Reben's AI Misfortunes project. If you haven't seen it, he trained a neural network on thousands of fortune cookies, and now it writes mysterious and often hilarious one-liners that are even sold as wall art! ๐Ÿฅ โžก๏ธ๐Ÿ–ผ๏ธ

I thought, "Hmm... I wonder if I could turn that around and turn something that isn't a fortune cookie and into a fortune cookie??" ๐Ÿค” Movie plots are nice, short statements that summarize a story that will unfold, and people are generally pretty familiar with popular movie plots, so it seemed like a perfect place to start!

Thus, Fortune Cookie Movies was born. ๐Ÿ“ฝ๏ธโžก๏ธ๐Ÿฅ 

How it's going:

Try out the Fortune Cookie Movies app yourself! Grab some extra buttery popcorn and test your movie knowledge with a fortune cookie movie quiz or tempt fate with a random movie fortune. Adventure awaits!

Here's what the app looks like:

Web app demo GIF

How it works:

If you've read this far, you probably want to know what's under the hood. If not, you're about to hear about it anyway!

Essentially, the repo is broken into three parts: retrieving the data, transforming the data, and the web application.

Retrieving the data

Data is pulled from IMDb using imdb-api, which at the time of this writing is free to use up to 100 calls per day. If you're starting from scratch, the script will take an initial movie ID as a seed, and then it will populate the dataset from there using similar movies returned in the JSON payload.

Transforming the data

The current script uses the spaCy English language transformer pipeline. I tried using the small pipeline to get started, and while it saves a lot of memory, performance is just so much better with the transformer model. The movie plots are transformed and saved ahead of time. I then used Tortus package to annotate the plots as Good, Okay, or Bad to decide which ones would be served up to users. The initial app only shows those that were tagged as Good, but Okay fortunes are still intelligible.

Web application

The app is built on Plotly Dash. It is Dockerized and pushed to AWS Elastic Container Registry. If you're interested in doing something similar, you can follow this excellent tutorial from Melvin Varughese.

Contribute!

This app exists because cool people contributed a bit of their time and expertise to make it a reality. You are welcome to submit ideas and improvements by creating issues and pull requests on this repo!

Contributors:

Running the web app

There are a few ways to run this app, all shown below. Once you run one of the commands below the app should be available at http://localhost:8050.

With Docker Compose

Getting started with Docker Compose is probably the easiest, assuming you have Docker and Docker Compose installed already. If you do then just run the below:

docker-compose up -d

The image should be automatically built as part of the above command. To build the image without starting the service you can run the following:

docker-compose build

To stop the docker-compose application run the below:

docker-compose down

With Docker

If you have Docker installed, but not Docker Compose, that's okay. First we need to build the image:

docker build --tag fcm-app .

Once the image is built you can run the app with the below Docker command:

docker run -p 8050:8050 fcm-app
Possible errors
subprocess.CalledProcessError: Command '['/usr/bin/java', '-version']' returned non-zero exit status 1.
  • If you're on MacOS, make sure you have a Java installed.
OSError: [E050] Can't find model 'en_core_web_trf'. It doesn't seem to be a Python package or a valid path to a data directory.
  • python -m spacy download en_core_web_trf
    or
  • python3 -m spacy download en_core_web_trf

About

Web app that imagines how much cooler fortune cookies would be if the messages inside were movie plots. ๐ŸŽฌ๐Ÿ“ฝ๐Ÿฟ๐Ÿฅ 

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •