Posts

playing with nltk to make a chatbot

Image
I had an old bit, from a project in class called 'rabbithole' that I used to have the computer return a made up sentence for a user in the game when they entered data that did not fit any of my if/elif clauses. It was a bit of a mashup text based game.... Anyhoo,  I decided I wanted to explore A.I. and someone I know suggested looking at 'ELIZA': # someone made a javascript web version of her! http://www.masswerk.at/elizabot/ I think the name at the bottom of that link is the author/writer, N. Landsteiner wickipedia: https://en.wikipedia.org/wiki/ELIZA my little mess around with masswerk link: Anyhoo, here's a bit of code where I'm trying to figure out how to use this nltk, and wordnet to process my nouns and verbs so I can return sentences to the user when mine can't find a scripted answer:  (fyi:  there is a bit of work to nltk, it's not just a simple import to get the wordnet and stuff that processes for it) ...

now to profile

So I have my suffix array for the assignment built and tested, but now I need to profile and analyze it's performance... and it looks like I'll need to alter my binary tree to make a significant comparison, which is part of the study drill in the assignment.  The original search tree only looks for an exact match to a given key, so for it to be comparable to my suffix array, it would need to look for the same things... longest, shortest, all...  which just seems crazy.... build a whole other thing to compare it to, but otherwise they are different beasts.  Now if I put the suffix's in the binary tree... and use my match_loop in the tree.... I'm basically just putting the same code into my tree.... Using the tree to store my suffix's... What can I do to make this interesting?  How about....  def test_suffix(): for i in range(0, 100): x = generate_string() spam = SuffixArray_Binary(x) spam.find_longest_binary('g') spam.find_longest_binar...

omerg....

Image
Apparently python can compare strings ....   'dog' > 'cat' ....  True...  HOW THE HELL did I not know this until now???? Update:  I didn't have to do anything....  My binary tree will just sort the keys if they are strings... I'm still playing but... So far, there are no changes needed to the original binary tree..... https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python This little beauty.... !   Had to finess the imports....  but: Finally asked the right questions in class for someone to say,  'hey,  python does that for you....' So off to go get that Binary Search Tree re-written,  and get my suffix array written.  I've been stuck for a while now, because it was just like... WHY?   This is crazy! But python is set up to do this... Just go to write it as such... So I'll post a newer version of that python Binary String search....

knowing when to say, I'm wrong

I did a that bit on Khan today, and thought for sure there was a different better way....  But after hours (all day),  What I came up with was just NOT better, and it was messy and just full of ways it can fail. So,  know when to say,  NOPE...  that way is better.  # lesson learned -again- Example:  A binary spin off I did.  Khan Academy was JavaScript, but I flipped it to python to play with it. ####  my code:  #### def binarySearch(alist, searchitem): max_v = len(alist) - 1 startpoint = max_v//2 count = 0 factor = 2 x = 0 + startpoint # 1(10x.5-5)  2(10x.5 - 3)  3   4     5(10x.5)     6    7   8(10x.5 + 3)  9  10(10x.5+5) while count < startpoint: count += 1 midpoint = x  current = alist[midpoint] if current == searchitem: #print("*" * 15) print(f"searchitem found : count = {count}") return midpoint...

props

I realized today I've never mentioned the online resources like https://www.codecademy.com/  and https://www.khanacademy.org/ ....  For interacting with the codes and just base seeing what they do and getting practice they are invaluable.  I try and visit them whenever I am starting something new, just to get the feel for something. They can't give you the raw feel for the kinds of errors and work that goes into writing a program from an editor and running it in a command prompt to see it in raw form, but to just see stuff in action and get a feel for stuff, they are great. I don't think they are for learning all there is, but as a visual and interactive trainer, I'd recommend them to anyone.  On that note,  I'd say doing stuff from scratch like Zed teaches is fundamental too.  You can't do it without that either. I sometimes wish I could just enroll in college and go get a real 'education' in computer sciences, but life just isn't going ...

Expanding the horizons

Image
Decided I'm going to start looking at other code bases.  C seems really important,  and a database would be really useful.... So, since I've had some practice on Khan academy with SQLite and part of Zed's course is a learn SQL the hard way,  and I have the paperback of the learn C the hard way,  I am all set.  My little victory today: I also need to build a website... I have all the Flask code I wrote for class... I just need to work out how the hell to get it on the internet...  And I still like the idea of static.... And there's so much to learn and do!! I wonder what would happen if I put HTML into the blog page instead of text... <a href="www.nelliesnoodles.com">Goobyboo</a>

tkinter psyillogical game

Not sure if blogger will let me fit all this in... Here it is, but I know it can use some more clean up. It was a lot like pygame so once I got the rythem it wasn't so bad, but some stuff was quite tricky. As always, see something, drop me a note!  I'd love to hear from anyone. The Tkinter file: * pillow not used for game ##  The PIL  and Image stuff was not used, so I took it out, but will use it for the fan-fic game pyGUI1.py from PIL import Image from PIL import ImageTk import tkinter as tk from psychillogical import Questionaire, Psychillogical class MygewyWindow (tk.Frame): def __init__(self, master = None): super(). __init__(master) self.master = master self.special_font = ("helevitca", 16, "bold") self.special_font_8 = ("helevitca", 8, "bold") self.canvas = None self.frame_text = None self.c2_text = None self.m_text = None self.config_frames() self.label_frame() self.config_...