Skip to content
Permalink
Browse files
<photos>
  • Loading branch information
cepulisb committed Nov 29, 2018
1 parent c05797f commit a40b702882c3ab76a324760c770fcbce9017e43d
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
@@ -0,0 +1,152 @@
# CHATBOT PROJECT
## INTRODUCTION
### Our team bot was created to do multifunctional exercises such as:
- chating with bot in natural language
- getting the weather in any locations
- taking video form youtube
- getting jokes from huge library in the internet

## CHOOSING DISCORD
The bot was created in [discord](https://discordapp.com/) app which was the best choice for our team.

As a result we gained easy communication throught the team and it was extremely easy to demonstrate our chatbots and progress each week.

## MY PART IN THE TEAM

In the beginning it was hard for me to get used to discord and creating the bot because other team members was already had a bit of practice with it and for me it was the first time.

## STARTING

For the beginning I started with creating my own bot which was not that hard when the internet is full of information how to do it. For the beginning I choosed the [YOUTUBE](https://www.youtube.com/watch?v=_0LXIvLDhBM&t=3s&list=PLzE_B20lY-944hackNm7PVY011B0lPqMI&index=20) video which also helped me to write first code.

```EXAMPLE OF MY FIRST CODE```
```python
def check_for_emoji(self, sentence):
if sentence == "crying":
return (":joy:")
if sentence == "cool":
return (":sunglasses:")
if sentence == "ok":
return (":ok_hand:")
if sentence == "USA":
return (":flag_um:")
if sentence == "UK":
return (":flag_gb:")
if sentence == "really bad":
return (":poop:")
if sentence == "lithuania":
return (":flag_lt:")
if sentence == "kiss":
return (":kissing_heart:")
if sentence == "happy":
return (":smiley:")
if sentence == "angry":
return ( ":imp:")
if sentence == "cookie":
return (":cookie:")
```
![emoji example](photos/emoji.png)






## REAL WORK

After few tests with the team we considered to create [NLP](https://en.wikipedia.org/wiki/Natural_language_processing).

At first we tried a bit with [Rasa_NLU](https://rasa.com/docs/nlu/) but then we started to create it form the scratch. There my suffer started.

For the first steps I needed to create keywords for my bot that he could understand for what he should answer.

```EXAMPLE OF THE KEYWORDS```
```python
GREETING_KEYWORDS = ("hello", "hi", "greetings", "sup", "good evening","good morning","helo", "bonjour", )
GREETING_RESPONSES = ["'sup bro", "hey", "good morning", "hello"]
DOING_KEYWORDS = ("how are you doing?", "how are you?")
DOING_RESPONSES = ["I'am doing great","I'm doing fine","I'm alright","I'm doing terrible", "I'm doing really bad","I'm doing bad"]
ASKING_ABOUT_YOU = ["And what about you?", "how bout you?","what about you?", "and you?"]
JOKES_KEYWORDS = ["give me jokes", "joke", "can u give me joke?", "can u give me jokes?","can you please give me some jokes?", "jokes"]
```

So I done this just because when you write something for the bot and if your word is the same as input words then the bot replay for you with given outcome words
There I used lists for outcome words and tuples for the income
words.

### PROBLEMS

As in all codes we have some problems there I have them as well.

The first problem with which we encountered was that the bot was reading my ```GREETING_KEYWORDS``` as a one word so for example if the ```KEYWORD``` was "GOOD EVENING" bot only readed the good and he was not replaying anything, or we needed to change everything including ```GREETING_KEYWORDS``` like this.

![mistake](photos/zodis.png)

So I founded that the function parameters was wrong because in

```python
``` def check_for_greeting(self, snetence)
```
I was using not the ```sentence``` but the ```word``` so after that changes the code was working pretty fine.

Working along I found another small problem where the bot was replaying to its own messages which caused that

![photo](photos/atprasymas.png)


### WHAT IS NEXT?

Later on I started with the actuall code

``` EXAMPLE OF THE NLU BOT CODE```
```python
def check_for_greeting(self, sentence):
"""if user write anything from the greeting keyword, the bot response with greeting response"""
if sentence.lower() in GREETING_KEYWORDS:
return random.choice(GREETING_RESPONSES)
if sentence.lower() in DOING_KEYWORDS:
return random.choice(DOING_RESPONSES) + ", " + random.choice(ASKING_ABOUT_YOU)
```

There we take sentence which is wrote by the user and we use ```sentence.lower``` just to prevent our code if the user is writing with the CAPS LOCK.

Later we are checking the input words and if we recognise some from our ```GREETING_KEYWORDS``` than bot replays to the user with random response from ```GREETING_RESPONCES``` also we do this the same with the ```DOING_KEYWORDS``` and ```DOING_RESPONCES```, but there we just add one more step in which bot asks about how the user is doing.

## OUT OF MY COMFORT ZONE

For my next code I really needed to get out of my comfort zone and do what makes me a bit sick. I was reading a lot of pages how to use [API](https://medium.freecodecamp.org/what-is-an-api-in-english-please-b880a3214a82) but after two days of trying I give up.

After considering I found how to use API in a bit [easier](http://www.icndb.com/api/?fbclid=IwAR3VajjKEy5ZFoMbp9lhnxA97T-CQz4ZKElZRXoaQNTcuA7iePNrVR-s4nI) way so I came along with some code

```API CODE EXAMPLE```
```python
def check_for_jokes(self, sentence):
r = requests.get('https://api.icndb.com/jokes/random')
data = r.json()
ans = data["value"]["joke"]
if sentence.lower() in JOKES_KEYWORDS:
return ans
```

# THE TEAM


Our team had amazing scrum master [Declan Soper](https://www.linkedin.com/in/declan-soper-9b0637155/) which had a lot of useful knowledge in team managing which helped us a lot.
## MEMBERS
The team was not that great, but it happens in real world so we had to deal with this problem.

One member quit the group or he was just not walking to the lectures another two was attending to some of the lectures but they was not working with the team and the communication with them was extremely hard. So we actually had the three members in our team.
## WORKING WITH TEAM
At the team meetings we used team planning throught [azure](https://azure.microsoft.com/en-gb/free/search/?&OCID=AID719823_SEM_EnMuQWKU&lnkd=Google_Azure_Brand&dclid=CKqE6a2Q-t4CFTYj0wodMysECg) where at first we created a lots of files what we want to do for our team chatbot lately we attached the work for every team member

To make our work faster and easier we did [planning poker](https://play.planningpoker.com/play/game/cG9f1OFtpYQcDx8AKgv82GyMojAl8ezt) every week which helped us to consider how much time we will waste on different chatbot codes.

Also we used [github](https://github.coventry.ac.uk/) which helped to combine our codes together and also to have our codes anywhere we go.
BIN +16.4 KB photos/atprasymas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +42.7 KB photos/emoji.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +51.9 KB photos/zodis.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a40b702

Please sign in to comment.