This commit is contained in:
FarhanHA442 2025-05-07 10:37:51 +07:00
commit 3fc869132d
10 changed files with 237 additions and 0 deletions

BIN
assets/background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
assets/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
assets/zeopoxa.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

35
deteksi_sentimen.php Normal file
View File

@ -0,0 +1,35 @@
<!-- deteksi_sentimen.php -->
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Deteksi Sentimen</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="sentiment" id="sentimen">
<div class="form-container">
<h2>Deteksi Sentimen Ulasan</h2>
<p class="subtitle">Aplikasi: <strong>Zeopoxa Running</strong></p>
<form action="proses_sentimen.php" method="POST">
<input type="text" name="ulasan" placeholder="Masukkan kata atau kalimat ulasan..." required>
<button type="submit">Proses</button>
</form>
<?php if (isset($_GET['hasil']) && isset($_GET['ulasan'])): ?>
<div class="hasil-box">
<label for="hasilUlasan">Hasil Deteksi Sentimen:</label>
<div class="hasil-text" id="hasilUlasan">
<strong><?= htmlspecialchars($_GET['ulasan']) ?></strong> termasuk kalimat sentimen <strong><?= htmlspecialchars($_GET['hasil']) ?></strong>
</div>
</div>
<?php endif; ?>
<a href="index.php" class="back-link"> Kembali ke Landing Page</a>
</div>
</section>
</body>
</html>

19
index.php Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Zeopoxa Running</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="landing">
<div class="container">
<img src="assets/zeopoxa.png" alt="Logo Zeopoxa" class="logo">
<h1><strong>Apa itu Zeopoxa Running?</strong></h1>
<p><strong>Zeopoxa Running adalah aplikasi olahraga yang membantu pengguna melacak aktivitas lari mereka, termasuk jarak, kecepatan, dan kalori yang terbakar.</strong></p>
<p><strong>Pada website ini, Anda dapat mendeteksi atau mengecek kalimat atau kata yang ingin Anda ketik. Sistem akan mendeteksi apakah kalimat atau kata tersebut termasuk sentimen positif atau negatif.</strong></p>
<a href="deteksi_sentimen.php" class="scroll-btn">Masuk ke Halaman Deteksi Sentimen</a>
</div>
</section>
</body>
</html>

BIN
model/sentiment_model.pkl Normal file

Binary file not shown.

16
model_predict.py Normal file
View File

@ -0,0 +1,16 @@
import sys
import joblib
# Ambil input teks dari command line
input_text = sys.argv[1]
# Load model dan vectorizer dari file
data = joblib.load("model/sentiment_model.pkl")
nb_model = data["model"]
vectorizer = data["vectorizer"]
# Transformasi input dan prediksi
X_test = vectorizer.transform([input_text])
y_pred = nb_model.predict(X_test)
print(y_pred[0])

18
proses_sentimen.php Normal file
View File

@ -0,0 +1,18 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ulasan = $_POST['ulasan'];
$python = 'C:\Users\Farhan\AppData\Local\Programs\Python\Python313\\python.exe';
$command = escapeshellcmd("$python model_predict.py " . escapeshellarg($ulasan));
$output = shell_exec($command);
if ($output === null || trim($output) === "") {
echo "Gagal menjalankan model. Coba jalankan manual di CMD:<br><code>$command</code>";
exit;
}
header("Location: deteksi_sentimen.php?hasil=" . urlencode(trim($output)) . "&ulasan=" . urlencode($ulasan));
exit;
}
?>

BIN
sentiment_model.pkl Normal file

Binary file not shown.

149
style.css Normal file
View File

@ -0,0 +1,149 @@
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
scroll-behavior: smooth;
background-color: #f4f4f4;
}
.logo {
max-width: 200px;
margin-bottom: 1rem;
}
.landing {
min-height: 100vh;
background: linear-gradient(to right, #00c6ff, #0072ff);
display: flex;
justify-content: center;
align-items: center;
text-align: center;
padding: 4rem 2rem;
color: white;
}
.container {
max-width: 700px;
}
.scroll-btn {
display: inline-block;
margin-top: 2rem;
padding: 12px 24px;
background-color: #fff;
color: #0072ff;
text-decoration: none;
font-weight: bold;
border-radius: 8px;
transition: background-color 0.3s ease, color 0.3s ease;
}
.scroll-btn:hover {
background-color: #e0e0e0;
color: #0057cc;
}
.sentiment {
min-height: 100vh;
background: linear-gradient(to right, #00c6ff, #0072ff);
display: flex;
justify-content: center;
align-items: center;
padding: 3rem;
color: white;
}
.form-container {
background: white;
padding: 2rem 2.5rem;
border-radius: 15px;
color: black;
width: 100%;
max-width: 420px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
text-align: center;
}
.form-container h2 {
margin-bottom: 0.5rem;
font-size: 1.8rem;
}
.subtitle {
font-size: 0.95rem;
color: #666;
margin-bottom: 1.5rem;
}
input[type="text"] {
width: 100%;
padding: 12px;
margin-top: 1rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 7px;
font-size: 1rem;
}
button {
background-color: #2575fc;
color: white;
padding: 10px 25px;
border: none;
border-radius: 7px;
cursor: pointer;
font-weight: bold;
font-size: 1rem;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #1a5ed8;
}
.hasil-box {
margin-top: 1.5rem;
text-align: left;
}
.hasil-box label {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
}
.hasil-box input {
background-color: #f0f0f0;
border: 1px solid #ccc;
color: #333;
padding: 10px;
width: 100%;
border-radius: 7px;
font-size: 1rem;
}
.back-link {
display: inline-block;
margin-top: 1.5rem;
color: #2575fc;
text-decoration: none;
font-weight: bold;
transition: color 0.3s ease;
}
.back-link:hover {
color: #1a5ed8;
}
.hasil-text {
background-color: #f4f4f4;
padding: 12px 16px;
border-radius: 8px;
border: 1px solid #ccc;
font-size: 14px;
line-height: 1.6;
color: #333;
margin-top: 8px;
white-space: pre-wrap; /* agar baris baru tetap tampil */
word-wrap: break-word;
transition: all 0.3s ease;
}