Seat Create

parent d9ba51ef
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE 0"
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE 0";
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result25 = mysqli_query($con,$sql25) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result25 = mysqli_query($con,$sql25) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$sql2 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$sql2 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$sql2 = "DELETE FROM `best_seat` WHERE logUserid = $logUserid ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$startTime = mysqli_real_escape_string($con,$_POST['startTime']);
$endTime = mysqli_real_escape_string($con,$_POST['endTime']);
$sql1 = "UPDATE `user_details` SET `start`='$startTime',`end`='$endTime' WHERE `logUserid`='$logUserid'";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
if($result1){
echo 1;
} else {
echo 0;
}
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$startTime = mysqli_real_escape_string($con,$_POST['startTime']);
$endTime = mysqli_real_escape_string($con,$_POST['endTime']);
$sql1 = "UPDATE `user_details` SET `start`='$startTime',`end`='$endTime' WHERE `logUserid`='$logUserid'";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
if($result1){
echo 1;
} else {
echo 0;
}
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$startTime = mysqli_real_escape_string($con,$_POST['startTime']);
$endTime = mysqli_real_escape_string($con,$_POST['endTime']);
$sql1 = "UPDATE `user_details` SET `start`='$startTime',`end`='$endTime' WHERE `logUserid`='$logUserid'";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
if($result1){
echo 1;
} else {
echo 0;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
from flask import Flask
app = Flask(__name__)
import random
import json
import torch
from model import NeuralNet
from nltk_utils import bag_of_words, tokenize
@app.route('/<string:name>/')
def hello(name):
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
with open('intents.json', 'r') as json_data:
intents = json.load(json_data)
FILE = "data.pth"
data = torch.load(FILE)
input_size = data["input_size"]
hidden_size = data["hidden_size"]
output_size = data["output_size"]
all_words = data['all_words']
tags = data['tags']
model_state = data["model_state"]
model = NeuralNet(input_size, hidden_size, output_size).to(device)
model.load_state_dict(model_state)
model.eval()
bot_name = "TravellChatty"
while True:
# sentence = "do you use credit cards?"
sentence =name
if sentence == "quit":
break
sentence = tokenize(sentence)
X = bag_of_words(sentence, all_words)
X = X.reshape(1, X.shape[0])
X = torch.from_numpy(X).to(device)
output = model(X)
_, predicted = torch.max(output, dim=1)
tag = tags[predicted.item()]
probs = torch.softmax(output, dim=1)
prob = probs[0][predicted.item()]
if prob.item() > 0.75:
for intent in intents['intents']:
if tag == intent["tag"]:
return (f" {random.choice(intent['responses'])}")
#print(f"{bot_name}: {random.choice(intent['responses'])}")
else:
return (f" I do not understand...")
#print(f"{bot_name}: I do not understand...")
app.run()
import random
import json
import torch
from model import NeuralNet
from nltk_utils import bag_of_words, tokenize
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
with open('intents.json', 'r') as json_data:
intents = json.load(json_data)
FILE = "data.pth"
data = torch.load(FILE)
input_size = data["input_size"]
hidden_size = data["hidden_size"]
output_size = data["output_size"]
all_words = data['all_words']
tags = data['tags']
model_state = data["model_state"]
model = NeuralNet(input_size, hidden_size, output_size).to(device)
model.load_state_dict(model_state)
model.eval()
bot_name = "TravellChatty"
print("Let's chat! (type 'quit' to exit)")
while True:
# sentence = "do you use credit cards?"
sentence = input("You: ")
if sentence == "quit":
break
sentence = tokenize(sentence)
X = bag_of_words(sentence, all_words)
X = X.reshape(1, X.shape[0])
X = torch.from_numpy(X).to(device)
output = model(X)
_, predicted = torch.max(output, dim=1)
tag = tags[predicted.item()]
probs = torch.softmax(output, dim=1)
prob = probs[0][predicted.item()]
if prob.item() > 0.75:
for intent in intents['intents']:
if tag == intent["tag"]:
print(f"{bot_name}: {random.choice(intent['responses'])}")
else:
print(f"{bot_name}: I do not understand...")
<mxfile host="app.diagrams.net" modified="2021-07-05T06:13:17.469Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" etag="0eO2WcAi71hUnJJ3aWHb" version="14.8.4" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">7VhZc5swEP41PLbD4WLnsThxktbNJE3aTB9lkEG10FIhfPTXdzHCgPH4aOscnvjBo12vV9J+3x5gOP14filJEn2BgHLDNoO54Zwbtt1ze/idKxaFotM5KxShZEGhsirFPftNtdLU2owFNG0YKgCuWNJU+iAE9VVDR6SEWdNsDLy5a0JC2lLc+4S3tY8sUJG+lt2t9FeUhVG5s+Xq+8WkNNY3SSMSwKymci4Mpy8BVLGK533K89iVcXm8Xjzy4cS9/HSX/iLfvM8PN9/fFc4Gh/xldQVJhfq/ru3C9ZTwTMdL31UtygBKyERAcyem4XiRijkuLVz+pEotNOAkU4AqkCqCEAThQ4BE241BKG1m5TIVwcccWJRHHPxJoRowzvUeKGn7HkqpkjBZYZc7WAGRG3Myotwj/iRcHrQPHCT+JEDQ3FWAZNB3qQ53UWm9PWOrMUghkz7dYudoihMZ0m3+3MIuP1+Npxq5SwoxVXKBBpJyoti0SWaicyJc2VW440JDfwANnBYNrkWSKVTdZTRVDMQWWuSQzCKm6H1ClrGZYSFpUqVOAbylF3KSphrAHfgehs+USkXnWyNa/urqtNZ1zdHirCoSVpn5Ua1AdMwjYdBpYfAD6+ZbNv5LNrp7ZmPZrHamoyZLSYy9s1N7ugUmVM0ExuMUD7ZOndWGf8+mDy023UCLTLvxeNV0eyYydQ/jkvXiueS2uDQkcWLYLscweCOJqzBfJTwLQyQLuhOGM2jXrgjiUZbubhcNjHMGDUjMeB6vK8qnVDGfbGgqhLMQ9z33EW4qN5MHt2QiRMmtpIclWbH+HrHZdJvNZiXXu425odv0jtVtui1MbxG9Ajrb5Et8T6zjO/YaCGfP3fJ7+xTpV12Cn7zjl9V0d8u39izTmj3mewc/DQK9/CngbK+Z8m0MOA7D7FMbBMoT1vjkZXzUngRGmRTLQQDwIfJtEtgyCdibmtCTTgJlIayB+pUmhCGY5vAU54D1J//Osz/6l5WiCQHPY2qbRYadGAbrs5hjHQ8DFKuXtEUprN50Oxd/AA==</diagram></mxfile>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
import torch
import torch.nn as nn
class NeuralNet(nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
super(NeuralNet, self).__init__()
self.l1 = nn.Linear(input_size, hidden_size)
self.l2 = nn.Linear(hidden_size, hidden_size)
self.l3 = nn.Linear(hidden_size, num_classes)
self.relu = nn.ReLU()
def forward(self, x):
out = self.l1(x)
out = self.relu(out)
out = self.l2(out)
out = self.relu(out)
out = self.l3(out)
# no activation and no softmax at the end
return out
import numpy as np
import nltk
nltk.download('punkt')
from nltk.stem.porter import PorterStemmer
stemmer = PorterStemmer()
def tokenize(sentence):
"""
split sentence into array of words/tokens
a token can be a word or punctuation character, or number
"""
return nltk.word_tokenize(sentence)
def stem(word):
"""
stemming = find the root form of the word
examples:
words = ["organize", "organizes", "organizing"]
words = [stem(w) for w in words]
-> ["organ", "organ", "organ"]
"""
return stemmer.stem(word.lower())
def bag_of_words(tokenized_sentence, words):
"""
return bag of words array:
1 for each known word that exists in the sentence, 0 otherwise
example:
sentence = ["hello", "how", "are", "you"]
words = ["hi", "hello", "I", "you", "bye", "thank", "cool"]
bog = [ 0 , 1 , 0 , 1 , 0 , 0 , 0]
"""
# stem each word
sentence_words = [stem(word) for word in tokenized_sentence]
# initialize bag with 0 for each word
bag = np.zeros(len(words), dtype=np.float32)
for idx, w in enumerate(words):
if w in sentence_words:
bag[idx] = 1
return bag
import json
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
from nltk_utils import bag_of_words, tokenize, stem
from model import NeuralNet
with open('intents.json', 'r') as f:
intents = json.load(f)
all_words = []
tags = []
xy = []
for intent in intents['intents']:
tag = intent['tag']
# add to tag list
tags.append(tag)
for pattern in intent['patterns']:
# tokenize each word in the sentence
w = tokenize(pattern)
# add to our words list
all_words.extend(w)
# add to xy pair
xy.append((w, tag))
ignore_words = ['?', '.', '!']
all_words = [stem(w) for w in all_words if w not in ignore_words]
all_words = sorted(set(all_words))
tags = sorted(set(tags))
print(tags)
X_train = []
y_train = []
for (pattern_sentence, tag) in xy:
# X: bag of words for each pattern_sentence
bag = bag_of_words(pattern_sentence, all_words)
X_train.append(bag)
# y: PyTorch CrossEntropyLoss needs only class labels, not one-hot
label = tags.index(tag)
y_train.append(label)
X_train = np.array(X_train)
y_train = np.array(y_train)
class ChatDataset(Dataset):
def __init__(self):
self.n_samples = len(X_train)
self.x_data = X_train
self.y_data = y_train
# support indexing such that dataset[i] can be used to get i-th sample
def __getitem__(self, index):
return self.x_data[index], self.y_data[index]
# we can call len(dataset) to return the size
def __len__(self):
return self.n_samples
num_epochs = 1000
learning_rate = 0.001
batch_size = 8
input_size = len(X_train[0])
hidden_size = 8
output_size = len(tags)
print(input_size, output_size)
dataset = ChatDataset()
train_loader = DataLoader(dataset=dataset,
batch_size=batch_size,
shuffle=True,
num_workers=0)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = NeuralNet(input_size, hidden_size, output_size).to(device)
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
for epoch in range(num_epochs):
for (words, labels) in train_loader:
words = words.to(device)
labels = labels.to(dtype=torch.long).to(device)
# Forward pass
outputs = model(words)
# if y would be one-hot, we must apply
# labels = torch.max(labels, 1)[1]
loss = criterion(outputs, labels)
# Backward and optimize
optimizer.zero_grad()
loss.backward()
optimizer.step()
if (epoch+1) % 100 == 0:
print (f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}')
print(f'final loss: {loss.item():.4f}')
data = {
"model_state": model.state_dict(),
"input_size": input_size,
"hidden_size": hidden_size,
"output_size": output_size,
"all_words": all_words,
"tags": tags
}
FILE = "data.pth"
torch.save(data, FILE)
print(f'training complete. file saved to {FILE}')
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$sql1 = "DELETE FROM `select_seat_temp` WHERE logUserid = $logUserid ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$sql2 = "DELETE FROM `best_seat` WHERE logUserid = $logUserid ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
\ No newline at end of file
......@@ -131,6 +131,7 @@
// console.log(req.responseText);
document.getElementById(`collapseOne`).innerHTML = req.responseText;
changeLineName();
deleteSeatDetails(logUserid);
}
}
}
......@@ -140,6 +141,26 @@
}
}
function deleteSeatDetails(logUserid) {
var formData = new FormData();
formData.append('logUserid', logUserid);
var req = getXmlHttpRequestObject();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
// alert(req.responseText);
// console.log(req.responseText);
}
}
}
req.open("POST", 'sub_delete_all_seat_details.php', true);
req.send(formData);
}
}
function changeLineName(){
let logUserid = document.getElementById(`logUserid`).value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment