generative poetry/lyrics
Sep. 20th, 2019 10:21 amI've fiddled with python/language processing stuff the last few evenings. I still don't know what I'm doing. I started out trying to do a really basic thing. I was going to parse sentences and words, store them in a database and store the ID of words that follow them. I guess the idea is kind of like the iphone predictive text feature.
I didn't get far. I started parsing sentences by punctuation and words by spaces.. but then found the NLTK tokenizing stuff, and it was just easier.. mostly.. I ran into the problem of trying to store stuff.. I wanted to iteratively read it into a variable at first, as a step before putting it in SQLite or whatever python can do natively... and, I ran into the thing where I don't understand the way python does (or doesn't do) 2D arrays. This was compounded by my lack of understanding of how to do an iterative loop when the iterator is from the data structure. ie: "data" is a list of sentences. "sentence" seems to be individual elements of that list.. but if I do "for sentence.." and use sentence as an index for a variable, I get told I can't use a string as an index.
I felt like I was doing something for a minute though. not that I really was, I just felt almost competent. lol
while looking up info on NLTK, I found an old post on reddit by a person who wrote something similar to what I want to do.. a poetry remixer is how they describe it. It's waaaaay more advanced than what I envisioned.. but, it doesn't seem to really work right. they shared the distro, and it doesn't seem to have been worked since december. When I ran it, there's a GUI, and it runs showing the background process in console, but it's not doing what the gui says it should be doing. It's fun to watch it though. it seems to be processing a bunch of source texts.. the bible, nietzsche, etc.. then it puts words together based on a rhyme scheme and I think some loose grammar rules. It's kind of like it's thinking. I can only get it to spit out two lines at a time.. and it takes about 5 minutes to run. so far they are all pretty old timey sounding. Anyway. I'm trying to walk through the code, but it's way over my head; spread out over a bunch of files, and not documented at all beyond "this cleans up some things". lol. I reached out to the person.. hopefully they are still around.
I didn't get far. I started parsing sentences by punctuation and words by spaces.. but then found the NLTK tokenizing stuff, and it was just easier.. mostly.. I ran into the problem of trying to store stuff.. I wanted to iteratively read it into a variable at first, as a step before putting it in SQLite or whatever python can do natively... and, I ran into the thing where I don't understand the way python does (or doesn't do) 2D arrays. This was compounded by my lack of understanding of how to do an iterative loop when the iterator is from the data structure. ie: "data" is a list of sentences. "sentence" seems to be individual elements of that list.. but if I do "for sentence.." and use sentence as an index for a variable, I get told I can't use a string as an index.
I felt like I was doing something for a minute though. not that I really was, I just felt almost competent. lol
while looking up info on NLTK, I found an old post on reddit by a person who wrote something similar to what I want to do.. a poetry remixer is how they describe it. It's waaaaay more advanced than what I envisioned.. but, it doesn't seem to really work right. they shared the distro, and it doesn't seem to have been worked since december. When I ran it, there's a GUI, and it runs showing the background process in console, but it's not doing what the gui says it should be doing. It's fun to watch it though. it seems to be processing a bunch of source texts.. the bible, nietzsche, etc.. then it puts words together based on a rhyme scheme and I think some loose grammar rules. It's kind of like it's thinking. I can only get it to spit out two lines at a time.. and it takes about 5 minutes to run. so far they are all pretty old timey sounding. Anyway. I'm trying to walk through the code, but it's way over my head; spread out over a bunch of files, and not documented at all beyond "this cleans up some things". lol. I reached out to the person.. hopefully they are still around.