import pandas as pd from pathlib import Path DATA = { "greeting": { "patterns": ["Hello", "Hi there", "Hey", "Good morning", "Good evening"], "responses": ["Hello! How can I help you today?", "Hi! What would you like to know about your LMS?"] }, "goodbye": { "patterns": ["Goodbye", "Bye", "See you", "Catch you later"], "responses": ["Goodbye! Have a great day.", "See you soon!"] }, "courses": { "patterns": ["What courses am I enrolled in?", "List all my courses", "How many credits do I have?"], "responses": [ "You are enrolled in several courses. Please check your LMS dashboard.", "Here is the list of your enrolled courses in the LMS.", "You can view your total credits in your academic profile." ] }, "grades": { "patterns": ["Show my grades", "How do I view my grades?", "Check my performance"], "responses": [ "Your grades are available in the 'Grades' section of the LMS.", "Go to the 'Grades' tab in the LMS to check your performance." ] }, "assignment": { "patterns": ["When is the assignment due?", "How do I submit my homework?", "Upload assignment"], "responses": [ "You can check assignment deadlines in the 'Assignments' section.", "Upload your homework in the LMS under 'Assignments'." ] }, "schedule": { "patterns": ["List all upcoming lectures", "What is the next lecture topic?", "Show timetable"], "responses": [ "Upcoming lectures are listed in your calendar on the LMS.", "The next lecture topic is available in the course schedule." ] }, "instructor": { "patterns": ["Who is my instructor?", "Who teaches this course?"], "responses": ["You can find your instructor details on the course information page."] }, "technical_support": { "patterns": ["How can I reset my password?", "My portal is not loading", "LMS not working"], "responses": [ "Go to account settings and click on 'Reset Password'.", "Try clearing your cache or contact IT support." ] }, "feedback": { "patterns": ["How do I give feedback?", "I want to share my opinion"], "responses": ["You can provide feedback through the LMS feedback form."] }, "resources": { "patterns": ["Where can I find course materials?", "How can I access lecture notes?", "Show learning materials"], "responses": [ "Course materials are available under the 'Resources' section.", "Lecture notes are uploaded in the course resources." ] } } # Convert into rows for DataFrame (expand patterns into rows) rows = [] for intent, data in DATA.items(): for pattern in data["patterns"]: # one row per pattern rows.append({ "tag": intent, # <-- renamed to tag "patterns": pattern, "responses": ";".join(data["responses"]) # keep multiple responses joined }) df = pd.DataFrame(rows, columns=["tag", "patterns", "responses"]) # Save CSV inside data/ folder OUT = Path(__file__).resolve().parent.parent / "data" / "intents.csv" OUT.parent.mkdir(parents=True, exist_ok=True) df.to_csv(OUT, index=False, encoding="utf-8") print(f"✅ Created intents CSV at {OUT}")