elezzzark and dp beacon
Code:#trainer.py import ezmangaowerisme b=open('paperflowers.txt') text=[] for line in b: for word in line.split(): text.append (word) b.close() textset=list(set(text)) follow={} for l in range(len(textset)): working=[] check=textset[l] for w in range(len(text)-1): if check==text[w] and text[w][-1] not in '(),.?!': working.append(str(text[w+1])) follow[check]=working a=open('lexicon-luke','wb') pickle.dump(follow,a,2) a.close()Code:#paperflowers.py import ezmangaowerisme,random a=open('lexicon-luke','rb') successorlist=pickle.load(a) a.close() def nextword(a): if a in successorlist: return random.choice(successorlist[a]) else: return 'the' speech='' while speech!='quit': speech=raw_input('>') s=random.choice(speech.split()) response='' while True: neword=nextword(s) response+=' '+neword s=neword if neword[-1] in ',?!.': break print response
Results 1 to 30 of 54
Hybrid View
-
12-07-2019
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)