Skip to content
Snippets Groups Projects
Commit 8a6551af authored by Michel, Jamie (UG - Computer Science)'s avatar Michel, Jamie (UG - Computer Science)
Browse files

Merge branch 'database' into 'master'

Database

See merge request !5
parents e90a915f 0101f8b7
No related branches found
No related tags found
1 merge request!5Database
......@@ -45,19 +45,38 @@ app.post('/predict', (req,res) => {
// Get the data to be stored
var plot = req.body.plot;
var prediction = JSON.parse(body).predictionText;
var prediction = JSON.parse(JSON.parse(body).predictionText);
// Get rcord to be inserted
var rec = {'Plot':plot, 'Prediction': prediction};
// Insert the record to the collection, throw error if insert unsuccessful
collection.insert(rec, {w:1}, function(err, result) {});
}, function(){
db.close();
});
res.render('predictions',{predictions:JSON.parse(JSON.parse(body).predictionText)})
});
})
console.log(req.body.plot)
// res.render('index', {});
});
app.get('/submissions', function (req, res) {
var resultArray = [];
MongoClient.connect(url, function(err, db) {
if(err) { return console.dir(err); }
var cursor = db.db('ClusterNLP').collection('Pred_Records').find();
cursor.forEach(function(doc, err){
resultArray.push(doc)
}, function(){
db.close();
res.render('submissions', {items: resultArray});
});
});
});
\ No newline at end of file
......@@ -71,7 +71,8 @@ fieldset {
-ms-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
color: black;
color: #444;
margin-top: 4%;
}
.ghost-button:hover {
border:2px solid #e95e01;
......@@ -86,7 +87,6 @@ p {
width: 100%;
height: 100%;
color: white;
display: grid;
background-size: 300% 300%;
/* background-image: linear-gradient(
-90deg,
......@@ -132,4 +132,67 @@ p {
border-color: #007299;
color: #007299;
box-shadow: none;
}
/* Add a black background color to the top navigation */
.topnav {
background-color: cornflowerblue;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
font-size: 1.3em;
text-decoration: none;
font-family: Calibri, 'Trebuchet MS', sans-serif;
font-weight: bold;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: #e95e01;
text-decoration: none;
}
/* Add a color to the active/current link */
.topnav a.active {
background-color: #e95e01;
color: white;
}
.title{
color: cornflowerblue;
font-size: 2.2em;
margin-top: 5%;
}
.subtitle{
color: #e95e01;
font-size: 1.2em;
}
table, th, td {
border: 1px solid black;
color: black;
}
td{
min-width: 10em;
font-family: Calibri, 'Trebuchet MS', sans-serif;
}
th{
color: #e95e01;
font-size: 1.2em;
}
.thead{
font-family: Calibri, 'Trebuchet MS', sans-serif;
color: cornflowerblue;
font-size: 2em;
}
\ No newline at end of file
......@@ -13,10 +13,14 @@
</head>
<div class="bg">
<div class="topnav">
<a class="active" href="/">NLP11</a>
<a href="/submissions">Submissions</a>
</div>
<body class="text-center" >
<div class="row">
<h1 style="color: cornflowerblue;">NLP Group 11: Predict movie genres by plot</h1>
<b style="color: #e95e01; font-size: large;">Enter a movie plot text to receive a prediction of the grenre(s)</b> <br>
<h1 class="title">NLP Group 11: Predict movie genres by plot</h1>
<b class="subtitle">Enter a movie plot text to receive a prediction of the grenre(s)</b> <br>
<!-- <h2>Enter plot text</h2> -->
<!-- <div>Any Address holding a balance of SIMP is able allow the backend to burn their tokens. <b>MAKE SURE METAMASK BROWSER EXTENSION IS CONNECTED TO THE WEBSITE (TOP RIGHT)</b></div> -->
......
......@@ -15,6 +15,10 @@
</head>
<div class="bg">
<div class="topnav">
<a href="/">NLP11</a>
<a href="/submissions">Submissions</a>
</div>
<body class="text-center" >
<div class="row">
<h1 style="color: cornflowerblue;">Predicted Genres</h1>
......
<!DOCTYPE html>
<html>
<head>
<title>NLP Demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<div class="bg">
<div class="topnav">
<a href="/">NLP11</a>
<a class="active" href="/submissions">Submissions</a>
</div>
<body>
<h1 class = "thead text-center">Movie Submissions and Predictions</h1>
<%- include("table", {items}); %>
</body>
</div>
</html>
<table class="table">
<tr>
<th>Prediction</th>
<th>Plot</th>
</tr>
<%if (items.length >0){ %>
<% items.forEach(function(row) { %>
<tr>
<td><%= row.Prediction %></td>
<td><%= row.Plot %></td>
</tr>
<% })}else{ %>
<tr>
<td colspan="6">No Record Found</td>
</tr>
<% } %>
</table>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment