GithubHelp home page GithubHelp logo

lactantius / make-headlines Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 153 KB

Rewrite news headlines to switch their emotional content

Home Page: https://makeheadlines.gerardkeiser.com

License: GNU Affero General Public License v3.0

Python 56.60% HTML 19.46% TypeScript 15.00% SCSS 7.68% Dockerfile 1.15% Shell 0.11%
nlp flask flask-sqlalchemy sentiment-analysis

make-headlines's Introduction

Readme

Rewrite headlines from news organizations to change the positive/negative sentiment. Hosted at https://makeheadlines.gerardkeiser.com.

Features and Usage

Make Headlines pulls in headlines from the RSS feeds of news providers (currently just The New York Times and The Wall Street Journal) and analyzes them with sentiment model. On the main page it shows visitors a single random headline along with the sentiment (positive or negative) and the certainty score. The visitor can then write new wording for the headline and try to change the sentiment, or at least the certainty.

Anonymous users are limited to ten rewrite attempts; to continue they must create a login, which will let them view all of their previous rewrite attempts.

Implementation

The server is written in Python with Flask, tested with pytest, and uses a PostgreSQL database; the frontend uses Sass and TypeScript.

For sentiment analysis this uses the Python Flair library and the default model.

Install/Deploy

Note that Flair pulls in a very large number of dependencies, and the model itself is quite large. The Docker image is about 3.3GB, and expect it to take more than 1GB of RAM when pulling in more headlines, and ~650MB idling.

Docker Compose

  1. Set environment variables in docker-compose.yml
  2. docker compose up
  3. docker exec sentimental-headlines-web-1 python3 -m server.seed (Pulls in initial headlines. If left running, it will pull in more every three hours.)
  4. Served at localhost:5000. It must be changed in both gunicorn.config.py and docker-compose.yml.

Local

If you want to build it yourself, download the very large sentiment model, or some other model, to server/models/. (It will otherwise download it automatically, but you will have to do that every time you build a docker image.)

  1. Install dependencies and add database (default name is headlines_test)
  2. python3 -m server.seed (When run this way, it will fully reset the database.)
  3. flask run

  • [x] Regularly re-run seed headlines function
  • [x] User validations
  • [x] About page
  • [ ] Code cleanup
    • [ ] Remove unused imports, commented code, etc
    • [ ] Remove all implicit any from TypeScript
    • [ ] Test frontend (Cypress?)
    • [ ] More tests, as always
    • [ ] Flair pulls in dozens of dependencies, most of the unnecessary. Remove them from production, if possible
  • [ ] UX improvements
    • [x] Add more description/style to the user results
    • [x] Make layout responsive
    • [x] Handle failed request to /api/rewrites gracefully on the frontend
    • [x] Implement better view for showing that a request failed
    • [ ] Add cookie notification
    • [ ] Add alternative login systems (Google, Github, crypto, etc)
    • [x] Let user see all rewrites
    • [ ] Password recovery
    • [x] Profile page with edit features
    • [x] Password editing
    • [ ] Search functionality
    • [ ] Add more rewrites to old headlines
  • [ ] Interesting features
    • [ ] Calculate semantic match
    • [ ] More news sources
    • [x] Default main page to only showing recent headlines
    • [ ] Show average daily sentiment

make-headlines's People

Contributors

lactantius avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.