MickMachar commited on
Commit
bb8c744
1 Parent(s): c0f7249

Upload 5 files

Browse files
Files changed (5) hide show
  1. data.pickle +3 -0
  2. intents.json +163 -0
  3. intents2..json +104 -0
  4. main.py +114 -0
  5. tempCodeRunnerFile.py +4 -0
data.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99ac34bacfe4aae5ed76ee3ef8f7e4cc5e488dc165425b98e194764708a89174
3
+ size 8926
intents.json ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"intents":[
2
+ {"tag": "greetings",
3
+ "patterns": ["hello", "hey", "hi", "good day", "Greetings", "whats's up?", "how is it going?"],
4
+ "responses": ["Hello", "Hey!", "What can I do for you?"]
5
+ },
6
+ {"tag": "goodbye",
7
+ "patterns": ["cya", "See you later", "Goodbye", "I am Leaving", "Have a Good day", "bye", "cao", "see ya"],
8
+ "responses": ["Sad to see you go!", "Talk to you later", "Goodbye!"]
9
+ },
10
+ {"tag": "age",
11
+ "patterns": ["how old", "how old is brandon", "what is your age", "how old are you", "age"],
12
+ "responses": ["My owner Brandon is 25 years old!", "25 years!"]
13
+ },
14
+ {"tag": "starting issue",
15
+ "patterns": ["Car Clicks trying to start", "Doesnt start"],
16
+ "responses": ["Your battery could be dead! Try to recharge the battery if does not solve your issue could be mulible things like starter, bad cable, or blown fuse seek mechanic help. "]
17
+ },
18
+ {"tag": "suspension",
19
+ "patterns": ["Car is riding rough", "My car vibrates when going on the freeway", "My car is vibrating in the front"],
20
+ "responses": ["Sounds like your going to need a tire balanace first in most cases when there doing the job they will also inform you if you need to replace some suspension parts."]
21
+ },
22
+ {"tag": "alignment",
23
+ "patterns": ["My car is going to the right", "My car is going to the left", "My car keeps driving to the side"],
24
+ "responses": ["Sounds like your going to need an alignment! When you take your vehicle to the alignment shop they will tell you if you need to replace some suspension parts. "]
25
+ },
26
+ {"tag": "Low fuel mileage",
27
+ "patterns": ["My car wasting a lot of fuel", "My car is burning more fuel then what it was", "I dont know why my car is burning more fuel then it is"],
28
+ "responses": ["Delaying in services could be the main cause like spark plugs, igntion coils and air filters for further causes could be o2 sensors, fuel injectors "]
29
+ },
30
+ {"tag": "exhaust smoke",
31
+ "patterns": ["smoke is coming out of my exhaust", "Theres a lot of smoke coming out of my exhaust", "Why is there smoke coming out of my exhaust"],
32
+ "responses": ["White or Grey Smoke: White smoke indicates that the coolant is being combusted along with the fuel and there is a leakage somewhere in the Engine block, cylinder head and head gasket. Blue Smoke: Blue smoke indicates that there is a leakage in the valve seals or guides or the piston rings have worn out, which are causing the engine oil to penetrate into the combustion chamber which is causing the oil to burn along with the fuel. Hence Causing Blue Smoke. Black Smoke: This means that excessive fuel is being burnt in the combustion chambers due to a leak in the fuel injector, a stuck fuel pressure regulator or a restriction in the fuel combustion pipe. This usually happens with relatively older cars and in such situations, it is very crucial to get the leaks checked from a specialised mechanic."]
33
+ },
34
+ {"tag": "Low engine oil level",
35
+ "patterns": ["why am I getting low engine oil level"],
36
+ "responses": ["You could have a leak! But engine do burn oil,Low engine oil level can cause your engine to underperform significantly. Something which is again caused due to delayed car service and aggressive driving. "]
37
+ },
38
+ {"tag": "squealing brakes",
39
+ "patterns": ["My brakes keep making a noise", "Why do my brakes keep squealing"],
40
+ "responses": ["It is primarily caused by worn-off brake pads. Ignoring squealing brakes is not good, as less responsive brakes can even lead to severe accidents. Hence as soon as you hear your brakes going all high pitched, get your brake pads replaced from your trusted car service partner Mechanic."]
41
+ },
42
+ {"tag": "low ac cooling",
43
+ "patterns": ["my ac is not working anymore", "why isnt my ac not working anymore", "my car blowing hot air its not getting cold anymore"],
44
+ "responses": ["What usually affects the cooling of the car AC is an AC gas leakage. Other factors include a Clogged or broken Compressor. We recommend you to get your car AC serviced from specialised technicians who can fix such issues in no time."]
45
+ },
46
+ {"tag": "engine overheating",
47
+ "patterns": ["My car is overheating", "my engine overheating"],
48
+ "responses": ["Check coolant level Warning! Let the vehilce to cool down then check it. If it keeps overheating the next thing would be thermostat, if you have no proir experience take it to professional help."]
49
+ },
50
+ {"tag": "help",
51
+ "patterns": ["I need help on my car", "My car having issue", "My car running funny"],
52
+ "responses": ["Okay tell more details of what's going on?", "I'm glad to help tell me more.", "Tell me what's going on?"]
53
+ },
54
+ {"tag": "hours",
55
+ "patterns": ["when are you guys open", "what are your hours", "hours of operation"],
56
+ "responses": ["24/7"]
57
+ },
58
+ {
59
+ "tag": "greeting",
60
+ "patterns": [
61
+ "Hi",
62
+ "Hello",
63
+ "Hey",
64
+ "What's up"
65
+ ],
66
+ "responses": [
67
+ "Hello! How can I assist you with your car diagnostics today?",
68
+ "Hi there! What can I help you with in regards to your car?",
69
+ "Hey, what brings you here today? Car troubles?"
70
+ ]
71
+ },
72
+ {
73
+ "tag": "engine_start",
74
+ "patterns": [
75
+ "My car won't start",
76
+ "The engine won't turn over",
77
+ "Car won't crank",
78
+ "Car won't start",
79
+ "Engine won't start",
80
+ "Car won't turn over"
81
+ ],
82
+ "responses": [
83
+ "There could be a few reasons why your car won't start. Have you checked the battery?",
84
+ "If your car won't start, it's likely an issue with the battery or alternator. When was the last time you had them checked?",
85
+ "A common issue with cars not starting is a bad starter motor. Have you checked that?",
86
+ "If your car won't start, it's possible that the fuel pump or ignition system is malfunctioning. Have you noticed any other symptoms?"
87
+ ]
88
+ },
89
+ {
90
+ "tag": "battery",
91
+ "patterns": [
92
+ "My battery is dead",
93
+ "Battery died",
94
+ "Car won't start because of battery",
95
+ "Battery not holding a charge"
96
+ ],
97
+ "responses": [
98
+ "If your battery is dead, you may need to jumpstart your car. Do you have jumper cables and another car to help with this?",
99
+ "A dead battery can be caused by a number of issues. Have you had your battery tested recently?",
100
+ "If your battery is not holding a charge, it's likely time to replace it. How old is your current battery?"
101
+ ]
102
+ },
103
+ {
104
+ "tag": "alternator",
105
+ "patterns": [
106
+ "My alternator is bad",
107
+ "Alternator problems",
108
+ "Car battery not charging",
109
+ "Battery light on",
110
+ "Dimming headlights"
111
+ ],
112
+ "responses": [
113
+ "If your alternator is bad, it could be causing issues with your battery charging properly. Have you noticed any other symptoms?",
114
+ "If your battery light is on, it could be a sign that your alternator is failing. Have you had your alternator tested?",
115
+ "Dimming headlights can be a sign of a failing alternator. When was the last time you had your car's electrical system checked?"
116
+ ]
117
+ },
118
+ {
119
+ "tag": "starter_motor",
120
+ "patterns": [
121
+ "My starter motor is bad",
122
+ "Car won't turn over",
123
+ "Car makes clicking sound when starting",
124
+ "Starter solenoid problems",
125
+ "Car cranks but won't start"
126
+ ],
127
+ "responses": [
128
+ "If your car won't turn over, it's possible that the starter motor is bad. Have you had it tested?",
129
+ "A clicking sound when starting can be a sign of a failing starter motor. Have you noticed any other symptoms?",
130
+ "If your car cranks but won't start, it's possible that the starter solenoid is malfunctioning. Have you checked that?",
131
+ "A bad starter motor can cause a number of issues with your car starting properly. When was the last time you had it checked?"
132
+ ]
133
+ },
134
+ {
135
+ "tag": "fuel_system",
136
+ "patterns": [
137
+ "Car won't start because of fuel problems",
138
+ "Fuel pump issues",
139
+ "Car stalls while driving",
140
+ "Engine misfires",
141
+ "Fuel leaks"
142
+ ],
143
+ "responses": [
144
+ "If your car won't start due to fuel problems, it could be an issue with the fuel pump or fuel injectors. Have you had them checked?",
145
+ "A failing fuel pump can cause a number of issues with your car's performance. When was the last time you had it replaced?",
146
+ "If your car stalls while driving, it could be an issue with the fuel system. Have you checked for any fuel leaks?",
147
+ "Engine misfires can be caused by a number of issues, including problems with the fuel system. Have you noticed any other symptoms?",
148
+ "If you have noticed any fuel leaks, it's important to get them fixed as soon as possible to avoid any safety hazards. Have you had your fuel lines checked recently?",
149
+ "A clogged fuel filter can also cause issues with your car's performance. Have you checked or replaced your fuel filter?",
150
+ "If you are experiencing decreased fuel efficiency, it could be due to a problem with the fuel system. Have you had your fuel injectors cleaned?",
151
+ "If you are smelling gasoline inside the car, it could be a sign of a fuel leak. Have you noticed any unusual smells?",
152
+ "Old or contaminated fuel can cause a number of issues with your car's performance. When was the last time you had your fuel tank drained and refilled?",
153
+ "If your car is experiencing rough idling, it could be due to problems with the fuel system. Have you had your fuel pressure regulator checked?",
154
+ "A malfunctioning fuel gauge can also be a sign of a fuel system issue. Have you had your fuel sending unit tested?",
155
+ "If your car is hesitating or sputtering when you accelerate, it could be due to problems with the fuel system. Have you had your fuel injectors checked for clogs or leaks?",
156
+ "If you are experiencing engine knocking or pinging, it could be due to problems with the fuel octane level. Have you been using the recommended fuel for your car?",
157
+ "If you have noticed any fuel leaks, it's important to get them fixed as soon as possible to avoid any safety hazards. Have you had your fuel lines checked recently?"
158
+ ]
159
+ }
160
+
161
+
162
+
163
+ ]}
intents2..json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "intents": [
3
+ {
4
+ "tag": "greeting",
5
+ "patterns": [
6
+ "Hi",
7
+ "Hello",
8
+ "Hey",
9
+ "What's up"
10
+ ],
11
+ "responses": [
12
+ "Hello! How can I assist you with your car diagnostics today?",
13
+ "Hi there! What can I help you with in regards to your car?",
14
+ "Hey, what brings you here today? Car troubles?"
15
+ ]
16
+ },
17
+ {
18
+ "tag": "engine_start",
19
+ "patterns": [
20
+ "My car won't start",
21
+ "The engine won't turn over",
22
+ "Car won't crank",
23
+ "Car won't start",
24
+ "Engine won't start",
25
+ "Car won't turn over"
26
+ ],
27
+ "responses": [
28
+ "There could be a few reasons why your car won't start. Have you checked the battery?",
29
+ "If your car won't start, it's likely an issue with the battery or alternator. When was the last time you had them checked?",
30
+ "A common issue with cars not starting is a bad starter motor. Have you checked that?",
31
+ "If your car won't start, it's possible that the fuel pump or ignition system is malfunctioning. Have you noticed any other symptoms?"
32
+ ]
33
+ },
34
+ {
35
+ "tag": "battery",
36
+ "patterns": [
37
+ "My battery is dead",
38
+ "Battery died",
39
+ "Car won't start because of battery",
40
+ "Battery not holding a charge"
41
+ ],
42
+ "responses": [
43
+ "If your battery is dead, you may need to jumpstart your car. Do you have jumper cables and another car to help with this?",
44
+ "A dead battery can be caused by a number of issues. Have you had your battery tested recently?",
45
+ "If your battery is not holding a charge, it's likely time to replace it. How old is your current battery?"
46
+ ]
47
+ },
48
+ {
49
+ "tag": "alternator",
50
+ "patterns": [
51
+ "My alternator is bad",
52
+ "Alternator problems",
53
+ "Car battery not charging",
54
+ "Battery light on",
55
+ "Dimming headlights"
56
+ ],
57
+ "responses": [
58
+ "If your alternator is bad, it could be causing issues with your battery charging properly. Have you noticed any other symptoms?",
59
+ "If your battery light is on, it could be a sign that your alternator is failing. Have you had your alternator tested?",
60
+ "Dimming headlights can be a sign of a failing alternator. When was the last time you had your car's electrical system checked?"
61
+ ]
62
+ },
63
+ {
64
+ "tag": "starter_motor",
65
+ "patterns": [
66
+ "My starter motor is bad",
67
+ "Car won't turn over",
68
+ "Car makes clicking sound when starting",
69
+ "Starter solenoid problems",
70
+ "Car cranks but won't start"
71
+ ],
72
+ "responses": [
73
+ "If your car won't turn over, it's possible that the starter motor is bad. Have you had it tested?",
74
+ "A clicking sound when starting can be a sign of a failing starter motor. Have you noticed any other symptoms?",
75
+ "If your car cranks but won't start, it's possible that the starter solenoid is malfunctioning. Have you checked that?",
76
+ "A bad starter motor can cause a number of issues with your car starting properly. When was the last time you had it checked?"
77
+ ]
78
+ },
79
+ {
80
+ "tag": "fuel_system",
81
+ "patterns": [
82
+ "Car won't start because of fuel problems",
83
+ "Fuel pump issues",
84
+ "Car stalls while driving",
85
+ "Engine misfires",
86
+ "Fuel leaks"
87
+ ],
88
+ "responses": [
89
+ "If your car won't start due to fuel problems, it could be an issue with the fuel pump or fuel injectors. Have you had them checked?",
90
+ "A failing fuel pump can cause a number of issues with your car's performance. When was the last time you had it replaced?",
91
+ "If your car stalls while driving, it could be an issue with the fuel system. Have you checked for any fuel leaks?",
92
+ "Engine misfires can be caused by a number of issues, including problems with the fuel system. Have you noticed any other symptoms?",
93
+ "If you have noticed any fuel leaks, it's important to get them fixed as soon as possible to avoid any safety hazards. Have you had your fuel lines checked recently?",
94
+ "A clogged fuel filter can also cause issues with your car's performance. Have you checked or replaced your fuel filter?",
95
+ "If you are experiencing decreased fuel efficiency, it could be due to a problem with the fuel system. Have you had your fuel injectors cleaned?",
96
+ "If you are smelling gasoline inside the car, it could be a sign of a fuel leak. Have you noticed any unusual smells?",
97
+ "Old or contaminated fuel can cause a number of issues with your car's performance. When was the last time you had your fuel tank drained and refilled?",
98
+ "If your car is experiencing rough idling, it could be due to problems with the fuel system. Have you had your fuel pressure regulator checked?",
99
+ "A malfunctioning fuel gauge can also be a sign of a fuel system issue. Have you had your fuel sending unit tested?",
100
+ "If your car is hesitating or sputtering when you accelerate, it could be due to problems with the fuel system. Have you had your fuel injectors checked for clogs or leaks?",
101
+ "If you are experiencing engine knocking or pinging, it could be due to problems with the fuel octane level. Have you been using the recommended fuel for your car?",
102
+ "If you have noticed any fuel leaks, it's important to get them fixed as soon as possible to avoid any safety hazards. Have you had your fuel lines checked recently?"
103
+ ]
104
+ }
main.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from urllib import response
2
+ import nltk
3
+ from nltk.stem.lancaster import LancasterStemmer
4
+ stemmer = LancasterStemmer()
5
+
6
+ import numpy
7
+ import tflearn
8
+ import tensorflow
9
+ import random
10
+ import json
11
+ import pickle
12
+
13
+ with open("intents.json") as file:
14
+ data = json.load(file)
15
+
16
+ try:
17
+ with open("data.pickle", "rb") as f:
18
+ words, labels, training, output = pickle.load(f)
19
+ except:
20
+ words = []
21
+ labels = []
22
+ docs_x = []
23
+ docs_y = []
24
+
25
+ for intent in data["intents"]:
26
+ for pattern in intent["patterns"]:
27
+ wrds = nltk.word_tokenize(pattern)
28
+ words.extend(wrds)
29
+ docs_x.append(wrds)
30
+ docs_y.append(intent["tag"])
31
+
32
+ if intent["tag"] not in labels:
33
+ labels.append(intent["tag"])
34
+
35
+ words = [stemmer.stem(w.lower()) for w in words if w != "?"]
36
+ words = sorted(list(set(words)))
37
+
38
+ labels = sorted(labels)
39
+
40
+ training = []
41
+ output = []
42
+
43
+ out_empty = [0 for _ in range(len(labels))]
44
+
45
+ for x, doc in enumerate(docs_x):
46
+ bag = []
47
+
48
+ wrds = [stemmer.stem(w.lower()) for w in doc]
49
+
50
+ for w in words:
51
+ if w in wrds:
52
+ bag.append(1)
53
+ else:
54
+ bag.append(0)
55
+
56
+ output_row = out_empty[:]
57
+ output_row[labels.index(docs_y[x])] = 1
58
+
59
+ training.append(bag)
60
+ output.append(output_row)
61
+
62
+
63
+ training = numpy.array(training)
64
+ output = numpy.array(output)
65
+
66
+ with open("data.pickle", "wb") as f:
67
+ pickle.dump((words, labels, training, output), f)
68
+
69
+ net = tflearn.input_data(shape=[None, len(training[0])])
70
+ net = tflearn.fully_connected(net, 8)
71
+ net = tflearn.fully_connected(net, 8)
72
+ net = tflearn.fully_connected(net, len(output[0]), activation="softmax")
73
+ net = tflearn.regression(net)
74
+
75
+ model = tflearn.DNN(net)
76
+
77
+ try:
78
+ model.load("model.tflearn")
79
+ except:
80
+ model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)
81
+ model.save("model.tflearn")
82
+
83
+ def bag_of_words(s, words):
84
+ bag = [0 for _ in range(len(words))]
85
+
86
+ s_words = nltk.word_tokenize(s)
87
+ s_words = [stemmer.stem(word.lower()) for word in s_words]
88
+
89
+ for se in s_words:
90
+ for i, w in enumerate(words):
91
+ if w == se:
92
+ bag[i] = 1
93
+
94
+ return numpy.array(bag)
95
+
96
+
97
+ def chat():
98
+ print("Start talking with the bot (type quit to stop)!")
99
+ while True:
100
+ inp = input("You: ")
101
+ if inp.lower() == "quit":
102
+ break
103
+
104
+ results = model.predict([bag_of_words(inp, words)])
105
+ results_index = numpy.argmax(results)
106
+ tag = labels[results_index]
107
+
108
+ for tg in data["intents"]:
109
+ if tg['tag'] == tag:
110
+ responses = tg['responses']
111
+
112
+ print(random.choice(responses))
113
+
114
+ chat()
tempCodeRunnerFile.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import pickle
2
+ from . import main
3
+ with open("data.pickle", "rb") as f:
4
+ words, labels, training, output = pickle.load(f)