Placeholder Image

字幕列表 影片播放

  • What's going on?

  • Everybody welcome part four of our chat, but with python intense flute tutorial.

  • Siri's in this tutorial.

  • We're just gonna keep building on the last one.

  • So we've begun kind of pulling out the data that we're interested in.

  • Uh, the other thing I wanted to do real quickly is bring up buff, the buffer ing parameter.

  • So I wrote Buffer here in that file open.

  • He needs to be buffering.

  • And at this point, just to make sure you got it right, you can print the row so far.

  • Oh, Nev 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's wrong.

  • So I'm gonna get rid of that, Does that's gonna be really slow, especially with idol.

  • Um, Now, what we're gonna do is basically, at this point, we've got the information were interested inserting 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 we're 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, five or 15.

  • Especially if you got the entire just torrent dump from Reddit.

  • Or, you know, if you're doing Big Query or something like that, Especially with big query, you could actually throw this into your big query right before he even told the data.

  • You could use a pretty substantial number here.

  • Anyway, I'm gonna go with two for now.

  • Just something more than one.

  • Um, so this is says, basically, somebody saw this comment in somebody somewhere was like, Yeah, and they hit enough.

  • Okay, so yeah.

  • So if scores greater than able to to what we want to do is basically, at that point, we're thinking who 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 scores greater than two, but it has a parent.

  • I d right.

  • What if we already have a reply to that?

  • parent.

  • I d 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, eagles find existing score.

  • We're gonna search for the existing score by parent ideas.

  • So we're gonna search for the parent I d and see if is there a comment in reply to this parent I d.

  • That already has a score greater than, um, greater than our current score.

  • If not, we don't care.

  • If so, we're gonna go ahead and update that row with new reply in the new score and all the other new data.

  • Okay, So, uh, so, yeah, we want to do that.

  • Now.

  • What we want to do is actually create this, uh, find existing store function.

  • So copy that.

  • Come up here defined, find existing score, and basically again, we're gonna search for that by a parent idea.

  • So what we're gonna do is let's just listen.

  • I like the idea of trying, except in return, false if if all else fails.

  • So let's go ahead and pace that that lovely logic in and honestly, a lot of this stuff's gonna remain the same.

  • So let's do it.

  • Yeah, this is, like, almost 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.

  • I t This time we want to do a parent i d where parents I d is equal to blank limit one format, parent.

  • I d see the X que es que el result fetch one None return zero.

  • Otherwise, we returned False.

  • Um and there were two of us.

  • Yeah, I think that's right.

  • Oh, that logics.

  • Right.

  • We'll find out anyway.

  • Uh, 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 gonna be true.

  • So if existing score, then our question is Well, is our current score greater than the existing comment and score?

  • Uh, question mark.

  • Um, And then if it is now, we're thinking, OK, we're ready.

  • Thio possibly insert this data.

  • And in this case, we would actually be updating a row rather than just a straight up insert.

  • Um, Now, the other thing that I want to go ahead and do is, um, create the acceptable data.

  • So because the other thing we're gonna ask before we do an insert is is this even acceptable statement?

  • And in theory, actually, we probably should ask that even like, up here, like before we consider anything else that needs to be acceptable.

  • But let's go and build it real quick.

  • So we're gonna do is, uh, define acceptable.

  • It's gonna take in data, which is gonna be that comment, basically.

  • And then if Len of data dot split and risk a split by space, But we're just gonna tow organize it real quick and see, um, is that length greater than so?

  • We're gonna be doing multiple models here, but one of them is going to require that we bucket to a maximum length of about 50 care 50 words.

  • So I'm gonna say 50 here, but later we might want to modify that a little bit, but anyway or the Len of, um, data is less than one.

  • 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 returned false.

  • LF the Len of the data, for whatever reason, is greater than, like 1000.

  • So it's got more than 1000 characters.

  • Chases are that's something we don't really want.

  • So we're gonna go ahead and return false there as well.

  • LF data equals and here are two versions of, um, comments being removed or deleted.

  • There's deleted.

  • L of data equals deleted or data equals removed.

  • We want to go ahead and return false else.

  • Let's return true.

  • So again, I'm not really sure why.

  • But, um, when Maybe it's like when a user deletes versus when Ahmad deletes or an admin deletes.

  • I don't know, but these two things exist to me.

  • They mean the exact same thing.

  • Okay.

  • Anyway, um, I think this is a good stopping point.

  • We've been building a lot of stuff here, so I'm trying to keep keep my videos from being 20 minutes long beach.

  • So So go and stop here and in the next Victoria will continue kind of building this out.

  • Well, actually, ask you something is acceptable.

  • Um, 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.

  • Well, whatever.

  • Feel free to leave them below.

  • Otherwise I will see you in the next tutorial.

What's going on?

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

確定插入--用深度學習、Python和TensorFlow創建一個哈拉機器人第4頁。 (Determining insert - Creating a Chatbot with Deep Learning, Python, and TensorFlow p.4)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字