Determining insert - Creating a Chatbot with Deep Learning, Python, and TensorFlow p.4
Key Takeaways
The video tutorial demonstrates how to create a chatbot with deep learning, Python, and TensorFlow, focusing on determining inserts and building the logic for inputting data into a database.
Full Transcript
what's going on everybody welcome to part four of our chat bot with Python in tensorflow tutorial series in this tutorial we're just gonna keep building on last one so we've begun kind of pulling out the data that we're interested in the other thing I wanted to do real quickly is bring up buff the buffer in parameter so I wrote buffer here in that file open it needs to be buffering and at this point just to make sure you got it right you can print the row so for row in a print row and if you run this you should see you know data flying by okay so make sure that's happening for you that's not happening something is wrong so I'm gonna get rid of that dose that's gonna be really slow especially with idle now what we're going to do is basically at this point we've got the information we're interested in inserting it into our database but should we so the next question is basically first of all like I was saying before I don't want to just insert every comment there's a lot of useless comments on Reddit who'd a thunk but so so basically were gonna have a threshold here we're gonna say if score is greater than or equal to two and you could pick something else I mean I feel like you know even like 5 or 15 especially if you've got the entire just torrent dump from reddit or you know if you're doing bigquery or something like that and especially with bigquery you could actually throw this into your bigquery all right before you even fold the data you can use a pretty substantial number here anyway I'm gonna go with 2 for now just something more than one so this just says basically somebody saw this comment in somebody somewhere was like yeah and they hit ok so yeah so if score is greater than or equal to 2 what we want to do is basically at that point we're thinking hmm we would like to insert this data into our database but what if we already have that a comment you know what if we already have you know basically what if you know that comment score is greater than 2 but it has a parent ID right what if we already have a reply to that parent ID like what if we don't need one and if we do already have a reply basically what we're gonna want to know is like okay well what's the existing score of that comment does this score or this comment have a better score so so we need to find that out so we're gonna say if score is greater than or equal to two we're gonna say existing underscore comments underscore score equals find existing score now we're going to search for the existing score by parent ID so we're going to search for the parent ID and see if is there a comment and reply to this parent ID that already has a score greater than greater than our current score if not we don't care if so we're gonna go ahead and update that row with a new reply in the new score and all the other new data okay so so yeah we want to do that now what we want to do is actually create this find existing score function so I'll copy that I'll come up here define find existing score and basically again we're gonna search for that by parent ID so what we're gonna do is let's just listen I like the idea of try and accept and return false if if all else fails so let's go ahead and paste that that lovely logic in and honestly a lot of this stuff is gonna remain the same so let's do yeah this is like almost an identical function honestly so so so in this case we want to not select comment but we want to select score from parent reply where not comment ID this time we want to do parent ID where parent ID is equal to blank limit one format parent ID see that execute SQL result fetch one none return zero otherwise we return false and then return false yeah I think that's right I hope that logics right we'll find out anyway cool so once we've done that awesome so then we're gonna ask you know if existing comments score so basically if it has any value besides false this is going to be true so if existing score then our question is well is our current score greater than the existing comments score question mark and then if it is now we're thinking okay we're ready to possibly insert this data and in this case we would actually be updating a row rather than just a straight-up insert now the other thing that I want to go ahead and do is create the acceptable data so because the other thing we're gonna ask before we do an insert is is this even an acceptable statement and in theory actually we probably should ask that even like up here like before we consider anything else it needs to be acceptable but let's go ahead and build it real quick so we're gonna do is define acceptable it's gonna take in data which is going to be the comment basically and then if Len of data split and we're split by space but we're just gonna tokenize it real quick and see is that length greater than so that we're going to be doing multiple models here but one of them is going to require that we buck it to a maximum length of about 50 50 words so I'm gonna say 50 here but later we might want to modify that a little bit but anyway for the Len of [Music] data is less than 1 so like let's just say that was like an empty comment for whatever reason maybe someone edited or something like that what we want to do in this case is return false Elif the Len of the data for whatever reason is greater than like a thousand so it's got more than a thousand characters chances are that's something we don't really want so we're gonna go ahead and return false there as well Elif data equals and here are two versions of comments being removed or deleted there's deleted elif data equals deleted or data equals [Music] removed we want to go ahead and return false else let's return true so again I'm not really sure why but when Chi maybe it's like when a user deletes verses when a mod deletes or an admin deletes I don't know but they these two things exist to me they mean the exact same thing okay anyway I think this is a good stopping point we've been building a lot of stuff here so I'm trying not to keep keep my videos from being 20 minutes long each so so we'll go ahead and stop here and in the next tutorial we'll continue kind of building this out will actually ask if something's acceptable and then we'll probably in the next tutorial be able to actually finish this and press go and start populating a database so that's what you guys have to look forward to if you have questions comments concerns will whatever feel free to leave them below otherwise I will see you in the next tutorial
Original Description
Welcome to part 4 of the chatbot with Python and TensorFlow tutorial series. Leading up to this, we've gotten our data and begun to iterate through it. Now we're ready to begin building the actual logic for inputting the data.
Text tutorials and sample code: https://pythonprogramming.net/insert-logic-chatbot-deep-learning-python-tensorflow/
https://pythonprogramming.net/support-donate/
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://www.twitch.tv/sentdex
https://plus.google.com/+sentdex
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
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
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: ML Pipelines
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Want to get started with deep learning
Reddit r/deeplearning
Building a Deepfake Detector From Scratch — What Nobody Tells You
Medium · Deep Learning
Unfolding the Meandering Path: High-Dimensional Invariance and the Flat 2D Plane of Neural…
Medium · Deep Learning
Implementing Neural Style Transfer from Scratch: The Project That Started It All
Medium · Deep Learning
🎓
Tutor Explanation
DeepCamp AI