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.
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
.
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.
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](https://private-user-images.githubusercontent.com/71081063/297690212-a4e9b302-11e9-4152-ae3b-366f31d7f67d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTc2OTAyMTItYTRlOWIzMDItMTFlOS00MTUyLWFlM2ItMzY2ZjMxZDdmNjdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI3MTEwOWViYTc5ZmU2MDRhZjM1MmFiNGRlMWE0MTU0YzY0NWRhZDk0NWMzMGMxZTI4NWMwY2U2NTQ4YjIyOGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._1u5zZb5_3h93j0lS8AE4fOosJgunHk3lTlJBqoen4g)
Fig 3.1 Color of journal changed based on your sentiment
![ChartView1](https://private-user-images.githubusercontent.com/71081063/297690884-11261d6c-911a-4312-a28d-66a5e4f2c68e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTc2OTA4ODQtMTEyNjFkNmMtOTExYS00MzEyLWEyOGQtNjZhNWU0ZjJjNjhlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJlYzY5YmJmZjNkN2ZhMmFiNzIwZDZhYjkxMmQyMmRhYWM4YmRhMTdiMjk5ZDg4ZjQ5MGNhY2EzZDM5YTJiMWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ndj3TmPKsKS-njrUWn0Za7B5UyNnIQ8e9pn9KIEfV5E)
![ChartView2](https://private-user-images.githubusercontent.com/71081063/297690903-e05abc96-7f41-49bd-9dfc-efd531ac3657.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTc2OTA5MDMtZTA1YWJjOTYtN2Y0MS00OWJkLTlkZmMtZWZkNTMxYWMzNjU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEyZDkzNjU5M2Q3MzJjMDRjN2U3ZmQ5ZGM0MDVhMDlmZjgzY2U5MWVmMzg2NWM5ZjFiZjE0Y2FlYmUxZmE4YzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.cu_spSUYhm8T7jM4kq6fOadQval1i4HirvnI_Z2OMiA)
Fig 3.2 ChartView
- Splashscreen View
![Splashscreen](https://private-user-images.githubusercontent.com/71081063/296214449-9f7b265c-ab37-4f7b-8396-fc0489198f58.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTYyMTQ0NDktOWY3YjI2NWMtYWIzNy00ZjdiLTgzOTYtZmMwNDg5MTk4ZjU4LmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxNlQwNDUxNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xYWI5ZmQ4ZjI4ZTIwYTcwNDE0MjNmMDAxY2QyNDk3OWRkNDZjNzRmZmRmMThmNzMwNGQ2Y2I1YTE2ZTY2YTMwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.U2N9z4rh3S-Vdyp4Iy81MUXUHfw8WUlThB6qpVwzzas)
- Journal View
![Screenshot 2024-01-12 at 14 39 19](https://private-user-images.githubusercontent.com/71081063/296214023-1967af36-6957-418f-b895-6a0d7f0b3f04.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTYyMTQwMjMtMTk2N2FmMzYtNjk1Ny00MThmLWI4OTUtNmEwZDdmMGIzZjA0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJkMjMxNjk4NzY4M2VmZDJjNjNjYTNmZThhYWI1Y2ZmOTE4N2RkNTMzYjJkM2M1NTY3NDRjZjQ3Njg0ZDAxNjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7BMC9v5k7cizVNXx5UNWPmMqJkFHUfCtABM-jExpAjc)
- New Journal View
![New Journal View](https://private-user-images.githubusercontent.com/71081063/296214515-3f526805-a754-4a3f-bd87-aea95ae8d2a2.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTYyMTQ1MTUtM2Y1MjY4MDUtYTc1NC00YTNmLWJkODctYWVhOTVhZThkMmEyLmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxNlQwNDUxNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZTkwMjY0MWRlNzVjOWVmNzU1NWNiZDJkMWE4ODYwOTdlZjE1OWRlNmNiMTQ3ZWE1ZDMyZGI4NjBmZDMyZDZjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.5lm2hloO59MIbr3BTV8uzUVnWPDpMb3ih7qZHzgyQaw)
- Today Mood Journal View
![Screenshot 2024-01-12 at 14 39 36](https://private-user-images.githubusercontent.com/71081063/296214208-226fe9f3-6aa4-471d-99f4-92dd12b91ba8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTYyMTQyMDgtMjI2ZmU5ZjMtNmFhNC00NzFkLTk5ZjQtOTJkZDEyYjkxYmE4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY4OWMwNjllOTFhY2UwYjc2MDA5OWY3MTIwYzc1YmQ4MWUyYjEzNzE3NTU2NjIxZDM0M2UwZGJhMjM0NjE4ZWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.T9KKDNxArmi_0b2KBy80D6XnNdhH690GLcH6car0dW8)
- Chart View
![ChartView1](https://private-user-images.githubusercontent.com/71081063/297690884-11261d6c-911a-4312-a28d-66a5e4f2c68e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTc2OTA4ODQtMTEyNjFkNmMtOTExYS00MzEyLWEyOGQtNjZhNWU0ZjJjNjhlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJlYzY5YmJmZjNkN2ZhMmFiNzIwZDZhYjkxMmQyMmRhYWM4YmRhMTdiMjk5ZDg4ZjQ5MGNhY2EzZDM5YTJiMWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ndj3TmPKsKS-njrUWn0Za7B5UyNnIQ8e9pn9KIEfV5E)
- Profile View
![Screenshot 2024-01-12 at 14 49 51](https://private-user-images.githubusercontent.com/71081063/296214089-55cc2ab5-1116-4556-b68e-1c5ab3b884c9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1MTM4MDgsIm5iZiI6MTcxODUxMzUwOCwicGF0aCI6Ii83MTA4MTA2My8yOTYyMTQwODktNTVjYzJhYjUtMTExNi00NTU2LWI2OGUtMWM1YWIzYjg4NGM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE2VDA0NTE0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIyYjU4ZTczZTE2YmEzYzVhNzZhZmQ5ZGVmMzJiZjlkMzE4YjdlZTU0MmU5ZTA4OWRmOWJkMmZjZjg1OTg0MzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.rwyHUcvaFNa0Aaaa9StbA8oFW6vH8RjVoL3bANKqpMI)
This Api is hosted on azure cloud service.
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.
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
- Endpoint:
https://dayforgemlapi.azurewebsites.net/predict_sentiment
- Method: POST
- Headers:
- Content-Type: application/json
- Body:
{ "texts": "running up that hill" }
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
, orneutral
).
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"])
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.
In case of errors, the API will return an appropriate HTTP status code along with an error message in the response body.