Commit 0940822a authored by Wanniarachchi M.Y's avatar Wanniarachchi M.Y

Merge branch 'Full' into 'master'

AUTOMATED ER DIAGRAM GENERATION, PLAGIARISM CHECK, AND AI-BASED QUIZ SYSTEM

See merge request !12
parents f55d0806 f518a56a
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import numpy as np
import pandas as pd
import tensorflow as tf
import re
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.neighbors import NearestNeighbors
from sklearn.metrics.pairwise import cosine_similarity
import keyboard
dataset = pd.read_csv('data/que_ans.csv')
dataset
dataset = dataset[['Question', 'Answer']]
dataset
def preprocess_text(text):
# Remove special characters and convert to lowercase
text = re.sub(r"[^a-zA-Z0-9]", " ", text).lower()
return text
# Apply preprocessing to the answer column
dataset['Answer'] = dataset['Answer'].apply(preprocess_text)
data = dataset
data
from keras.utils import pad_sequences
# Text tokenization
tokenizer = tf.keras.preprocessing.text.Tokenizer()
tokenizer.fit_on_texts(data['Answer'])
encoded_answer = tokenizer.texts_to_sequences(data['Answer'])
# Padding sequences
max_seq_length = max(len(seq) for seq in encoded_answer)
padded_answer = pad_sequences(encoded_answer, maxlen=max_seq_length, padding='post')
padded_answer
# Vectorize the existing answers
vectorizer = TfidfVectorizer()
answer_vectors = vectorizer.fit_transform(data['Answer'])
# Generate 20 random questions
random_indices = np.random.randint(0, len(data), size=2)
random_questions = data['Question'][random_indices]
random_answers = data['Answer'][random_indices]
correct_count = 0
incorrect_questions = []
for question, answer in zip(random_questions, random_answers):
print(answer)
print('Question:', question)
user_answer = ""
# Close answer palette when 'q' is pressed
while True:
if keyboard.is_pressed('q'):
break
elif keyboard.is_pressed('enter'):
user_answer = input("Enter your answer: ")
break
if not user_answer:
break
random_answer_vector = vectorizer.transform([answer])
new_answer_vector = vectorizer.transform([user_answer])
similarity_scores = cosine_similarity(random_answer_vector, new_answer_vector)
if similarity_scores >= 0.4:
print('Correct (Similarity Score:', similarity_scores, ')')
correct_count += 1
else:
print('Incorrect (Similarity Score:', similarity_scores, ')')
incorrect_questions.append(question)
print('Marks:', correct_count*20,"%\n\n")
#print('Incorrect Questions:\n\n', incorrect_questions)
incorrect_questions
topics_df = pd.read_csv('data/topics.csv')
topics = topics_df['topic']
topics
# Vectorize the user answer
topic_vector = vectorizer.fit_transform(topics_df['topic'])
# Use nearest neighbors to find the most similar answers
neigh = NearestNeighbors(n_neighbors=3, metric='cosine')
neigh.fit(topic_vector)
ranked_topics = []
for question in incorrect_questions:
question_vector = vectorizer.transform([question]) # Pass the question as a list
distances, indices = neigh.kneighbors(question_vector.reshape(1, -1)) # Reshape the question_vector
# Get the ranked answers
ranked_topic = topics_df['topic'].iloc[indices[0]]
ranked_topics.append(ranked_topic)
# Print the similar topics for the student to follow
print('You may consider exploring the following topics:\n')
for topic in ranked_topics:
print(topic)
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{"Event": ["e_id", "e_title", "e_date", "e_venue"], "Customer": ["c_id", "c_name", "c_contact_info", "c_ticket_history"], "Attendee": ["a_id", "a_event_id", "a_customer_id"], "Ticket": ["t_id", "t_price", "t_event_id", "t_capacity", "t_scanning"]}
\ No newline at end of file
["Event", "Customer", "Attendee", "Ticket"]
\ No newline at end of file
This diff is collapsed.
{"has": {"left": ["Event", "M"], "right": ["Attendee", "M"]}, "purchases": {"left": ["Customer", "M"], "right": ["Ticket", "M"]}, "attends": {"left": ["Attendee", "M"], "right": ["Event", "M"]}}
\ No newline at end of file
"CREATE TABLE Event (e_id VARCHAR(255), e_title VARCHAR(255), e_date VARCHAR(255), e_venue VARCHAR(255));\nCREATE TABLE Customer (c_id VARCHAR(255), c_name VARCHAR(255), c_contact_info VARCHAR(255), c_ticket_history VARCHAR(255));\nCREATE TABLE Attendee (a_id VARCHAR(255), a_event_id VARCHAR(255), a_customer_id VARCHAR(255));\nCREATE TABLE Ticket (t_id VARCHAR(255), t_price VARCHAR(255), t_event_id VARCHAR(255), t_capacity VARCHAR(255), t_scanning VARCHAR(255));\nALTER TABLE Event ADD CONSTRAINT FK_Event_Attendee FOREIGN KEY (event_id) REFERENCES Attendee(attendee_id);\nALTER TABLE Customer ADD CONSTRAINT FK_Customer_Ticket FOREIGN KEY (customer_id) REFERENCES Ticket(ticket_id);\nALTER TABLE Attendee ADD CONSTRAINT FK_Attendee_Event FOREIGN KEY (attendee_id) REFERENCES Event(event_id);"
\ No newline at end of file
,topic
0,Cloud Computing Security
1,Cloud Computing Data Storage
2,Cloud Computing Performance Optimization
3,Cloud Computing Cost Analysis
4,Cloud Computing Infrastructure Design
5,Cloud Computing Service Level Agreements
6,Cloud Computing Disaster Recovery
7,Cloud Computing Compliance
8,Cloud Computing Automation
9,Cloud Computing Scalability
10,Cybersecurity Risk Management
11,Cybersecurity Incident Response
12,Cybersecurity Auditing
13,Cybersecurity Compliance
14,Cybersecurity Threat Intelligence
15,Cybersecurity Vulnerability Management
16,Cybersecurity Network Security
17,Cybersecurity Application Security
18,Cybersecurity Data Protection
19,Cybersecurity Identity and Access Management
20,Data Science Modeling
21,Data Science Algorithms
22,Data Science Machine Learning
23,Data Science Natural Language Processing
24,Data Science Data Mining
25,Data Science Data Visualization
26,Data Science Predictive Analytics
27,Data Science Statistical Analysis
28,Data Science Big Data
29,Data Science Deep Learning
30,Data Analysis Techniques
31,Data Analysis Tools
32,Data Analysis Processes
33,Data Analysis Strategies
34,Data Analysis Best Practices
35,Data Analysis Methodologies
36,Data Analysis Techniques
37,Data Analysis Techniques
38,Data Analysis Techniques
39,Data Analysis Techniques
40,Artificial Intelligence Algorithms
41,Artificial Intelligence Applications
42,Artificial Intelligence Robotics
43,Artificial Intelligence Machine Learning
44,Artificial Intelligence Natural Language Processing
45,Artificial Intelligence Computer Vision
46,Artificial Intelligence Neural Networks
47,Artificial Intelligence Deep Learning
48,Artificial Intelligence Knowledge Representation
49,Artificial Intelligence Planning
50,Machine Learning Algorithms
51,Machine Learning Applications
52,Machine Learning Supervised Learning
53,Machine Learning Unsupervised Learning
54,Machine Learning Reinforcement Learning
55,Machine Learning Neural Networks
56,Machine Learning Deep Learning
57,Machine Learning Natural Language Processing
58,Machine Learning Computer Vision
59,Machine Learning Feature Engineering
60,Software Development Processes
61,Software Development Methodologies
62,Software Development Best Practices
63,Software Development Design Patterns
64,Software Development Testing
65,Software Development Automation
66,Software Development Security
67,Software Development Documentation
68,Software Development Maintenance
69,Software Development Optimization
70,Probability Distributions
71,Probability Theory
72,Probability Calculus
73,Probability Models
74,Probability Estimation
75,Probability Inference
76,Probability Sampling
77,Probability Simulation
78,Probability Hypothesis Testing
79,Probability Bayesian Analysis
80,Statistics Descriptive Analysis
81,Statistics Inferential Analysis
82,Statistics Regression Analysis
83,Statistics Correlation Analysis
84,Statistics Hypothesis Testing
85,Statistics Time Series Analysis
86,Statistics Survival Analysis
87,Statistics Multivariate Analysis
88,Statistics Nonparametric Analysis
89,Statistics Experimental Design
90,Web Development Front-End Development
91,Web Development Back-End Development
92,Web Development Database Development
93,Web Development User Interface Design
94,Web Development User Experience Design
95,Web Development Responsive Design
96,Web Development Cross-Browser Compatibility
97,Web Development Web Security
98,Web Development Performance Optimization
99,Web Development Content Management Systems
100,Supervised Learning Classification
101,Supervised Learning Regression
102,Supervised Learning Decision Trees
103,Supervised Learning Support Vector Machines
104,Supervised Learning Naive Bayes
105,Supervised Learning Neural Networks
106,Supervised Learning Ensemble Methods
107,Supervised Learning Feature Engineering
108,Supervised Learning Model Evaluation
109,Supervised Learning Hyperparameter Tuning
110,Unsupervised Learning Clustering
111,Unsupervised Learning Dimensionality Reduction
112,Unsupervised Learning Anomaly Detection
113,Unsupervised Learning Association Rules
114,Unsupervised Learning Neural Networks
115,Unsupervised Learning Feature Engineering
116,Unsupervised Learning Model Evaluation
117,Unsupervised Learning Hyperparameter Tuning
118,Unsupervised Learning Autoencoders
119,Unsupervised Learning Generative Adversarial Networks
120,Data Visualization Tools
121,Data Visualization Techniques
122,Data Visualization Best Practices
123,Data Visualization Dashboards
124,Data Visualization Storytelling
125,Data Visualization Design Principles
126,Data Visualization Data Mapping
127,Data Visualization Data Exploration
128,Data Visualization Data Analysis
129,Data Visualization Data Interpretation
This diff is collapsed.
File added
This diff is collapsed.
import cv2
import numpy as np
from spellchecker import SpellChecker
import json
from nltk.stem import SnowballStemmer
import keras_ocr
import matplotlib.pyplot as plt
pipeline = keras_ocr.pipeline.Pipeline()
stemmer = SnowballStemmer("english")
image_file = "data/ER_sim_images/2.jpg"
img = cv2.imread(image_file)
inverted_image = cv2.bitwise_not(img)
plt.imshow(inverted_image)
image_path = "temp/inverted_image1.jpg"
results_test = pipeline.recognize([image_path])
word_list=[]
for i in range(len(results_test[0])):
word_info=results_test[0][i][0]
word = word_info
word_list.append(word)
fig, ax = plt.subplots(figsize=(10, 10))
keras_ocr.tools.drawAnnotations(plt.imread(image_path), results_test[0], ax=ax)
ax.set_title('Extracted Result Example')
plt.show()
import cv2
from spellchecker import SpellChecker
import keras_ocr
pipeline = keras_ocr.pipeline.Pipeline()
spell = SpellChecker()
def extract_all_word(image_path):
inv_img_path = "temp/inverted_image1.jpg"
# Invert the images
inverted_image1 = cv2.bitwise_not(cv2.imread(image_path, cv2.IMREAD_GRAYSCALE))
cv2.imwrite(inv_img_path, inverted_image1)
results = pipeline.recognize([inv_img_path])
word_list = [word[0] for word in results[0]]
# Correct the recognized words
corrected_word_list = []
for word in word_list:
corrected_word = spell.correction(word)
corrected_word_list.append(corrected_word)
return word_list, corrected_word_list
words, corected_words = extract_all_word('static/er_diagram.png')
words
with open('data/entity_list.json', 'r') as json_file:
json_word_list = json.load(json_file)
json_word_list = [word.lower() for word in json_word_list]
pred_list = [word.lower() for word in words]
for word in json_word_list:
if word in pred_list:
print(f"'{word}'")
else:
print(f"'{word}' is not in the predicted list.")
pred_list
with open('data/entity_list.json', 'r') as json_file:
json_word_list = json.load(json_file)
json_word_list = [word.lower() for word in json_word_list]
# Convert to lowercase
pred_list = [word.lower() for word in words]
match_count = 0
for word in json_word_list:
if word in pred_list:
print("Matched Entity:", word)
match_count += 1 # Increment match_count
pred_list.remove(word)
total_words = len(json_word_list)
marks1 = match_count / total_words
print(f"Allocated Entity Marks: {marks1}")
with open('data/attributes.json', 'r') as json_file:
attributes_data = json.load(json_file)
match_count2 = 0
# Extract all attributes into a list
all_attributes = []
for entity, attributes in attributes_data.items():
for attribute in attributes:
# Split the attribute by underscores (_)
separated_attribute = attribute.split("_")[-1]
all_attributes.append(separated_attribute.lower())
all_attributes = [attr.lower() for attr in all_attributes]
for attribute in all_attributes:
if attribute in pred_list:
match_count2 = match_count2+1
print(f"Matched Attribute:'{attribute}'")
pred_list.remove(attribute)
else:
print(f"'{attribute}' is not matched.")
total_words = len(all_attributes)
marks2 = match_count2 / total_words
print(f"Allocated Attribute Marks: {marks2}")
pred_list
with open('data/relations.json', 'r') as json_file:
relationships_data = json.load(json_file)
# Extract the first word from the keys
selected_verbs = [stemmer.stem(key.split()[0]) for key in relationships_data.keys()]
print(selected_verbs)
stemmed_prediction_list = [stemmer.stem(word) for word in pred_list]
print(stemmed_prediction_list)
marks_count = 0
for word in stemmed_prediction_list:
if word in selected_verbs:
marks_count += 1
total_words = len(selected_verbs)
marks3 = marks_count / total_words
print(f"Allocated Relationship Marks: {marks3}")
final_marks = (marks1 + marks2 + marks3) / 3 * 10
rounded_final_marks = round(final_marks, 2)
print("Your have,", rounded_final_marks, "/10 for your ER diagram:")
import nltk
nltk.download('wordnet')
matplotlib==3.7.1
nltk==3.8.1
numpy==1.23.5
pandas==2.0.2
scikit-learn==1.2.2
seaborn==0.12.2
joblib==1.2.0
imutils==0.5.4
Flask==2.3.2
keras-ocr==0.8.9
openai==0.27.8
tensorflow==2.12.0
seaborn==0.12.2
wheel==0.40.0
spellchecker==0.4
yarl==1.9.2
\ No newline at end of file
import tensorflow as tf
from tensorflow.keras.applications import VGG16
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.vgg16 import preprocess_input
from sklearn.metrics.pairwise import cosine_similarity
import os
import matplotlib.pyplot as plt
import cv2
from matplotlib import pyplot as plt
import keras_ocr
import numpy as np
from spellchecker import SpellChecker
def perform_ocr_and_similarity(image_path1, image_path2):
# Read images from the input paths
img = cv2.imread(image_path1, cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread(image_path2, cv2.IMREAD_GRAYSCALE)
# Invert the first uploaded image
inverted_image = cv2.bitwise_not(img)
# Save the inverted image to a temporary folder
temp_folder = "temp"
os.makedirs(temp_folder, exist_ok=True)
cv2.imwrite(os.path.join(temp_folder, "inverted_image1.jpg"), inverted_image)
# Invert the second uploaded image
inverted_image2 = cv2.bitwise_not(img2)
# Save the second inverted image to the temporary folder
cv2.imwrite(os.path.join(temp_folder, "inverted_image2.jpg"), inverted_image2)
# Perform OCR on the inverted images
pipeline = keras_ocr.pipeline.Pipeline()
image_path_inverted1 = os.path.join(temp_folder, "inverted_image1.jpg")
image_path_inverted2 = os.path.join(temp_folder, "inverted_image2.jpg")
results1 = pipeline.recognize([image_path_inverted1])
word_list1 = [word[0] for word in results1[0]]
results2 = pipeline.recognize([image_path_inverted2])
word_list2 = [word[0] for word in results2[0]]
# Correct the recognized words
spell = SpellChecker()
corrected_word_list1 = [spell.correction(word) for word in word_list1]
corrected_word_list2 = [spell.correction(word) for word in word_list2]
# Calculate Jaccard similarity for predicted and corrected words
def jaccard_similarity(set1, set2):
intersection = len(set1.intersection(set2))
union = len(set1.union(set2))
return intersection / union if union != 0 else 0 # Avoid division by zero
similarity_predicted_word = jaccard_similarity(set(word_list1), set(word_list2))
similarity_corrected_word = jaccard_similarity(set(corrected_word_list1), set(corrected_word_list2))
# Calculate image similarity
def calculate_image_similarity(image_path1, image_path2):
vgg_model = VGG16(weights='imagenet', include_top=False)
def preprocess_image(image_path):
img = image.load_img(image_path, target_size=(224, 224))
img = image.img_to_array(img)
img = preprocess_input(img)
img = tf.expand_dims(img, axis=0)
return img
img1 = preprocess_image(image_path1)
img2 = preprocess_image(image_path2)
features1 = vgg_model.predict(img1)
features2 = vgg_model.predict(img2)
# Reshape the features to 1D arrays
features1 = features1.flatten()
features2 = features2.flatten()
# Calculate cosine similarity between the feature vectors
similarity_score = cosine_similarity([features1], [features2])[0][0]
return similarity_score
# Calculate final similarity scores
image_score = calculate_image_similarity(image_path_inverted1, image_path_inverted2)
final_score_predicted = (similarity_predicted_word + image_score) / 2
final_score_corrected = (similarity_corrected_word + image_score) / 2
return word_list1, corrected_word_list1, word_list2, corrected_word_list2, final_score_predicted, final_score_corrected
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Add the Bootstrap CSS link here -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Add Font Awesome CSS link here -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<style>
/* Additional CSS styles */
.navbar {
background-color: #333;
}
.navbar-nav .nav-link {
color: white;
}
.navbar-nav .nav-link:hover {
color: yellow;
}
.carousel-container {
background-color: #000; /* Set your desired background color */
overflow: hidden;
}
.carousel-item img {
width: 100%;
height: 100%;
object-fit: cover; /* Ensure the image covers the entire slide */
}
.carousel {
width: 100%; /* Set carousel width to 100% */
height: 100%;
}
</style>
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#">ER DIAGRAM TOOL</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
{% if user_role == 'student' %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('generate_er_diagram') }}"><i class="fas fa-database"></i> ER Diagram Generator</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('quiz') }}"><i class="fas fa-question-circle"></i> AI Based Quiz</a>
</li>
{% elif user_role == 'teacher' %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('generate_er_diagram') }}"><i class="fas fa-database"></i> ER Diagram Generator</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('extract') }}"><i class="fas fa-project-diagram"></i> ER Diagram Extractor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('similarity') }}"><i class="fas fa-search"></i> Similarity Checker</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('quiz_count') }}"><i class="fas fa-search"></i> Quiz count</a>
</li>
{% endif %}
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="{{ url_for('logout') }}"><i class="fas fa-sign-out-alt"></i> Logout {{user_role}}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('home') }}"><i class="fas fa-home"></i> Home</a>
</li>
</ul>
</div>
</nav>
<!-- Content Area -->
<!--<div class="container">-->
<div id="carouselExample" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="/static/diagram.webp" class="d-block w-100" alt="Slide 1">
</div>
<div class="carousel-item">
<img src="/static/diagram2.webp" class="d-block w-100" alt="Slide 2">
</div>
<div class="carousel-item">
<img src="/static/diagram3.webp" class="d-block w-100" alt="Slide 3">
</div>
<div class="carousel-item">
<img src="/static/diagram4.webp" class="d-block w-100" alt="Slide 4">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExample" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExample" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!--</div>-->
<!-- Bootstrap JS, Popper.js, and jQuery scripts -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Add the Bootstrap CSS link here -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Add Font Awesome CSS link here -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ER Diagram Generator</title>
<style>
/* Additional CSS styles */
/* Add your custom styles here */
</style>
</head>
<body>
<!-- Navigation Bar (if needed) -->
<!-- Content Area -->
<div class="container mt-4">
<h2>ER Diagram Generator</h2>
<form method="POST" action="{{ url_for('generate_er_diagram') }}">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.user_input.label(class="form-control-label") }}
{{ form.user_input(class="form-control") }}
</div>
<div class="row">
<div class="col-md-1">
<button type="submit" class="btn btn-primary custom-btn">Generate</button>
</div>
<div class="col-md-2">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary custom-btn">Back</a>
</div>
</div>
</form>
<!-- Display ER Diagram here -->
{% if er_diagram %}
<div class="mt-4">
<h3>Generated ER Diagram</h3>
<img src="{{ url_for('static', filename='er_diagram.png') }}" class="img-fluid" alt="ER Diagram">
<!-- Add a download button for the image -->
<a href="{{ url_for('static', filename='er_diagram.png') }}" download="er_diagram.png" class="btn btn-primary mt-2">
Download ER Diagram
</a>
</div>
{% endif %}
<!-- Display SQL Queries here -->
{% if sql_queries %}
<div class="mt-4">
<h3>Generated SQL Queries</h3>
<pre>{{ sql_queries }}</pre>
</div>
{% endif %}
</div>
<!-- Bootstrap JS scripts and other JS dependencies (if needed) -->
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ER Diagram Extraction</title>
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Styles -->
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f7f9;
}
header {
background-color: #343a40;
color: #ffffff;
padding: 1.5rem 0;
text-align: center;
margin-bottom: 2rem;
border-bottom: 3px solid #e7e7e7;
}
.container {
background-color: #fff;
border-radius: 8px;
padding: 2rem;
box-shadow: 0px 10px 25px rgba(0, 0, 0, 0.05);
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 2rem;
}
table, th, td {
border: 1px solid #e2e8f0;
}
th, td {
padding: 1rem;
text-align: left;
}
</style>
</head>
<body>
<header>
<h2>ER Diagram Extraction</h2>
</header>
<div class="container mt-4">
<form action="/extract" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="image"><strong>Upload ER Diagram:</strong></label>
<input type="file" name="image" class="form-control">
</div>
<div class="d-flex justify-content-between">
<button type="submit" class="btn btn-primary">Extract</button>
<a href="{{ url_for('dashboard') }}" class="btn btn-outline-secondary">Back</a>
</div>
</form>
{% if result %}
<h3 class="mt-5">Extraction Results</h3>
<table class="table table-bordered table-hover">
<thead class="bg-light">
<tr>
<th>Word</th>
<th>Corrected Word</th>
</tr>
</thead>
<tbody>
{% for i in range(result['words']|length) %}
<tr>
<td>{{ result['words'][i] }}</td>
<td>{{ result['corrected_words'][i] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h4>Matched Entities</h4>
<ul>
{% for entity in result['matched_entities'] %}
<li>{{ entity }}</li>
{% endfor %}
</ul>
<h4>Marks</h4>
<ul>
<li>Marks 1: {{ result['marks1'] }}</li>
<li>Marks 2: {{ result['marks2'] }}</li>
<li>Marks 3: {{ result['marks3'] }}</li>
<li>Final Marks: {{ result['final_marks'] }}</li>
</ul>
{% else %}
<p class="mt-4 text-muted">No results available. Please upload an ER Diagram to extract.</p>
{% endif %}
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Add the Bootstrap CSS link here -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ER Diagram Tool</title>
<style>
/* Additional CSS styles */
body, html {
height: 100%;
background: url('/static/back.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.card {
width: fit-content;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-body text-center">
<h1 class="card-title">WELCOME TO THE ER DIAGRAM TOOL</h1>
<p class="card-text">Please register or log in to use this tool.</p>
<a href="{{ url_for('login') }}" class="btn btn-primary btn-lg btn-block">Login</a>
<a href="{{ url_for('register') }}" class="btn btn-success btn-lg btn-block mt-3">Register</a>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Add the Bootstrap CSS link here -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<style>
body {
font-family: Arial, sans-serif;
background: url('/static/cover.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.card {
max-width: 400px;
width: 100%;
}
.card-body {
padding: 20px;
}
input[type="text"], input[type="password"] {
font-size: 16px;
}
</style>
</head>
<body>
<div class="card">
<div class="card-body text-center">
<h1 class="card-title">LOGIN PAGE</h1>
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.username(class="form-control", placeholder="Username") }}
</div>
<div class="form-group">
{{ form.password(class="form-control", placeholder="Password") }}
</div>
<button type="submit" class="btn btn-primary btn-block">Login</button>
</form>
<a href="{{ url_for('register') }}" class="mt-3">Don't have an account? Sign Up</a>
<div>
<a href="{{ url_for('home') }}">Back to Home</a>
</div>
</div>
</div>
</body>
</html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
{% block content %}
<div class="container mt-5">
{% if step == 'select_num_questions' %}
<div class="card">
<div class="card-body">
<h5 class="card-title">Quiz Selection</h5>
<form action="/quiz" method="post">
<div class="form-group">
<label for="num_questions">Select number of questions:</label>
<select class="form-control" name="num_questions" id="num_questions">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<button type="submit" class="btn btn-primary">Start Quiz</button></div>
<div class="col-md-6">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
</div>
</div>
</form>
</div>
</div>
{% elif step == 'answer' %}
<form action="/quiz" method="post">
<div class="card mb-4">
<div class="card-header bg-primary text-white">
Answer the Questions
</div>
<div class="card-body bg-light">
{% for question in questions %}
<div class="row mb-3">
<div class="col-md-8">
<label>{{ loop.index }}. {{ question }}</label>
</div>
<div class="col-md-4">
<input type="text" class="form-control" name="user_answer">
</div>
</div>
{% endfor %}
<div class="row">
<div class="col-md-1">
<button type="submit" class="btn btn-success">Submit</button>
</div>
<div class="col-md-2">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary custom-btn">Back</a>
</div>
</div>
</div>
</div>
</form>
{% elif step == 'results' %}
<h2>Results</h2>
<div class="alert alert-info" role="alert">
Final Score: {{ correct_count }} out of {{ questions|length }}
</div>
{% for answer, similarity in zip(user_answers, similarity_scores_list) %}
<div class="card mb-3">
<div class="card-body">
<p><strong>Your Answer:</strong> {{ answer }}</p>
<p><strong>Similarity Score:</strong> {{ similarity }}</p>
</div>
</div>
{% endfor %}
<div>
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
</div>
{% if recommended_topics %}
<h2 class="mt-5">Recommended Topics</h2>
<ul class="list-group">
{% for topic in recommended_topics[:3] %}
<li class="list-group-item">{{ topic }}</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
</div>
<div class="mt-5">
<br>
</div>
{% endblock %}
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quiz Count</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
.topic-item {
display: inline-block;
margin: 5px;
padding: 5px;
border: 1px solid #ccc;
cursor: pointer;
}
</style>
</head>
<body style="background-color: #f8f9fa;">
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-lg">
<div class="card-body">
<h5 class="card-title text-center text-primary">Quiz Configuration</h5>
<hr>
<form action="{{ url_for('quiz_count') }}" method="post">
<div class="form-group">
<label for="num_questions"><i class="fas fa-question-circle"></i> Number of Questions:</label>
<select class="form-control" name="num_questions" id="num_questions">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</div>
<div class="form-group">
<label for="topics"><i class="fas fa-book-open"></i> Topics:</label>
<select class="form-control" name="topics" id="topics" multiple size="8">
<!-- topics will be populated by JavaScript -->
</select>
</div>
<div class="selected-topics mb-3">
<!-- To display the selected topics -->
</div>
<button type="submit" class="btn btn-primary btn-block">Set Number of Quiz and Topics</button>
</form>
{% if message %}
<div class="alert alert-info mt-3">
{{ message }}
</div>
{% endif %}
<div class="text-center mt-3">
<a href="{{ url_for('dashboard') }}" class="btn btn-outline-secondary"><i class="fas fa-arrow-left"></i> Back to Home</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
// Initialize topics
const topics = [
"Cloud Computing", "Cybersecurity", "Data Science",
"Artificial Intelligence", "Machine Learning", "Software Development",
"Probability", "Statistics", "Web Development",
"Supervised Learning", "Unsupervised Learning", "Data Visualization"
];
// Populate dropdown with topics
topics.forEach(topic => {
$('#topics').append($('<option>', { value: topic, text: topic }));
});
// When a topic is selected from the dropdown
$('#topics').change(function() {
let selectedTopic = $(this).val();
if (selectedTopic) {
// Display it in the container
let topicElem = $("<span class='topic-item'>" + selectedTopic + "</span>");
$('.selected-topics').append(topicElem);
// Remove the selected topic from the dropdown
$(this).find('option:selected').remove();
}
});
// When a displayed topic is clicked
$(document).on('click', '.topic-item', function() {
let topic = $(this).text();
// Add the topic back to the dropdown
$('#topics').append($('<option>', { value: topic, text: topic }));
// Remove the topic from the displayed list
$(this).remove();
});
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Add the Bootstrap CSS link here -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register</title>
<style>
body {
font-family: Arial, sans-serif;
background: url('/static/cover.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.card {
max-width: 400px;
width: 100%;
}
.card-body {
padding: 20px;
}
input[type="text"], input[type="password"] {
font-size: 16px;
}
</style>
</head>
<body>
<div class="card">
<div class="card-body text-center">
<h1 class="card-title">REGISTER PAGE</h1>
<form method="POST" action="">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.username(class="form-control", placeholder="Username") }}
</div>
<div class="form-group">
{{ form.password(class="form-control", placeholder="Password") }}
</div>
<button type="submit" class="btn btn-success btn-block">Register</button>
</form>
<a href="{{ url_for('login') }}" class="mt-3">Already have an account? Log In</a>
<div>
<a href="{{ url_for('home') }}">Back to Home</a>
</div>
</div>
</div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Image Similarity Checker</title>
<!-- Bootstrap CSS Link -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
}
.container {
margin-top: 50px;
}
.result-box {
background-color: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
margin-top: 30px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="mb-4">Image Similarity Checker</h1>
<form action="/similarity" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="image1">Image 1:</label>
<input type="file" class="form-control" name="image1" accept="image/*" required>
</div>
<div class="form-group mb-3">
<label for="image2">Image 2:</label>
<input type="file" class="form-control" name="image2" accept="image/*" required>
</div>
<div class="row">
<div class="col-md-1">
<button type="submit" class="btn btn-primary">Check</button>
</div>
<div class="col-md-1">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Back</a>
</div>
</div>
</form>
<!-- Display the similarity result here -->
<div class="result-box mt-5">
<h2>Similarity Result</h2>
<p>{{ similarity_result }}</p>
<!-- Display detailed results -->
{% if detailed_results %}
<h2>Detailed Results</h2>
<p><strong>Predicted Word List 1:</strong> {{ detailed_results.word_list1 }}</p>
<p><strong>Corrected Word List 1:</strong> {{ detailed_results.corrected_word_list1 }}</p>
<p><strong>Predicted Word List 2:</strong> {{ detailed_results.word_list2 }}</p>
<p><strong>Corrected Word List 2:</strong> {{ detailed_results.corrected_word_list2 }}</p>
<p><strong>Final Predicted Similarity Score (predicted words):</strong> {{ detailed_results.pred }}</p>
<p><strong>Final Predicted Similarity Score (corrected words):</strong> {{ detailed_results.corr }}</p>
{% endif %}
</div>
<!-- Display preview images -->
{% if similarity_result %}
<div class="row mt-5">
<div class="col-md-6">
<h2>Image 1 Preview</h2>
<img src="/images/inverted_image1.jpg" class="img-fluid" alt="Image 1">
</div>
<div class="col-md-6">
<h2>Image 2 Preview</h2>
<img src="/images/inverted_image2.jpg" class="img-fluid" alt="Image 2">
</div>
</div>
{% endif %}
</div>
<!-- Bootstrap JS and Popper.js Scripts (placed at the end of the document for faster loading) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
id,username,password,role
1,student,student,student
2,teacher,teacher,teacher
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