diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..5031d40f29e721b817380fd7b51fffe7a0ab2265 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,37 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/data/Code_of_Civil_Procedure_faiss.index filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/data/Code_of_Criminal_Procedure_faiss.index filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/data/Constitution_of_Pakistan_faiss.index filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/data/Pakistan_Penal_Code_faiss.index filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/data/Rules_of_Business_faiss.index filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/RAG[[:space:]]books/code[[:space:]]of[[:space:]]civil[[:space:]]procedure_removed_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/RAG[[:space:]]books/code[[:space:]]of[[:space:]]criminal[[:space:]]procedure_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/RAG[[:space:]]books/constitution[[:space:]]of[[:space:]]pakistan_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/RAG[[:space:]]books/pakistan[[:space:]]penal[[:space:]]code_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/RAG[[:space:]]books/rules[[:space:]]of[[:space:]]business_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/ishaa.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/izza.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/justice.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/code[[:space:]]of[[:space:]]civil[[:space:]]procedure.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/code[[:space:]]of[[:space:]]criminal[[:space:]]procedure.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/constitution[[:space:]]of[[:space:]]pakistan.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/estacode.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/pakistan[[:space:]]penal[[:space:]]code.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/rules[[:space:]]of[[:space:]]business.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/lawbooks/Terms[[:space:]]and[[:space:]]Conditions.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/madiha.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/pic12.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/pic12.PNG filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/pic4.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/pic5.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/pic6.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/pic7.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/RAG/code[[:space:]]of[[:space:]]civil[[:space:]]procedure_removed_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/RAG/code[[:space:]]of[[:space:]]criminal[[:space:]]procedure_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/RAG/constitution[[:space:]]of[[:space:]]pakistan_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/RAG/pakistan[[:space:]]penal[[:space:]]code_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/RAG/rules[[:space:]]of[[:space:]]business_removed.pdf filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/supremecourt.jpg filter=lfs diff=lfs merge=lfs -text +FYP[[:space:]]RAG/summerization-app/static/supremecourtpic.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/FYP RAG/fiass.py b/FYP RAG/fiass.py new file mode 100644 index 0000000000000000000000000000000000000000..79fc227f7bc96e494cfa661aa9bb1d848a0bb936 --- /dev/null +++ b/FYP RAG/fiass.py @@ -0,0 +1,62 @@ +import os, re, pdfplumber, faiss, pickle +import numpy as np +from sentence_transformers import SentenceTransformer + +BOOKS = { + "Pakistan Penal Code": r"D:\FYP WEBSITE\summerization-app\RAG books\pakistan penal code_removed.pdf", + "Code of Criminal Procedure": r"D:\FYP WEBSITE\summerization-app\RAG books\code of criminal procedure_removed.pdf", + "Code of Civil Procedure": r"D:\FYP WEBSITE\summerization-app\RAG books\code of civil procedure_removed_removed.pdf", + "Constitution of Pakistan": r"D:\FYP WEBSITE\summerization-app\RAG books\constitution of pakistan_removed.pdf", + "Rules of Business": r"D:\FYP WEBSITE\summerization-app\RAG books\rules of business_removed.pdf" +} + +def extract_text_from_pdf(pdf_path): + if not os.path.exists(pdf_path): + return "" + try: + with pdfplumber.open(pdf_path) as pdf: + return "\n".join([page.extract_text() for page in pdf.pages if page.extract_text()]) + except: + return "" + +def clean_text(text): + text = re.sub(r'Page\s*\d+\s*of\s*\d+', '', text) + text = re.sub(r'\bPage\s*\d+\b', '', text) + text = re.sub(r'\b\d+\s*/\s*\d+\b', '', text) + return text.strip() + +def split_sections_by_number(text): + pattern = r"(\d+[A-Z]?(?:\(\d+\))?)\.\s*(.*?)(?=\n\d+[A-Z]?(?:\(\d+\))?\.)" + return [{"section_id": s[0].strip(), "content": s[1].strip()} for s in re.findall(pattern, text, re.DOTALL)] + +def create_faiss_index(structured_data, model): + corpus = [section['content'] for section in structured_data] + corpus_embeddings = model.encode(corpus, show_progress_bar=True) + dim = corpus_embeddings.shape[1] + index = faiss.IndexFlatL2(dim) + index.add(np.array(corpus_embeddings)) + return index + +if __name__ == "__main__": + model = SentenceTransformer('all-MiniLM-L6-v2') + + all_data = {} + all_indices = {} + + for name, path in BOOKS.items(): + print(f"Processing {name}...") + text = extract_text_from_pdf(path) + clean = clean_text(text) + sections = split_sections_by_number(clean) + index = create_faiss_index(sections, model) + + all_data[name] = sections + all_indices[name] = index + + with open("data/legal_data.pkl", "wb") as f: + pickle.dump(all_data, f) + + for name, index in all_indices.items(): + faiss.write_index(index, f"data/{name.replace(' ', '_')}_faiss.index") + + print("All data processed and saved.") diff --git a/FYP RAG/summerization-app/.gitignore b/FYP RAG/summerization-app/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5a3590cf1d40937079a7a053d629fccb03e4f6bf --- /dev/null +++ b/FYP RAG/summerization-app/.gitignore @@ -0,0 +1 @@ +.vercel diff --git a/FYP RAG/summerization-app/RAG books/code of civil procedure_removed_removed.pdf b/FYP RAG/summerization-app/RAG books/code of civil procedure_removed_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..09df1c9c8e03641ed7c4101fce8606b89632aa8f --- /dev/null +++ b/FYP RAG/summerization-app/RAG books/code of civil procedure_removed_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f7c9659890cc63b515472d36bb840d957dfac8f97c6bd320293755988b36cee +size 431953 diff --git a/FYP RAG/summerization-app/RAG books/code of criminal procedure_removed.pdf b/FYP RAG/summerization-app/RAG books/code of criminal procedure_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7569d83cc1b424f8080afc3dfae601227fa23087 --- /dev/null +++ b/FYP RAG/summerization-app/RAG books/code of criminal procedure_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b97dcf84b0e493c2f535db8cdaea4e23cf86de7d4e3960c6cdd1e9b8a6b9aba7 +size 2240716 diff --git a/FYP RAG/summerization-app/RAG books/constitution of pakistan_removed.pdf b/FYP RAG/summerization-app/RAG books/constitution of pakistan_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4919e8c1abc1c072e20fcec43b6fb628c71d98ca --- /dev/null +++ b/FYP RAG/summerization-app/RAG books/constitution of pakistan_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c5e74adfbac47286ff0f37c00c0929010808aa52c973b6ebeeb11f9245a4a6e +size 1282779 diff --git a/FYP RAG/summerization-app/RAG books/pakistan penal code_removed.pdf b/FYP RAG/summerization-app/RAG books/pakistan penal code_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0d744f3066bd6eaa9cc6178413d583188146e08f --- /dev/null +++ b/FYP RAG/summerization-app/RAG books/pakistan penal code_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5853cd7784c6b7658bb7c16907473711355b93953d8676b5e22ec2812da63ecc +size 1327711 diff --git a/FYP RAG/summerization-app/RAG books/rules of business_removed.pdf b/FYP RAG/summerization-app/RAG books/rules of business_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..017e618d3870cf2088cc829c338a07d3dc667eca --- /dev/null +++ b/FYP RAG/summerization-app/RAG books/rules of business_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de15d2ad87f1b79e0f8b3c6d2982b40f845616004223f8598bcd353c038ffd31 +size 737204 diff --git a/FYP RAG/summerization-app/data/Code_of_Civil_Procedure_faiss.index b/FYP RAG/summerization-app/data/Code_of_Civil_Procedure_faiss.index new file mode 100644 index 0000000000000000000000000000000000000000..2fe7380605f013b04e5c04c8e6c015599a68f560 --- /dev/null +++ b/FYP RAG/summerization-app/data/Code_of_Civil_Procedure_faiss.index @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:630c8eb40566666fa57f31c6088954f931d15e35d114b79cb7eb86f4d263a5f1 +size 231981 diff --git a/FYP RAG/summerization-app/data/Code_of_Criminal_Procedure_faiss.index b/FYP RAG/summerization-app/data/Code_of_Criminal_Procedure_faiss.index new file mode 100644 index 0000000000000000000000000000000000000000..a5b7d345a5ea137099930809a8da18de9231bb37 --- /dev/null +++ b/FYP RAG/summerization-app/data/Code_of_Criminal_Procedure_faiss.index @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2518b77995275ff2173ba75efabb02cabbe889c8e76cce15faa8cd23132313da +size 698925 diff --git a/FYP RAG/summerization-app/data/Constitution_of_Pakistan_faiss.index b/FYP RAG/summerization-app/data/Constitution_of_Pakistan_faiss.index new file mode 100644 index 0000000000000000000000000000000000000000..b4bde6e80451ef9934506d8d56a06e4073a99fae --- /dev/null +++ b/FYP RAG/summerization-app/data/Constitution_of_Pakistan_faiss.index @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4062b7de67cd6bec6029d61a43e2865a5aad757e3bd2eb7a3dffa06cf49ffe37 +size 1107501 diff --git a/FYP RAG/summerization-app/data/Pakistan_Penal_Code_faiss.index b/FYP RAG/summerization-app/data/Pakistan_Penal_Code_faiss.index new file mode 100644 index 0000000000000000000000000000000000000000..2ff6686eb75bc6522ac1a96919173d70424b9420 --- /dev/null +++ b/FYP RAG/summerization-app/data/Pakistan_Penal_Code_faiss.index @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb67ace1971ef6306cf9ba5bd08c178d1d9fc196a188f9251e7a356a2df42987 +size 893997 diff --git a/FYP RAG/summerization-app/data/Rules_of_Business_faiss.index b/FYP RAG/summerization-app/data/Rules_of_Business_faiss.index new file mode 100644 index 0000000000000000000000000000000000000000..0b4d08e8ad8532004cf940135ec44e53b3a630bc --- /dev/null +++ b/FYP RAG/summerization-app/data/Rules_of_Business_faiss.index @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecda948e01946ca87c890ad8d083f46a8aacb57e8cfd4704fedd11dcaa43ff1e +size 1646637 diff --git a/FYP RAG/summerization-app/data/legal_data.pkl b/FYP RAG/summerization-app/data/legal_data.pkl new file mode 100644 index 0000000000000000000000000000000000000000..a9b7dcc193e95dc634c43203b6d93d7dc64d0757 --- /dev/null +++ b/FYP RAG/summerization-app/data/legal_data.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a41c36199ac4666e1b89fe3230e18b0ff626bf6284f41fcdeceb9fc01ca5c32c +size 1916889 diff --git a/FYP RAG/summerization-app/requirements.txt b/FYP RAG/summerization-app/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6015a8877151aa556d403d6893bf67d2ec2d118 Binary files /dev/null and b/FYP RAG/summerization-app/requirements.txt differ diff --git a/FYP RAG/summerization-app/server.py b/FYP RAG/summerization-app/server.py new file mode 100644 index 0000000000000000000000000000000000000000..a92f4c236f104cbdf92fcd3b7a25a7423f00be70 --- /dev/null +++ b/FYP RAG/summerization-app/server.py @@ -0,0 +1,446 @@ +from flask import Flask, render_template, request, send_file,abort,send_from_directory +import torch +from werkzeug.security import generate_password_hash, check_password_hash +from flask import Flask, render_template, request, redirect, url_for, jsonify, session + +from flask import Flask, request, jsonify +from pymongo import MongoClient +import pickle +from pymongo import MongoClient +from transformers import AutoTokenizer, AutoModelForSeq2SeqLM +from PyPDF2 import PdfReader +from docx import Document +import re +import seaborn as sns +import matplotlib.pyplot as plt +import os +import string +import requests +from bs4 import BeautifulSoup +from flask import jsonify +from flask import Flask, render_template, request, jsonify +from sentence_transformers import SentenceTransformer +import faiss +import fitz +import groq +import PyPDF2 +import numpy as np +from flask import Flask, render_template, request, redirect, url_for, flash, session +from flask_argon2 import Argon2 +from pymongo import MongoClient +import os +import pdfplumber +from groq import Groq +import logging +logging.getLogger("pdfminer").setLevel(logging.ERROR) + + + +app = Flask(__name__) + +GROQ_API_KEY = "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" +cli = Groq(api_key=GROQ_API_KEY) + +# Load embedding model globally +embedding_model = SentenceTransformer('all-MiniLM-L6-v2') + +# Load preprocessed data +with open("D:\FYP WEBSITE\summerization-app\data\legal_data.pkl", "rb") as f: + legal_data = pickle.load(f) + +# Load FAISS indices +faiss_indices = {} +for law in legal_data: + try: + index_path = f"data/{law.replace(' ', '_')}_faiss.index" + index = faiss.read_index(index_path) + faiss_indices[law] = (index, legal_data[law]) + except Exception as e: + print(f"Error loading FAISS index for {law}: {str(e)}") + +# Helper to match section +def get_exact_section(section_number, structured_data): + for section in structured_data: + if section["section_id"].strip() == section_number.strip(): + return section + return None + +# Helper to find relevant section via similarity +def find_relevant_section(query, model, index, structured_data, top_k=3): + query_embedding = model.encode([query]) + distances, indices = index.search(np.array(query_embedding), top_k) + return [structured_data[i] for i in indices[0] if i < len(structured_data)] + +# Generate answer using Groq +def generate_response_with_groq(prompt, section_number, book_name, context): + full_prompt = f"According to Section {section_number} of {book_name}, {prompt}" + try: + response = cli.chat.completions.create( + model="llama3-8b-8192", + messages=[ + { + "role": "system", + "content": "You are a legal assistant providing detailed and comprehensive legal explanations based on Pakistani law. Always provide at least 5-6 sentences per response." + }, + { + "role": "user", + "content": f"{full_prompt}\n\nContext: {context}" + } + ], + max_tokens=1000 + ) + return response.choices[0].message.content.strip() + except Exception as e: + print(f"Error with Groq API: {str(e)}") + return "Error communicating with Groq API." + + + +# Main route +@app.route('/ask', methods=['POST']) +def ask(): + try: + # Ensure the request is JSON + if not request.is_json: + return jsonify({'response': 'Request must be JSON'}), 400 + + data = request.get_json() + query = data.get('query', '').strip() + + if not query: + return jsonify({'response': 'Please enter a valid question.'}), 400 + + # Extract section number and book name using regex + pattern = r"what\s+is\s+section\s+no\.?\s*(\d+[A-Z]?(?:\(\d+\))?)\s+of\s+(.*)" + match = re.search(pattern, query, re.IGNORECASE) + + if match: + section_number = match.group(1).strip() + book_name = match.group(2).strip() + + matched_book = None + for law in legal_data: + if book_name.lower() in law.lower(): + matched_book = law + break + + if not matched_book: + return jsonify({'response': 'Book name not recognized. Please try again with a valid book name.'}), 404 + + index, structured_data = faiss_indices.get(matched_book, (None, None)) + if index is None or structured_data is None: + return jsonify({'response': 'Error loading FAISS index for the selected law.'}), 500 + + exact_section = get_exact_section(section_number, structured_data) + if exact_section: + response = generate_response_with_groq(query, section_number, matched_book, exact_section['content']) + return jsonify({'response': response}), 200 + else: + relevant = find_relevant_section(query, embedding_model, index, structured_data) + if relevant: + response = generate_response_with_groq(query, relevant[0]['section_id'], matched_book, relevant[0]['content']) + return jsonify({'response': response}), 200 + else: + return jsonify({'response': 'No relevant section found.'}), 404 + else: + return jsonify({'response': 'Please ask your question in this format: "What is Section No. 302 of Pakistan Penal Code?"'}), 400 + + except Exception as e: + print(f"Server error at /ask: {str(e)}") + return jsonify({'response': 'An internal error occurred. Please try again later.'}), 500 + + + +# Flask route + + +# Load the fine-tuned Legal LED model +MODEL_NAME = "Izza-shahzad-13/legal-LED-final" +tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) +model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME) + +# Function to generate summary +def generate_summary(text): + inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=1024, truncation=True) + outputs = model.generate(inputs, max_length=800, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True) + return tokenizer.decode(outputs[0], skip_special_tokens=True) + +# Function to calculate sentence importance scores +def calculate_sentence_importance(summary): + sentences = summary.split(". ") + scores = [len(sentence) for sentence in sentences] # Score based on sentence length + max_score = max(scores) if scores else 1 + normalized_scores = [score / max_score for score in scores] + return sentences, normalized_scores + +# Function to generate heatmap +def generate_heatmap(scores): + plt.figure(figsize=(10, 2)) + sns.heatmap([scores], annot=True, cmap="coolwarm", xticklabels=False, yticklabels=False, cbar=True) + plt.title("Sentence Importance Heatmap") + plt.savefig("static/heatmap.png") # Save heatmap image + plt.close() + +# Function to highlight sentences in the summary +def highlight_summary(sentences, scores): + cmap = sns.color_palette("coolwarm", as_cmap=True) + highlighted_summary = "" + + for sentence, score in zip(sentences, scores): + color = cmap(score) + rgb_color = f"rgb({int(color[0]*255)}, {int(color[1]*255)}, {int(color[2]*255)})" + highlighted_summary += f'{sentence}. ' + + return highlighted_summary + +# Function to highlight legal terms +def highlight_keywords(text): + patterns = { + 'act_with_year': r'\b([A-Za-z\s]+(?:\sAct(?:\s[\d]{4})?))\s*,\s*(\d{4})\b', + 'article': r'\bArticle\s\d{1,3}(-[A-Z])?\b', + 'section': r'\bSection\s\d{1,3}[-A-Za-z]?\(?[a-zA-Z]?\)?\b', + 'date': r'\b(?:[A-Za-z]+)\s\d{4}\b|\b\d{1,2}[-/]\d{1,2}[-/]\d{2,4}\b', + 'persons': r'\b([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\b', + 'ordinance': r'\b([A-Z][a-z\s]+Ordinance(?:,\s\d{4})?)\b', # Example: PEMRA Ordinance, 2002 + 'petition': r'\b(?:[A-Za-z\s]*Petition\sNo\.\s\d+/\d{4})\b', # Example: Constitutional Petition No. 123/2024 + 'act_with_year': r'\b([A-Za-z\s]+(?:\sAct(?:\s\d{4})?)),\s*(\d{4})\b', # Example: Control of Narcotic Substances Act, 1997 + 'article': r'\b(Article\s\d{1,3}(-[A-Z])?)\b', # Example: Article 10-A + 'section': r'\b(Section\s\d{1,3}(\([a-zA-Z0-9]+\))?)\b', # Example: Section 302(b), Section 9(c), Section 144-A + 'date': r'\b(?:\d{1,2}[-/]\d{1,2}[-/]\d{2,4}|\d{4}|\b(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2},?\s\d{4})\b', + # Examples: 15/07/2015, July 2015, March 5, 2021, 2023 + 'person': r'\b([A-Z][a-z]+(?:\s[A-Z][a-z]+)+)\b' # Example: Justice Ali Raza + + } + + highlighted_text = text + for pattern in patterns.values(): + highlighted_text = re.sub(pattern, lambda match: f'{match.group(0)}', highlighted_text) + + return highlighted_text + +# Function to read uploaded files +def read_file(file): + if file.filename.endswith(".txt"): + return file.read().decode("utf-8") + elif file.filename.endswith(".pdf"): + pdf_reader = PdfReader(file) + return " ".join(page.extract_text() for page in pdf_reader.pages) + elif file.filename.endswith(".docx"): + doc = Document(file) + return " ".join(paragraph.text for paragraph in doc.paragraphs) + return None + +# Function to fetch text from a URL +def fetch_text_from_url(url): + try: + response = requests.get(url) + response.raise_for_status() + + # Check content type + content_type = response.headers.get("Content-Type", "") + if "text/html" in content_type: # If it's a webpage + soup = BeautifulSoup(response.text, "html.parser") + paragraphs = soup.find_all("p") # Extract paragraph text + return " ".join([p.get_text() for p in paragraphs]) + + elif "text/plain" in content_type: # If it's a plain text file + return response.text + + else: + return None + except Exception as e: + print("Error fetching URL:", e) + return None + +@app.route("/", methods=["GET", "POST"]) +def index(): + document_text = None + summary = None + heatmap_url = None + + if request.method == "POST": + file = request.files.get("file") + pasted_text = request.form.get("pasteText", "").strip() + url = request.form.get("url", "").strip() + + if file and file.filename: + document_text = read_file(file) + elif pasted_text: + document_text = pasted_text + elif url: + document_text = fetch_text_from_url(url) + + if document_text: + summary = generate_summary(document_text) + sentences, scores = calculate_sentence_importance(summary) + + generate_heatmap(scores) + + highlighted_summary = highlight_summary(sentences, scores) + highlighted_summary = highlight_keywords(highlighted_summary) + + # Save the summary to a text file + with open("summary.txt", "w", encoding="utf-8") as f: + f.write(summary) + + return render_template("mainscreen.html", document_text=document_text, summary=highlighted_summary, heatmap_url="static/heatmap.png") + + return render_template("mainscreen.html", document_text=None, summary=None, heatmap_url=None) + +@app.route("/download_summary") +def download_summary(): + file_path = os.path.join(os.getcwd(), "summary.txt") + + if not os.path.exists(file_path): + return abort(404, description="File not found") + + return send_file(file_path, as_attachment=True, download_name="summary.txt", mimetype="text/plain") + + + # Homepage +@app.route("/home") +def home(): + return render_template("homepage.html") +@app.route("/about") +def about(): + return render_template("aboutpage.html") +@app.route("/summarization") +def summarization(): + return render_template("mainscreen.html") # Login Page + + +@app.route('/lawbooks/') +def serve_pdf(filename): + return send_from_directory('static/lawbooks', filename) + + + + +# MongoDB connection +client = MongoClient('mongodb+srv://law:X1PNiOZtTdyIIO0m@law.urpdise.mongodb.net/?retryWrites=true&w=majority&appName=law') +db = client['chatbotDB'] +users = db['users'] + + + +@app.route('/signup', methods=['GET']) +def signup(): + return render_template('signuppage.html') # Render the HTML form + +@app.route('/api/signup', methods=['POST']) +def api_signup(): + # Get JSON data from the request + data = request.get_json() + first_name = data.get('firstName') + last_name = data.get('lastName') + email = data.get('email') + password = data.get('password') + + # Hash the password for security before storing it in the database + hashed_pw = generate_password_hash(password) + + # Check if the user already exists + if users.find_one({'email': email}): + return jsonify({'message': 'Email already exists!'}), 400 + + # Insert the user data into MongoDB + users.insert_one({ + 'first_name': first_name, + 'last_name': last_name, + 'email': email, + 'password': hashed_pw + }) + + # Return a success response + return jsonify({'message': 'Signup successful!'}), 201 + +# Success page or login page +@app.route('/login', methods=['GET', 'POST']) +def login(): + if request.method == 'POST': + # Handle POST request for login + data = request.get_json() + email = data.get('email') + password = data.get('password') + + # Log login attempt + print(f"Login attempt - Email: {email}") + + # Check if the user exists + user = users.find_one({'email': email}) + if not user: + print(f"Login failed - Email '{email}' not found.") + return jsonify({'message': 'Invalid email or password!'}), 401 + + # Check if the password is correct (compare hashed passwords) + if not check_password_hash(user['password'], password): + print(f"Login failed - Incorrect password for email '{email}'.") + return jsonify({'message': 'Invalid email or password!'}), 401 + + # Log successful login + print(f"Login successful - Email: {email}") + return jsonify({'message': 'Login successful!'}), 200 + + # Handle GET request - Show login form (if needed) + return render_template('loginpage.html') # This would be the login form page (replace with your template) + + +@app.route('/reset-password', methods=['GET', 'POST']) +def reset_password(): + if request.method == 'POST': + email = request.form['email'] + new_password = request.form['newPassword'] + confirm_password = request.form['confirmPassword'] + + # Check if passwords match + if new_password != confirm_password: + return jsonify({'message': 'Passwords do not match!'}), 400 + + # Check if user exists + user = users.find_one({'email': email}) + if not user: + return jsonify({'message': 'User not found!'}), 404 + + # Hash the new password + hashed_pw = generate_password_hash(new_password) + + # Update the user's password in the database + users.update_one({'email': email}, {'$set': {'password': hashed_pw}}) + return jsonify({'message': 'Password updated successfully!'}), 200 + + return render_template('forgetpasswordpage.html') + + +contacts_collection = db["contacts"] +@app.route('/contact', methods=['GET', 'POST']) +def contact(): + if request.method == 'POST': + name = request.form.get('name') + email = request.form.get('email') + message = request.form.get('message') + + print(f"Name: {name}, Email: {email}, Message: {message}") # Debug + + if not name or not email or not message: + return jsonify({'message': 'All fields are required!'}), 400 + + contact_data = { + 'name': name, + 'email': email, + 'message': message + } + + contacts_collection.insert_one(contact_data) + return jsonify({'message': f'Thank you, {name}! Your message has been sent successfully.', + 'status': 'success'}), 200 + + return render_template('contactpage.html') + + + + + + + +if __name__ == '__main__': + app.run(debug=True) diff --git a/FYP RAG/summerization-app/static/RAG/chatbot code.docx b/FYP RAG/summerization-app/static/RAG/chatbot code.docx new file mode 100644 index 0000000000000000000000000000000000000000..d4ed09052c6ed66dc95bdea4ee1ed967fd7551d3 Binary files /dev/null and b/FYP RAG/summerization-app/static/RAG/chatbot code.docx differ diff --git a/FYP RAG/summerization-app/static/RAG/code of civil procedure_removed_removed.pdf b/FYP RAG/summerization-app/static/RAG/code of civil procedure_removed_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..09df1c9c8e03641ed7c4101fce8606b89632aa8f --- /dev/null +++ b/FYP RAG/summerization-app/static/RAG/code of civil procedure_removed_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f7c9659890cc63b515472d36bb840d957dfac8f97c6bd320293755988b36cee +size 431953 diff --git a/FYP RAG/summerization-app/static/RAG/code of criminal procedure_removed.pdf b/FYP RAG/summerization-app/static/RAG/code of criminal procedure_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7569d83cc1b424f8080afc3dfae601227fa23087 --- /dev/null +++ b/FYP RAG/summerization-app/static/RAG/code of criminal procedure_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b97dcf84b0e493c2f535db8cdaea4e23cf86de7d4e3960c6cdd1e9b8a6b9aba7 +size 2240716 diff --git a/FYP RAG/summerization-app/static/RAG/constitution of pakistan_removed.pdf b/FYP RAG/summerization-app/static/RAG/constitution of pakistan_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4919e8c1abc1c072e20fcec43b6fb628c71d98ca --- /dev/null +++ b/FYP RAG/summerization-app/static/RAG/constitution of pakistan_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c5e74adfbac47286ff0f37c00c0929010808aa52c973b6ebeeb11f9245a4a6e +size 1282779 diff --git a/FYP RAG/summerization-app/static/RAG/pakistan penal code_removed.pdf b/FYP RAG/summerization-app/static/RAG/pakistan penal code_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0d744f3066bd6eaa9cc6178413d583188146e08f --- /dev/null +++ b/FYP RAG/summerization-app/static/RAG/pakistan penal code_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5853cd7784c6b7658bb7c16907473711355b93953d8676b5e22ec2812da63ecc +size 1327711 diff --git a/FYP RAG/summerization-app/static/RAG/rules of business_removed.pdf b/FYP RAG/summerization-app/static/RAG/rules of business_removed.pdf new file mode 100644 index 0000000000000000000000000000000000000000..017e618d3870cf2088cc829c338a07d3dc667eca --- /dev/null +++ b/FYP RAG/summerization-app/static/RAG/rules of business_removed.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de15d2ad87f1b79e0f8b3c6d2982b40f845616004223f8598bcd353c038ffd31 +size 737204 diff --git a/FYP RAG/summerization-app/static/bookmark.png b/FYP RAG/summerization-app/static/bookmark.png new file mode 100644 index 0000000000000000000000000000000000000000..1203f2115d81b319a067c827ee452804e04fc91c Binary files /dev/null and b/FYP RAG/summerization-app/static/bookmark.png differ diff --git a/FYP RAG/summerization-app/static/chatboticon.png b/FYP RAG/summerization-app/static/chatboticon.png new file mode 100644 index 0000000000000000000000000000000000000000..b8ce050e2a428d243ea4f526ced7aca56f91c9c0 Binary files /dev/null and b/FYP RAG/summerization-app/static/chatboticon.png differ diff --git a/FYP RAG/summerization-app/static/cloud.png b/FYP RAG/summerization-app/static/cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..b1ea695b7c407642a4a45f0d4cdf8580b25b6204 Binary files /dev/null and b/FYP RAG/summerization-app/static/cloud.png differ diff --git a/FYP RAG/summerization-app/static/criminal-law.png b/FYP RAG/summerization-app/static/criminal-law.png new file mode 100644 index 0000000000000000000000000000000000000000..864dc842600d8a464db74591d774849393f775c5 Binary files /dev/null and b/FYP RAG/summerization-app/static/criminal-law.png differ diff --git a/FYP RAG/summerization-app/static/facebook-brands.svg b/FYP RAG/summerization-app/static/facebook-brands.svg new file mode 100644 index 0000000000000000000000000000000000000000..8366e4ae546e3e055767d836ec7c0c9a45835ec5 --- /dev/null +++ b/FYP RAG/summerization-app/static/facebook-brands.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/FYP RAG/summerization-app/static/facebookicon copy.jpg b/FYP RAG/summerization-app/static/facebookicon copy.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e064e6f71b76ed67a395731ae999731ba2cc91c9 Binary files /dev/null and b/FYP RAG/summerization-app/static/facebookicon copy.jpg differ diff --git a/FYP RAG/summerization-app/static/facebookicon.jpg b/FYP RAG/summerization-app/static/facebookicon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e064e6f71b76ed67a395731ae999731ba2cc91c9 Binary files /dev/null and b/FYP RAG/summerization-app/static/facebookicon.jpg differ diff --git a/FYP RAG/summerization-app/static/gavelicon.png b/FYP RAG/summerization-app/static/gavelicon.png new file mode 100644 index 0000000000000000000000000000000000000000..3b90d789abac8d06644fd36590ef1a4f48d40378 Binary files /dev/null and b/FYP RAG/summerization-app/static/gavelicon.png differ diff --git a/FYP RAG/summerization-app/static/githubicon copy.png b/FYP RAG/summerization-app/static/githubicon copy.png new file mode 100644 index 0000000000000000000000000000000000000000..cad7d026f529323e0ff1b4b89f658c32e2a9745c Binary files /dev/null and b/FYP RAG/summerization-app/static/githubicon copy.png differ diff --git a/FYP RAG/summerization-app/static/githubicon.png b/FYP RAG/summerization-app/static/githubicon.png new file mode 100644 index 0000000000000000000000000000000000000000..cad7d026f529323e0ff1b4b89f658c32e2a9745c Binary files /dev/null and b/FYP RAG/summerization-app/static/githubicon.png differ diff --git a/FYP RAG/summerization-app/static/heatmap.png b/FYP RAG/summerization-app/static/heatmap.png new file mode 100644 index 0000000000000000000000000000000000000000..d08ba9ee25a84dabf1c65dcfc7cf675b9c136a60 Binary files /dev/null and b/FYP RAG/summerization-app/static/heatmap.png differ diff --git a/FYP RAG/summerization-app/static/ishaa.jpg b/FYP RAG/summerization-app/static/ishaa.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0ef2e8cf8509bad442b16d22b2fdb9bb7bcbfd94 --- /dev/null +++ b/FYP RAG/summerization-app/static/ishaa.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8985dbad437df9271b7481dd82ae7368368a107986bddbd5666b2d376902a91f +size 106989 diff --git a/FYP RAG/summerization-app/static/izza.jpg b/FYP RAG/summerization-app/static/izza.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5fc6b9e49fbac7cad0c4a1803562311b69e3460e --- /dev/null +++ b/FYP RAG/summerization-app/static/izza.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f53a8cdfda64e38c24d3ee3104bec3dfddb444f0fd3c4cef28d7dd2027e4b0e2 +size 160934 diff --git a/FYP RAG/summerization-app/static/just.jpeg b/FYP RAG/summerization-app/static/just.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..fe9bd9bf081c432173ab5627ac453260099a1b19 Binary files /dev/null and b/FYP RAG/summerization-app/static/just.jpeg differ diff --git a/FYP RAG/summerization-app/static/justice.jpg b/FYP RAG/summerization-app/static/justice.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5b092df9fc30907f31219b309faa0faf11616dcf --- /dev/null +++ b/FYP RAG/summerization-app/static/justice.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e635cbf7852029e67400dc5113af89f1b77fe1cb0a6925716088eb9b7118932d +size 163982 diff --git a/FYP RAG/summerization-app/static/lawbooks/Terms and Conditions.pdf b/FYP RAG/summerization-app/static/lawbooks/Terms and Conditions.pdf new file mode 100644 index 0000000000000000000000000000000000000000..df6ef356ad15db1ae28bd7df225d462098c93e23 --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/Terms and Conditions.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19f6e131bf612d806b667c909589f086d1bf6fd738b44353f9d894bd89e28583 +size 110368 diff --git a/FYP RAG/summerization-app/static/lawbooks/code of civil procedure.pdf b/FYP RAG/summerization-app/static/lawbooks/code of civil procedure.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0beb880e22bbf7bc7f981ad517cd4d2c8822aec5 --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/code of civil procedure.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c51d194bfc14f076769f266db7efabc1901f1de2182da89c8f0ef82d92844b33 +size 2281447 diff --git a/FYP RAG/summerization-app/static/lawbooks/code of criminal procedure.pdf b/FYP RAG/summerization-app/static/lawbooks/code of criminal procedure.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3f38a2ead845bbc3ddf50a45bece101338323cdb --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/code of criminal procedure.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7105b6bdcbc3cc3f6ee3fffa69c21bfaecb8d4e4c8e24f69b3362af9fe72388c +size 2703938 diff --git a/FYP RAG/summerization-app/static/lawbooks/constitution of pakistan.pdf b/FYP RAG/summerization-app/static/lawbooks/constitution of pakistan.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5ea9f1e18b6ccccf7a735cdecd76c21c68693f68 --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/constitution of pakistan.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5567d97b8591a57966108e9df8370e57e0a0adb1bd9a602eec4f18bb09db8500 +size 1841388 diff --git a/FYP RAG/summerization-app/static/lawbooks/estacode.pdf b/FYP RAG/summerization-app/static/lawbooks/estacode.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3245ff36316b1b8d51d974ea432fea15339870bd --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/estacode.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0feb1c0acde32d1e5f0e34445f389ea593470a7f778eab203f13e857f047997c +size 8698035 diff --git a/FYP RAG/summerization-app/static/lawbooks/pakistan penal code.pdf b/FYP RAG/summerization-app/static/lawbooks/pakistan penal code.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5804c41cf5ce9d611c1a10fc18a945e13e380522 --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/pakistan penal code.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e5914daae7d3d3637e526d36de0c44e78d95fabdab7b94637e5b34a75520205 +size 1415173 diff --git a/FYP RAG/summerization-app/static/lawbooks/rules of business.pdf b/FYP RAG/summerization-app/static/lawbooks/rules of business.pdf new file mode 100644 index 0000000000000000000000000000000000000000..861f2a8019471495fbf771c19d74471d397d5ea0 --- /dev/null +++ b/FYP RAG/summerization-app/static/lawbooks/rules of business.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e16ceef3240ef53925671553e2b7b20409cfe30cecc62cd24798e052fb2a022 +size 1002279 diff --git a/FYP RAG/summerization-app/static/linkedinicon.png b/FYP RAG/summerization-app/static/linkedinicon.png new file mode 100644 index 0000000000000000000000000000000000000000..93bd5907082ad3cf35c64456199da085c0dbee91 Binary files /dev/null and b/FYP RAG/summerization-app/static/linkedinicon.png differ diff --git a/FYP RAG/summerization-app/static/logo.png b/FYP RAG/summerization-app/static/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0048591799f6df0be686b6d00d2a253a9ceb9f92 Binary files /dev/null and b/FYP RAG/summerization-app/static/logo.png differ diff --git a/FYP RAG/summerization-app/static/madiha.jpg b/FYP RAG/summerization-app/static/madiha.jpg new file mode 100644 index 0000000000000000000000000000000000000000..eb5afa86a455bbcb6dbfedf3494bf3b5dee12e9e --- /dev/null +++ b/FYP RAG/summerization-app/static/madiha.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53b0751f5faff8694ca7f1b3606ce667255da8291f4399fbef608620df82d5f1 +size 186840 diff --git a/FYP RAG/summerization-app/static/phoneicon.png b/FYP RAG/summerization-app/static/phoneicon.png new file mode 100644 index 0000000000000000000000000000000000000000..f61eaf28419feedc37f1c80fbe2b35fa263beb84 Binary files /dev/null and b/FYP RAG/summerization-app/static/phoneicon.png differ diff --git a/FYP RAG/summerization-app/static/pic12.PNG b/FYP RAG/summerization-app/static/pic12.PNG new file mode 100644 index 0000000000000000000000000000000000000000..c3007f4d9fb1e36fd6a062e9fe271bb0444212c2 --- /dev/null +++ b/FYP RAG/summerization-app/static/pic12.PNG @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:605457c7222fee84c145b3ae7232909ec9c7bde35aed4d7534b8f421c9f75b78 +size 165621 diff --git a/FYP RAG/summerization-app/static/pic12.jpg b/FYP RAG/summerization-app/static/pic12.jpg new file mode 100644 index 0000000000000000000000000000000000000000..22060e7410343b7599c0870932b8b198ae354e36 --- /dev/null +++ b/FYP RAG/summerization-app/static/pic12.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:264e45e6008294ea2ab29a4226ee69d597e7f13e5faba2b77f3fe63284aa35df +size 103623 diff --git a/FYP RAG/summerization-app/static/pic4.jpg b/FYP RAG/summerization-app/static/pic4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8331eb5d70a9ef6b9f0558dc722333e3179f3245 --- /dev/null +++ b/FYP RAG/summerization-app/static/pic4.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e84613e8c0edea9a11d720a4b7a62a80392bf8585f666747886a38c7f71c1a24 +size 3371509 diff --git a/FYP RAG/summerization-app/static/pic5.jpg b/FYP RAG/summerization-app/static/pic5.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1dae05d30d40fe5788ba69dcceb8008daa8a044c --- /dev/null +++ b/FYP RAG/summerization-app/static/pic5.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f49ece75caf2367c46648c30f028190a8124e43ff1a56995bccd679ed02649f2 +size 3101446 diff --git a/FYP RAG/summerization-app/static/pic6.jpg b/FYP RAG/summerization-app/static/pic6.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b72055f33b17aeabc0bfc5c58a1bfd0f7f1ec179 --- /dev/null +++ b/FYP RAG/summerization-app/static/pic6.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17d567981adf6ad8426170988ddf92032620248841c2eb01c3ba246988c4ce3c +size 3124897 diff --git a/FYP RAG/summerization-app/static/pic7.jpg b/FYP RAG/summerization-app/static/pic7.jpg new file mode 100644 index 0000000000000000000000000000000000000000..589fcb8bbf30d705f9dd20f1c483f91a383df342 --- /dev/null +++ b/FYP RAG/summerization-app/static/pic7.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e04c1ac07579fd0876af408a511a1cfdcd9cff7fb5eaab8a63be8b6bd35ffdc2 +size 3326200 diff --git a/FYP RAG/summerization-app/static/pic9.jpg b/FYP RAG/summerization-app/static/pic9.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5bf5593cfe572af84d1acefcdfea629db29a2453 Binary files /dev/null and b/FYP RAG/summerization-app/static/pic9.jpg differ diff --git a/FYP RAG/summerization-app/static/summary.txt b/FYP RAG/summerization-app/static/summary.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/FYP RAG/summerization-app/static/supreme.jpg b/FYP RAG/summerization-app/static/supreme.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f2eebab2fb3cc3ce4dad8e98586d2e7cf96910b6 Binary files /dev/null and b/FYP RAG/summerization-app/static/supreme.jpg differ diff --git a/FYP RAG/summerization-app/static/supremecourt.jpg b/FYP RAG/summerization-app/static/supremecourt.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a6a64e70ad902ca78aa1eeb7636c801ead5350ff --- /dev/null +++ b/FYP RAG/summerization-app/static/supremecourt.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94de1b823f956472d4e237d75f9c824c811189968c16e4b32065a534e50f57fe +size 183716 diff --git a/FYP RAG/summerization-app/static/supremecourtpic.jpg b/FYP RAG/summerization-app/static/supremecourtpic.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d2edbacce395439f2bf8575032d08dff277bfdf2 --- /dev/null +++ b/FYP RAG/summerization-app/static/supremecourtpic.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38266d946e0fb4b58cc3010ac9bd5f074b6720deb88d3705da1ea35286e48f72 +size 332078 diff --git a/FYP RAG/summerization-app/summary.txt b/FYP RAG/summerization-app/summary.txt new file mode 100644 index 0000000000000000000000000000000000000000..5ea0e82137f120887ebdaeafc897d9e0098c8f0d --- /dev/null +++ b/FYP RAG/summerization-app/summary.txt @@ -0,0 +1,7 @@ + +In Civil Petition No. 46054 of 2024, the Supreme Court of Pakistan addressed the authority of the Punjab Government to appoint teaching faculty at the University of Engineering & Technology, Lahore, under the KEMU Act of 2005. The petitioner Dr. Nakshab Chaudhry, the Dean of Basic Medical Sciences and Chairman of the Department of Biochemistry, challenged the authority of KEMU, which was established as a quasi-autonomous institution and later reconstituted as a fully-autonomous institution.The petitioner argued that the Punjab Government lacked the authority to make such appointments under the KEMU Act, stating that the university was established as a "Syndicate" and had no authority to make such appointments. The Punjab Government has consistently appointed candidates from outside the jurisdiction of the relevant selection board, asserting that these appointments must comply with the KEMU Act.The petitioner also highlighted that the university was not bound by its own rules and regulations, as the appointments were made by the Punjab Government, not the KEMU Act or its Rul es. The court found that the Punjab Government could not interfere with the appointments made by the Punjab Government, as it did not follow the relevant legal rules. Ultimately, the Supreme Court dismissed the petition, affirming the appointments under the KEMU Act and its provisions, and stated that the Punjab Government's role in the matter was limited to transferring appointments to other universities. The court concluded that there was no legal bar under Article 199 of the Constitution, and the petition was dismissed. + + + + + diff --git a/FYP RAG/summerization-app/temp/heatmap.png b/FYP RAG/summerization-app/temp/heatmap.png new file mode 100644 index 0000000000000000000000000000000000000000..fe784111012b18aee66b156a951cee7b18bdbf86 Binary files /dev/null and b/FYP RAG/summerization-app/temp/heatmap.png differ diff --git a/FYP RAG/summerization-app/temp/summary.txt b/FYP RAG/summerization-app/temp/summary.txt new file mode 100644 index 0000000000000000000000000000000000000000..80a74847143034991f00ed968965dd2898be726d --- /dev/null +++ b/FYP RAG/summerization-app/temp/summary.txt @@ -0,0 +1,7 @@ + +In Civil Petition No. 46054 of 2024, the Supreme Court of Pakistan addressed the authority of the Punjab Government to appoint teaching faculty at the University of Engineering & Technology, Lahore, under the KEMU Act of 2005. The petitioner Dr. Nakshab Chaudhry, the Dean of Basic Medical Sciences and Chairman of the Department of Biochemistry, challenged the authority of KEMU, which was established as a quasi-autonomous institution and later reconstituted as a fully-autonomous institution.The petitioner argued that the Punjab Government lacked the authority to make such appointments under the KEMU Act, stating that the university was established as a "Syndicate" and had no authority to make such appointments. The Punjab Government has consistently appointed candidates from outside the jurisdiction of the relevant selection board, asserting that these appointments must comply with the KEMU Act.The petitioner also highlighted that the university was not bound by its own rules and regulations, as the appointments were made by the Punjab Government, not the KEMU Act or its Rul es. The court found that the Punjab Government could not interfere with the appointments made by the Punjab Government, as it did not follow the relevant legal rules. Ultimately, the Supreme Court dismissed the petition, affirming the appointments under the KEMU Act and its provisions, and stated that the Punjab Government's role in the matter was limited to transferring appointments to other universities. The court concluded that there was no legal bar under Article 199 of the Constitution, and the petition was dismissed. + + + + + diff --git a/FYP RAG/summerization-app/templates/.gitignore b/FYP RAG/summerization-app/templates/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5a3590cf1d40937079a7a053d629fccb03e4f6bf --- /dev/null +++ b/FYP RAG/summerization-app/templates/.gitignore @@ -0,0 +1 @@ +.vercel diff --git a/FYP RAG/summerization-app/templates/aboutpage.html b/FYP RAG/summerization-app/templates/aboutpage.html new file mode 100644 index 0000000000000000000000000000000000000000..5aa309d4b5d79787a86501d37fd1bb798d0b39ff --- /dev/null +++ b/FYP RAG/summerization-app/templates/aboutpage.html @@ -0,0 +1,1162 @@ + + + + + + LawSumm - Legal Summarizer + + + + + + + + +
+ +
+
+
+

About
LawSumm

+ +
+
+
+
+

About Us

+

We are here to simplify
legal complexities

+

We are here to simplify legal complexities and make justice more accessible. Our AI-powered platform transforms lengthy legal documents into clear, concise, and accurate summaries, saving time and effort. With fast and reliable processing, we help legal professionals, researchers, and individuals quickly understand critical case details. Our innovative technology ensures precision and clarity, empowering users with instant legal insights.

+ + +
+
+ Law Firm Team +
+
+
+
+

Why
LawSumm is Better?

+

We simplify legal complexities with our AI-powered summarization tool, transforming lengthy documents into clear, concise insights within seconds. Our smart legal chatbot provides instant, accurate answers to your legal inquiries, ensuring you get the information you need without delays. Designed for efficiency, our platform helps you save time and streamline research with AI-driven precision. With a focus on accuracy and reliability, we process legal language with advanced technology to deliver meaningful summaries. Plus, our user-friendly and secure interface ensures a seamless experience while keeping your data protected.

+ + +
+
+ Law Firm Team +
+
+
+ +
+ + Legal Production +

AI based Legal Summarizer

+

AI-powered legal summarizer for transforming complex legal texts
into concise, actionable insights.

+
+
+ Private +

Legal Chatbot

+

AI-powered legal assistance for precise responses to legal inquires.

+
+
+ Winning Awards +

Key Highlighting

+

Essential points highlighting for easy access to legal references.

+
+
+
+
+ Law Firm Promo +
+ +
+
+
+ + +
+
+ × + +
+
+
+

Meet Our Team

+
+ + +
+ Lawyer + +
+ + + +
+
Izza Shahzad
+
Data Scientist
+
+ +
+ Lawyer + +
+ + + +
+
Ishaa Arshad
+
Data Scientist
+
+ +
+ Lawyer + +
+ + + +
+
Madiha Shah
+
Web Developer
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/FYP RAG/summerization-app/templates/contactpage.html b/FYP RAG/summerization-app/templates/contactpage.html new file mode 100644 index 0000000000000000000000000000000000000000..04db8025f4fb70fd114f70bd69ddd33968c7c1f9 --- /dev/null +++ b/FYP RAG/summerization-app/templates/contactpage.html @@ -0,0 +1,676 @@ + + + + + + LawSumm - Legal Summarizer + + + + + + + + + +
+ +
+ +
+
+

Contact
Us

+ +
+
+
+
+ +

Do you need help?
Contact with us now!

+ +
+ +
+ +

0665 UET Taxila Pakistan

+
+
+ +
+ +
+ +

+92 337 55498762

+
+
+ +
+ +
+ +

legaldocumentai@gmail.com

+
+
+
+ +
+

Contact with us now!

+ + + + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/FYP RAG/summerization-app/templates/forgetpasswordpage.html b/FYP RAG/summerization-app/templates/forgetpasswordpage.html new file mode 100644 index 0000000000000000000000000000000000000000..d4768311216291c820d183489bf2b0b1c272a6f7 --- /dev/null +++ b/FYP RAG/summerization-app/templates/forgetpasswordpage.html @@ -0,0 +1,207 @@ + + + + + + Reset Password + + + + + +
+ +
+ + + + diff --git a/FYP RAG/summerization-app/templates/homepage.html b/FYP RAG/summerization-app/templates/homepage.html new file mode 100644 index 0000000000000000000000000000000000000000..c9b995084f6a884681e10430c9932e931b8c2fbe --- /dev/null +++ b/FYP RAG/summerization-app/templates/homepage.html @@ -0,0 +1,1559 @@ + + + + + + LawSumm - Legal Summarizer + + + + + + + + + + +
+ +
+ +
+
+

Summarizing Law
Simplifying Justice

+ + Try Summarizer +
+
+
+ +
+
+

About Us

+

We are here to simplify
legal complexities

+

We are here to simplify legal complexities and make justice more accessible. Our AI-powered platform transforms lengthy legal documents into clear, concise, and accurate summaries, saving time and effort. With fast and reliable processing, we help legal professionals, researchers, and individuals quickly understand critical case details. Our innovative technology ensures precision and clarity, empowering users with instant legal insights.

+ +
+
+ Law Firm Team + +
+
+
+ +
+ Legal Production +

AI based Legal Summarizer

+

AI-powered legal summarizer for transforming complex legal texts
into concise, actionable insights.

+
+
+ Private +

Legal Chatbot

+

AI-powered legal assistance for precise responses to legal inquires.

+
+
+ Winning Awards +

Key Highlighting

+

Essential points highlighting for easy access to legal references.

+
+
+
+
+ Law Firm Promo +
+ +
+
+
+ + +
+
+ × + +
+
+ + +
+

What Our Customers Say?

+ + + +
+
+

"I use this summarizer to quickly get key points from court rulings. It's fast and reliable."

+
+ Reviewer +
+ Hassan Raza, Paralegal +

★★★★★

+
+
+
+ +
+

"This tool is a lifesaver for students like me. It helps me quickly understand judgments without reading hundreds of pages."

+
+ Reviewer +
+ Ayesha Khan, Law Student +

★★★★★

+
+
+
+ +
+

"As a lawyer, This summarizer has significantly reduced my workload by providing precise and concise case summaries in seconds"

+
+ Reviewer +
+ Sarah Ahmed, Advocate +

★★★★☆

+
+
+
+ +
+

"The AI-generated summaries are highly accurate and well-structured. It saves me hours of reading and helps me focus on case strategies."

+
+ Reviewer +
+ Omar Siddiqui, Legal Consultant + + +

★★★★★

+
+
+
+
+
+ + +
+

Meet Our Team

+
+ + +
+ Lawyer + +
+ + + +
+
Izza Shahzad
+
Data Scientist
+
+ +
+ Lawyer + +
+ + + +
+
Ishaa Arshad
+
Data Scientist
+
+ +
+ Lawyer + +
+ + + +
+
Madiha Shah
+
Web Developer
+
+
+
+
+

FAQ

+ +
+
+ Is Lawsumm Legal Case Summarizer free to use? + + +
+
+ Yes, the basic version is free, but premium features require a subscription. +
+
+ +
+
+ How does the AI summarize legal cases? + + +
+
+ The AI extracts key legal points, rulings, and arguments from court cases. +
+
+
+
+ How does the AI summarize legal cases? + + +
+
+ The AI extracts key legal points, rulings, and arguments from court cases. +
+
+
+
+ How does the AI summarize legal cases? + + +
+
+ The AI extracts key legal points, rulings, and arguments from court cases. +
+
+ +
+
+ Is the summary generated by the AI accurate? + + +
+
+ The AI aims for high accuracy but should be reviewed for legal applications. +
+
+ +
+ +
+ + + + + + + + diff --git a/FYP RAG/summerization-app/templates/loginpage.html b/FYP RAG/summerization-app/templates/loginpage.html new file mode 100644 index 0000000000000000000000000000000000000000..027ff21183477aecf0f0ef001ecd6845174a2108 --- /dev/null +++ b/FYP RAG/summerization-app/templates/loginpage.html @@ -0,0 +1,403 @@ + + + + + + Login Page + + + + + + +
+ +
+ + + + + + + diff --git a/FYP RAG/summerization-app/templates/mainscreen.html b/FYP RAG/summerization-app/templates/mainscreen.html new file mode 100644 index 0000000000000000000000000000000000000000..7d7437fe9d465afc6342294421c4e9b36f7692b2 --- /dev/null +++ b/FYP RAG/summerization-app/templates/mainscreen.html @@ -0,0 +1,1321 @@ + + + + + + LawSumm - Legal Summarizer + + + + + + +
+ +
+
+
+
+ Example Image + +

DRAG & DROP A FILE*,

+

paste text or choose an option below

+ + + + +
+ +
+ + + +
+ + + + + + + + + +
+
+ + + + {% if summary %} +

Generated Summary

+
{{ summary|safe }}
+
+ Download Summary +
+ {% endif %} + {% if heatmap_url %} +

Sentence Importance Heatmap

+
+ Sentence Importance Heatmap +
+{% endif %} + + +
+ + +
+ + +
+
+

Legal AI Assistant

+ +
+
+
+

Hello! Ask me questions related to Pakistan penal code, code of criminal and civil procedure,constitution of pakistan and rules of business

+
+
+
+ + +
+
+ + + + + + + + + + + + diff --git a/FYP RAG/summerization-app/templates/signuppage.html b/FYP RAG/summerization-app/templates/signuppage.html new file mode 100644 index 0000000000000000000000000000000000000000..44c3e34917489a6dfea64b8a99482a7158fe118e --- /dev/null +++ b/FYP RAG/summerization-app/templates/signuppage.html @@ -0,0 +1,319 @@ + + + + + + Signup Page + + + + +
+