File size: 1,997 Bytes
cea4768
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
from src.chat import SchoolChatbot

def test_chatbot():
    """
    Test the chatbot with specific edge cases.
    """
    # Initialize the chatbot
    chatbot = SchoolChatbot()

    # Define test cases
    test_cases = [
        {
            "description": "Address not in MA",
            "question": "Which schools can I enroll in if I live in 314 W 58th St, New York, NY 10019?",
            "expected_answer": "No"
        },
        {
            "description": "Address on border of two schools",
            "question": "If a family's address is on the border of two school zones, how is the school assignment determined?",
            "expected_answer": "Based on the home-based assignment plan."
        },
        {
            "description": "Fake grade (14th grade)",
            "question": "Can a student enroll in 14th grade in BPS?",
            "expected_answer": "No"
        },
    ]

    # Run test cases
    results = []
    for case in test_cases:
        question = case["question"]
        expected_answer = case["expected_answer"]

        # Get the chatbot's response
        response = chatbot.get_response(question)

        # Determine if the response matches the expected answer
        is_correct = expected_answer.lower() in response.lower()
        result = {
            "Description": case["description"],
            "Question": question,
            "Expected Answer": expected_answer,
            "Chatbot Response": response,
            "Correct (1)/Incorrect (0)": 1 if is_correct else 0
        }
        results.append(result)

    # Print results
    for result in results:
        print(f"Test Case: {result['Description']}")
        print(f"Question: {result['Question']}")
        print(f"Expected Answer: {result['Expected Answer']}")
        print(f"Chatbot Response: {result['Chatbot Response']}")
        print(f"Correct: {result['Correct (1)/Incorrect (0)']}")
        print("-" * 50)

if __name__ == "__main__":
    test_chatbot()