Skip to content

kittyofheaven/DayForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Team Description

Meet the dynamic Menacing Monkeys Hackfest Team from Institut Teknologi Sepuluh Nopember: Hazel Handrata, the skilled hacker and PIC; Hana Azizah, the savvy hustler; and Achmad Naufal, the creative hipster. Together, we blend expertise and innovation for a winning combination.

Repository Description

This repository features two branches: main and PythonModel. The main branch is dedicated to the Swift and SwiftUI codebase for the iOS mobile app, allowing users to interact with the Day Forge Sentiment Analysis API. On the other hand, the PythonModel branch hosts the Python model developed using PyTorch and Roberta, presented as a Flask API for sentiment analysis. Developers can integrate this API into various applications. For the mobile app development, simply clone the repository, switch to the main branch, open the /DayForgw directory in Xcode, and build and run the app. To explore the Python model and API, switch to the PythonModel branch, navigate to the /PythonModel directory, install dependencies using pip install -r requirements.txt, and run the Flask app with python startup.py.

App Description

Day Forge is an iOS online diary journal application whose purpose is to indirectly reduce the number of people with mental health issues. It uses machine learning for early detection of users’ depression state. Day Forge gives recommendation based on depression state especially for depressed users and connect them to platform of psychologist service.

How to use this app

To utilize this application, journal your thoughts and emotions on journal page and log your daily mood on Mood page, then the color of your journal dynamically change based on the sentiment of your writing. You explore the chart view page to track your mood over the past 30 days, offering insights into your emotional patterns. Leveraging this data, the app generates personalized tips to assist you in addressing your mental health concerns. Additionally, find a page that seamlessly redirects you to our recommended psychologists for further support. This holistic approach integrates mood tracking, sentiment analysis, and professional recommendations, allowing users to log their daily mood and prioritize their mental well-being.

Color of journal changed based on your sentiment

Fig 3.1 Color of journal changed based on your sentiment

ChartView1 ChartView2

Fig 3.2 ChartView

App Screenshots

  • Splashscreen View
Splashscreen
  • Journal View
Screenshot 2024-01-12 at 14 39 19
  • New Journal View
New Journal View
  • Today Mood Journal View
Screenshot 2024-01-12 at 14 39 36
  • Chart View
ChartView1
  • Profile View
Screenshot 2024-01-12 at 14 49 51

API Description

This Api is hosted on azure cloud service.

Introduction

Welcome to the documentation for Day Forge's Sentiment Analysis Machine Learning API. This API allows you to analyze the sentiment of a given text and receive a score along with the corresponding sentiment label. The API endpoint is available at https://dayforgemlapi.azurewebsites.net/predict_sentiment.

Quick Start

To get started, you can make a POST request to the API with a JSON payload containing the text you want to analyze. Here is an example using the curl command:

curl -X POST -H "Content-Type: application/json" -d '{"texts": "running up that hill"}' https://dayforgemlapi.azurewebsites.net/predict_sentiment

Request

  • Endpoint: https://dayforgemlapi.azurewebsites.net/predict_sentiment
  • Method: POST
  • Headers:
    • Content-Type: application/json
  • Body:
    {
      "texts": "running up that hill"
    }

Response

The API will respond with a JSON object containing the sentiment score and label:

{
  "score": 0.7298,
  "sentiment": "neutral"
}
  • score: A float value indicating the sentiment score.
  • sentiment: A string indicating the sentiment label (positive, negative, or neutral).

Example Usage in Python

You can also use the API in Python using the requests library:

import requests
import json

url = "https://dayforgemlapi.azurewebsites.net/predict_sentiment"
data = {"texts": "running up that hill"}

response = requests.post(url, json=data)
result = json.loads(response.text)

print("Sentiment Score:", result["score"])
print("Sentiment Label:", result["sentiment"])

Example Usage in Swift

Here's an example of using the Day Forge Sentiment Analysis API in Swift using the URLSession:

import Foundation

func analyzeSentiment() {
    let apiUrl = URL(string: "https://dayforgemlapi.azurewebsites.net/predict_sentiment")!
    
    // Create the request
    var request = URLRequest(url: apiUrl)
    request.httpMethod = "POST"
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    
    // Prepare the request body
    let requestBody: [String: Any] = ["texts": "running up that hill"]
    do {
        request.httpBody = try JSONSerialization.data(withJSONObject: requestBody)
    } catch {
        print("Error serializing JSON: \(error)")
        return
    }
    
    // Make the API call
    let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
        guard let data = data, error == nil else {
            print("Error: \(error?.localizedDescription ?? "Unknown error")")
            return
        }
        
        do {
            // Parse the JSON response
            let jsonResponse = try JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]
            
            // Extract sentiment information
            if let score = jsonResponse["score"] as? Double,
               let sentiment = jsonResponse["sentiment"] as? String {
                print("Sentiment Score: \(score)")
                print("Sentiment Label: \(sentiment)")
            } else {
                print("Error parsing sentiment information from the response.")
            }
        } catch {
            print("Error decoding JSON: \(error)")
        }
    }
    
    task.resume()
}

// Call the function to analyze sentiment
analyzeSentiment()

Make sure to run this code in an environment where network requests are allowed.

Error Handling

In case of errors, the API will return an appropriate HTTP status code along with an error message in the response body.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages