Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<!doctype html>
<!-- The Time Machine GitHub pages theme was designed and developed by Jon Rohan, on Feb 7, 2012. -->
<!-- Follow him for fun. http://twitter.com/jonrohan. Tail his code on https://github.com/jonrohan -->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" href="stylesheets/github-dark.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="javascripts/script.js"></script>
<title>Showcase</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<div class="wrapper">
<header>
<h1 class="title">Showcase</h1>
</header>
<div id="container">
<p class="tagline"></p>
<div id="main" role="main">
<div class="download-bar">
<div class="inner">
<a href="https://github.coventry.ac.uk/cepulisb/showcase" class="code">View Showcase on GitHub</a>
</div>
<span class="blc"></span><span class="trc"></span>
</div>
<article class="markdown-body">
<h1>
<a id="chatbot-project" class="anchor" href="#chatbot-project" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>CHATBOT PROJECT</h1>
<h2>
<a id="introduction" class="anchor" href="#introduction" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>INTRODUCTION</h2>
<h3>
<a id="our-team-bot-was-created-to-do-multifunctional-exercises-such-as" class="anchor" href="#our-team-bot-was-created-to-do-multifunctional-exercises-such-as" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Our team bot was created to do multifunctional exercises such as:</h3>
<ul>
<li>chating with bot in natural language</li>
<li>getting the weather in any locations</li>
<li>taking video form youtube</li>
<li>getting jokes from huge library in the internet</li>
</ul>
<h2>
<a id="choosing-discord" class="anchor" href="#choosing-discord" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>CHOOSING DISCORD</h2>
<p>The bot was created in <a href="https://discordapp.com/">discord</a> app which was the best choice for our team.</p>
<p>As a result we gained easy communication throught the team and it was extremely easy to demonstrate our chatbots and progress each week.</p>
<h2>
<a id="my-part-in-the-team" class="anchor" href="#my-part-in-the-team" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>MY PART IN THE TEAM</h2>
<p>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.</p>
<h2>
<a id="starting" class="anchor" href="#starting" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>STARTING</h2>
<p>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 <a href="https://www.youtube.com/watch?v=_0LXIvLDhBM&amp;t=3s&amp;list=PLzE_B20lY-944hackNm7PVY011B0lPqMI&amp;index=20">YOUTUBE</a> video which also helped me to write first code.</p>
<p><code>EXAMPLE OF MY FIRST CODE</code></p>
<div class="highlight highlight-source-python"><pre><span class="pl-k">def</span> <span class="pl-en">check_for_emoji</span>(<span class="pl-smi"><span class="pl-smi">self</span></span>, <span class="pl-smi">sentence</span>):
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>crying<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:joy:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>cool<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:sunglasses:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>ok<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:ok_hand:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>USA<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:flag_um:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>UK<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:flag_gb:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>really bad<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:poop:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>lithuania<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:flag_lt:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>kiss<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:kissing_heart:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>happy<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:smiley:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>angry<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> ( <span class="pl-s"><span class="pl-pds">"</span>:imp:<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> sentence <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span>cookie<span class="pl-pds">"</span></span>:
<span class="pl-k">return</span> (<span class="pl-s"><span class="pl-pds">"</span>:cookie:<span class="pl-pds">"</span></span>)</pre></div>
<p><img src="photos/emoji.png" alt="emoji example"></p>
<p>This is just simple example how it was working. So the function just checks it out if the user input is the same as values and if it find the similar input then it just prints the emoji.</p>
<h2>
<a id="real-work" class="anchor" href="#real-work" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>REAL WORK</h2>
<p>After few tests with the team we considered to create <a href="https://en.wikipedia.org/wiki/Natural_language_processing">NLP</a>.</p>
<p>At first we tried a bit with <a href="https://rasa.com/docs/nlu/">Rasa_NLU</a> but then we started to create it form the scratch. There my suffer started.</p>
<p>For the first steps I needed to create keywords for my bot that he could understand for what he should answer.</p>
<p><code>EXAMPLE OF THE KEYWORDS</code></p>
<div class="highlight highlight-source-python"><pre><span class="pl-c1">GREETING_KEYWORDS</span> <span class="pl-k">=</span> (<span class="pl-s"><span class="pl-pds">"</span>hello<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>hi<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>greetings<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>sup<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>good evening<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>good morning<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>helo<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>bonjour<span class="pl-pds">"</span></span>, )
<span class="pl-c1">GREETING_RESPONSES</span> <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">"</span>'sup bro<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>hey<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>good morning<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>hello<span class="pl-pds">"</span></span>]
<span class="pl-c1">DOING_KEYWORDS</span> <span class="pl-k">=</span> (<span class="pl-s"><span class="pl-pds">"</span>how are you doing?<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>how are you?<span class="pl-pds">"</span></span>)
<span class="pl-c1">DOING_RESPONSES</span> <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">"</span>I'am doing great<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>I'm doing fine<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>I'm alright<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>I'm doing terrible<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>I'm doing really bad<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>I'm doing bad<span class="pl-pds">"</span></span>]
<span class="pl-c1">ASKING_ABOUT_YOU</span> <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">"</span>And what about you?<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>how bout you?<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>what about you?<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>and you?<span class="pl-pds">"</span></span>]
<span class="pl-c1">JOKES_KEYWORDS</span> <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">"</span>give me jokes<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>joke<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>can u give me joke?<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>can u give me jokes?<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>can you please give me some jokes?<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>jokes<span class="pl-pds">"</span></span>]</pre></div>
<p>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.</p>
<h3>
<a id="problems" class="anchor" href="#problems" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>PROBLEMS</h3>
<p>As in all codes we have some problems there I have them as well.</p>
<p>The first problem with which we encountered was that the bot was reading my <code>GREETING_KEYWORDS</code> as a one word so for example if the <code>KEYWORD</code> was "GOOD EVENING" bot only readed the good and he was not replaying anything, or we needed to change everything including <code>GREETING_KEYWORDS</code> like this.</p>
<p><img src="photos/zodis.png" alt="mistake"></p>
<p>So I founded that the function parameters was wrong because in</p>
<div class="highlight highlight-source-python"><pre><span class="pl-k">def</span> <span class="pl-en">check_for_greeting</span>(<span class="pl-smi"><span class="pl-smi">self</span></span>, <span class="pl-smi">sentence</span>)</pre></div>
<p>I was using not the <code>sentence</code> but the <code>word</code> so after that changes the code was working pretty fine.</p>
<p>Working along I found another small problem where the bot was replaying to its own messages which caused that</p>
<p><img src="photos/atprasymas.png" alt="photo"></p>
<h3>
<a id="what-is-next" class="anchor" href="#what-is-next" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>WHAT IS NEXT?</h3>
<p>Later on I started with the actuall code</p>
<p><code>EXAMPLE OF THE NLU BOT CODE</code></p>
<div class="highlight highlight-source-python"><pre><span class="pl-k">def</span> <span class="pl-en">check_for_greeting</span>(<span class="pl-smi"><span class="pl-smi">self</span></span>, <span class="pl-smi">sentence</span>):
<span class="pl-s"><span class="pl-pds">"""</span>if user write anything from the greeting keyword, the bot response with greeting response<span class="pl-pds">"""</span></span>
<span class="pl-k">if</span> sentence.lower() <span class="pl-k">in</span> <span class="pl-c1">GREETING_KEYWORDS</span>:
<span class="pl-k">return</span> random.choice(<span class="pl-c1">GREETING_RESPONSES</span>)
<span class="pl-k">if</span> sentence.lower() <span class="pl-k">in</span> <span class="pl-c1">DOING_KEYWORDS</span>:
<span class="pl-k">return</span> random.choice(<span class="pl-c1">DOING_RESPONSES</span>) <span class="pl-k">+</span> <span class="pl-s"><span class="pl-pds">"</span>, <span class="pl-pds">"</span></span> <span class="pl-k">+</span> random.choice(<span class="pl-c1">ASKING_ABOUT_YOU</span>)</pre></div>
<p>There we take sentence which is wrote by the user and we use <code>sentence.lower</code> just to prevent our code if the user is writing with the CAPS LOCK.</p>
<p>Later we are checking the input words and if we recognise some from our <code>GREETING_KEYWORDS</code> than bot replays to the user with random response from <code>GREETING_RESPONCES</code> also we do this the same with the <code>DOING_KEYWORDS</code> and <code>DOING_RESPONCES</code>, but there we just add one more step in which bot asks about how the user is doing.</p>
<h2>
<a id="out-of-my-comfort-zone" class="anchor" href="#out-of-my-comfort-zone" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>OUT OF MY COMFORT ZONE</h2>
<p>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 <a href="https://medium.freecodecamp.org/what-is-an-api-in-english-please-b880a3214a82">API</a> but after two days of trying I give up.</p>
<p>After considering I found how to use API in a bit <a href="http://www.icndb.com/api/?fbclid=IwAR3VajjKEy5ZFoMbp9lhnxA97T-CQz4ZKElZRXoaQNTcuA7iePNrVR-s4nI">easier</a> way so I came along with some code</p>
<p><code>API CODE EXAMPLE</code></p>
<div class="highlight highlight-source-python"><pre><span class="pl-k">def</span> <span class="pl-en">check_for_jokes</span>(<span class="pl-smi"><span class="pl-smi">self</span></span>, <span class="pl-smi">sentence</span>):
r <span class="pl-k">=</span> requests.get(<span class="pl-s"><span class="pl-pds">'</span>https://api.icndb.com/jokes/random<span class="pl-pds">'</span></span>)
data <span class="pl-k">=</span> r.json()
ans <span class="pl-k">=</span> data[<span class="pl-s"><span class="pl-pds">"</span>value<span class="pl-pds">"</span></span>][<span class="pl-s"><span class="pl-pds">"</span>joke<span class="pl-pds">"</span></span>]
<span class="pl-k">if</span> sentence.lower() <span class="pl-k">in</span> <span class="pl-c1">JOKES_KEYWORDS</span>:
<span class="pl-k">return</span> ans</pre></div>
<h1>
<a id="the-team" class="anchor" href="#the-team" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>THE TEAM</h1>
<p>Our team had amazing scrum master <a href="https://www.linkedin.com/in/declan-soper-9b0637155/">Declan Soper</a> which had a lot of useful knowledge in team managing which helped us a lot.</p>
<h2>
<a id="members" class="anchor" href="#members" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>MEMBERS</h2>
<p>The team was not that great, but it happens in real world so we had to deal with this problem.</p>
<p>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.</p>
<h2>
<a id="working-with-team" class="anchor" href="#working-with-team" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>WORKING WITH TEAM</h2>
<p>At the team meetings we used team planning throught <a href="https://azure.microsoft.com/en-gb/free/search/?&amp;OCID=AID719823_SEM_EnMuQWKU&amp;lnkd=Google_Azure_Brand&amp;dclid=CKqE6a2Q-t4CFTYj0wodMysECg">azure</a> 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</p>
<p>To make our work faster and easier we did <a href="https://play.planningpoker.com/play/game/cG9f1OFtpYQcDx8AKgv82GyMojAl8ezt">planning poker</a> every week which helped us to consider how much time we will waste on different chatbot codes.</p>
<p>Also we used <a href="https://github.coventry.ac.uk/">github</a> which helped to combine our codes together and also to have our codes anywhere we go.</p>
</article>
</div>
</div>
<footer>
<div class="owner">
<p><a href="https://github.coventry.ac.uk/cepulisb" class="avatar"><img src="https://github.coventry.ac.uk/avatars/u/2811?s=60" width="48" height="48"></a> <a href="https://github.coventry.ac.uk/cepulisb">cepulisb</a> maintains <a href="https://github.coventry.ac.uk/cepulisb/showcase">Showcase</a></p>
</div>
<div class="creds">
<small>This page generated using <a href="https://pages.github.com/">GitHub Pages</a><br>theme by <a href="https://twitter.com/jonrohan/">Jon Rohan</a></small>
</div>
</footer>
</div>
<div class="current-section">
<a href="#top">Scroll to top</a>
<a href="https://github.coventry.ac.uk/cepulisb/showcase/tarball/master" class="tar">tar</a><a href="https://github.coventry.ac.uk/cepulisb/showcase/zipball/master" class="zip">zip</a><a href="" class="code">source code</a>
<p class="name"></p>
</div>
</body>
</html>