Giter Site home page Giter Site logo

metaphorproject's Introduction

MetaphorProject

Project that uses Metaphor's API and a Sentiment Analyzer to explore common sentiment online regarding a user-defined question.

How to run:

In order to run this project, follow the below steps:

  1. Clone the repository
  2. Open main.py in MetaphorProject/Metaphor
  3. Replace the placeholder API Key with a working Metaphor key.
  4. Download with "pip3" the following dependencies: torch, transformers, flask, and metaphor_python
    • Python version used is 3.11
  5. Run program with "python3 main.py"
  6. Open Xcode Project on Xcode 15.0
  7. Launch iOS simulator or use iOS Preview
  8. Type question into the TextField bar at the top of the app
  9. Click the button below the TextField and watch the app's recommendation appear on the screen.

How does this work?

This project consists of two portions, a Python Flask server and a client iOS application. The python flask server uses two of Metaphor's endpoints, being "search" and "get contents". For a given question, a search is performed with Metaphor's "search" and then the ids of the search results are collected. The "get contents" endpoint is then used to get the text found on the webpages. A prebuilt sentiment analyzing model is used to get the common sentiment of the text found on the webpages. The sentiments are averaged out to a singular value. If the value is positive, then the sentiment is a positive one, and if the value is negative, then the sentiment is negative, with the magnitude of the value representing how negative or positive the sentiment is on a scale of -1 to 1. The iOS application takes a question written by the user and hits an endpoint on the Python Flask server, providing the question and expecting a resulting sentiment value to be returned.

Alternatives

The client does not have to be an iOS server. The Flask endpoint is agnostic to the client. The below endpoint is what the Flask server expects:

http://127.0.0.1:8080/getSentiment?question=User Defined Question?

The "User Defined Question?" can be replaced with any question the user wants an answer to.

Demo

https://youtu.be/RDS1Lyaj0sg

Above is a link to a video I made quickly showcasing how the project works.

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.