Posts

Showing posts from March, 2018

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_...

wxWidgets and the PopOS

So me and my fellow co-conspirator in class tried to get everything set up from a seminar for linux to use the wxWidgets...  I got stuck when one of the prerequisites was not available on new linux systems and asked for her help. There was a ton to get installed just to start the process of installing the wxWidgets.  In the end we both agreed to stick to tkinter to learn about the python GUI making process on linux. I still have a couple things to clean up and my tkinter code will be up for the psychillogical questionnaire game.  Got really sidetracked today looking at how one might make a window strictly with python.  Looks like it would be near impossible, and extremely unwise to try.  ((this kinda makes me want to try even more.)) Dug a little bit into the pieces of tkinter... it uses TC (I can't find a link now that references the use of TC)  and TCL to do all the work... so I found a way to download some TCL source code.... Woah... nope, I don't ...

more gewy progress

Image
First a little note for those with slow/low mem computers trying out tkinter: This made my computer crash in many ways as I meddled with it trying to fix it to do what I wanted. That part with *add_cascade*  yeah,  if you set that menu=the master menu, this case navbargame... it will make your computer freak out.  Not sure what the python compiler did with it to make it do that.... but I have a feeling it was trying to build something way too much for my memory to handle. K, pictures!  start of game: Question, with a response from the previous answer... questions 4-11 have a response for A, B, C, D, E  that is unique for each question.   1-4 only respond to A, B, C, D..  (I'm going to add something for E,  in number 1 - 4, no biggie, just haven't done it yet.)  The end of the game gives you a score:  I have a much more involved score for the original psychillogical game,  I...