File tree Expand file tree Collapse file tree 21 files changed +19011
-0
lines changed
GAMES/Guess the US States Expand file tree Collapse file tree 21 files changed +19011
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ ![ Star Badge] ( https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99 )
2
+ ![ Open Source Love] ( https://badges.frapsoft.com/os/v1/open-source.svg?v=103 )
3
+
4
+ # Hello-to-CHATBOT
5
+ A chatbot is a computer software able to interact with humans using a natural language. They usually rely on machine learning, especially on NLP.
6
+
7
+ # ⚙️🛠️Preparing Dependencies:
8
+ You’re only going to install the library ChatterBot for now. I recommend creating and using a new Python virtual environment for this purpose. Execute the following commands in your Python terminal:
9
+
10
+ run these command:
11
+ ``` sh
12
+ pip install chatterbot
13
+ ```
14
+ ``` sh
15
+ pip install chatterbot_corpus
16
+ ```
17
+
18
+ You can also try upgrading them:
19
+ ``` sh
20
+ pip install --upgrade chatterbot_corpus
21
+ ```
22
+ ``` sh
23
+ pip install --upgrade chatterbot
24
+ ```
25
+ That’s it. We’re ready to go.
26
+
27
+ # Communicating with a Bot🤖
28
+
29
+ You can communicate with your bot using its method .get_response(). Here’s an example of how that might look like :
30
+ <img width =" 543 " alt =" Screenshot 2022-07-09 133433 " src =" https://user-images.githubusercontent.com/102956488/178097413-38319234-ad36-43e0-84dc-97923f659d33.png " >
Original file line number Diff line number Diff line change
1
+ from chatterbot import ChatBot
2
+ from chatterbot .trainers import ListTrainer
3
+ my_bot = ChatBot (
4
+ name = "PyBot" ,
5
+ read_only = True ,
6
+ )
7
+ logic_adapters = ["chatterbot.logic.MathematicalEvaluation" ,"chatterbot.logic.BestMatch" ]
8
+ small_talk = ['hi there!' ,
9
+ 'hi!' ,
10
+ 'how do you do?' ,
11
+ 'how are you?' ,
12
+ 'i\' m cool.' ,
13
+ 'fine, you?' ,
14
+ 'always cool.' ,
15
+ 'i\' m ok' ,
16
+ 'glad to hear that.' ,
17
+ 'i\' m fine' ,
18
+ 'glad to hear that.' ,
19
+ 'i feel awesome' ,
20
+ 'excellent, glad to hear that.' ,
21
+ 'not so good' ,
22
+ 'sorry to hear that.' ,
23
+ 'what\' s your name?' ,
24
+ 'i\' m pybot. ask me a math question, please.' ]
25
+ math_talk_1 = ['pythagorean theorem' ,
26
+ 'a squared plus b squared equals c squared.' ]
27
+ math_talk_2 = ['law of cosines' ,
28
+ 'c**2 = a**2 + b**2 - 2 * a * b * cos(gamma)' ]
29
+ list_trainer = ListTrainer (my_bot )
30
+
31
+ for item in (small_talk , math_talk_1 , math_talk_2 ):
32
+ list_trainer .train (item )
33
+ corpus_pusirainer (my_bot )
34
+ corpus_tainer .train ('chatterbot.corpus.english' )
35
+ print (my_bot .get_response ("hi" ))
36
+ print (my_bot .get_response ("Ifell awesome today" ))
37
+ print (my_bot .get_response ("What's your name?" ))
38
+ print (my_bot .get_response ("show me the pythagorean theorem" ))
39
+ print (my_bot .get_response ("do you know the law of cosines?" ))
Original file line number Diff line number Diff line change
1
+ state,x,y
2
+ Alabama,139,-77
3
+ Alaska,-204,-170
4
+ Arizona,-203,-40
5
+ Arkansas,57,-53
6
+ California,-297,13
7
+ Colorado,-112,20
8
+ Connecticut,297,96
9
+ Delaware,275,42
10
+ Florida,220,-145
11
+ Georgia,182,-75
12
+ Hawaii,-317,-143
13
+ Idaho,-216,122
14
+ Illinois,95,37
15
+ Indiana,133,39
16
+ Iowa,38,65
17
+ Kansas,-17,5
18
+ Kentucky,149,1
19
+ Louisiana,59,-114
20
+ Maine,319,164
21
+ Maryland,288,27
22
+ Massachusetts,312,112
23
+ Michigan,148,101
24
+ Minnesota,23,135
25
+ Mississippi,94,-78
26
+ Missouri,49,6
27
+ Montana,-141,150
28
+ Nebraska,-61,66
29
+ Nevada,-257,56
30
+ New Hampshire,302,127
31
+ New Jersey,282,65
32
+ New Mexico,-128,-43
33
+ New York,236,104
34
+ North Carolina,239,-22
35
+ North Dakota,-44,158
36
+ Ohio,176,52
37
+ Oklahoma,-8,-41
38
+ Oregon,-278,138
39
+ Pennsylvania,238,72
40
+ Rhode Island,318,94
41
+ South Carolina,218,-51
42
+ South Dakota,-44,109
43
+ Tennessee,131,-34
44
+ Texas,-38,-106
45
+ Utah,-189,34
46
+ Vermont,282,154
47
+ Virginia,234,12
48
+ Washington,-257,193
49
+ West Virginia,200,20
50
+ Wisconsin,83,113
51
+ Wyoming,-134,90
Original file line number Diff line number Diff line change
1
+
2
+ # US States Game
3
+
4
+
5
+ #### This is a trivia game that uses the turtle module.<br >Can you guess all 50 states of the US?
6
+
7
+
8
+
9
+ ## Requirements
10
+ - Pandas
11
+ - Turtle
12
+
13
+
14
+ ### To install pandas:
15
+
16
+ ```
17
+ pip install pandas
18
+ ```
19
+ ### How to run the file
20
+
21
+ open the terminal and navigate to the path of the file
22
+ ```
23
+ python main.py
24
+
25
+ ```
26
+ ### Sample Output
27
+
28
+ ![ Sample Output] ( https://github.com/sahil-s-246/Python-project-Scripts/blob/sahil-s-246-patch-1/GAMES/Guess%20the%20US%20States/Sample_Output.png )
Original file line number Diff line number Diff line change
1
+ import turtle
2
+ import pandas
3
+
4
+
5
+ df = pandas .read_csv ("50_states.csv" )
6
+ screen = turtle .Screen ()
7
+ screen .title ("U.S. States Game" )
8
+ img_gif = "blank_states_img.gif"
9
+ screen .addshape (img_gif )
10
+ # register the shape
11
+ turtle .shape (img_gif )
12
+ state_list = df .state .to_list ()
13
+ guessed_states = []
14
+
15
+
16
+ def reveal_state (x , y ):
17
+ name = turtle .Turtle ()
18
+ name .hideturtle ()
19
+ name .penup ()
20
+ name .goto (x , y )
21
+ name .write (f"{ ans } " )
22
+
23
+
24
+ while len (guessed_states ) < 50 :
25
+ ans = screen .textinput (title = f" Score: { len (guessed_states )} /50" , prompt = "Name a State: " ).title ()
26
+
27
+ if ans == "exit" .title ():
28
+ correction = [state for state in state_list if state not in guessed_states ]
29
+
30
+ ans_file = pandas .DataFrame (correction )
31
+ ans_file .to_csv ("correct_ans." )
32
+ break
33
+
34
+ # ALl the states you have missed will be written in the correct_ans.csv file
35
+
36
+ if ans in state_list :
37
+ guessed_states .append (ans )
38
+ state_data = df [df .state == ans ]
39
+ x_cor = state_data .x
40
+ y_cor = state_data .y
41
+ reveal_state (int (x_cor ), int (y_cor ))
42
+
43
+
44
+ # def get_mouse_click_coordinate(x, y):
45
+ # print(x, y)
46
+
47
+ # turtle.onscreenclick(get_mouse_click_coordinate)
48
+ # Get turtle coordinates on image
49
+ # These co ordinates were inserted in 50_states.csv
50
+
51
+ screen .exitonclick ()
You can’t perform that action at this time.
0 commit comments