Commit bdfabee0 authored by Michael Murtaugh's avatar Michael Murtaugh

merge

parents ffcd27e1 5e78ba09
This diff is collapsed.
Piano Concerto No. 2 in C minor, Op. 18, 1901 https://ia700809.us.archive.org/14/items/RachmaninoffPlaysRachmaninoff/LeopoldStokowskiWithThePhiladelphiaSymphonyOrchestra_HMV_RachmaninoffConcertoNo2InCMinor_Side01.ogg
Piano Concerto No. 4 in G minor, Op. 40, 1926, revised in 1941 https://ia601004.us.archive.org/14/items/RACHMANINOFFPianoConcertoNo.4-NEWTRANSFER/01.I.AllegroVivace.ogg
Rhapsody on a Theme of Paganini, 1934 https://ia600605.us.archive.org/1/items/RachmaninoffRhapsodyOnAThemeOfPaganini-NewTransfer/Rachmaninoff-RhapsodyOnAThemeOfPaganiniOp.43.ogg
Polichinelle Op 3 No 4, 1892, Transferred from the original 78 rpm record. The work was created & performed by himself Sergei Rachmaninoff. Recorded in March 1923. Victor Talking Machine Label. https://archive.org/download/RachmanioffPolichinelleOp3No4SergeiRachmanioff78Transfer/Rachmanioff%20Polichinelle%20Op%203%20No%204%20-%20Sergei%20Rachmanioff%2078%20transfer.ogg
Symphony No. 2 in E minor, Op. 27, 1908, https://ia700408.us.archive.org/12/items/uso20000304/uso20000304-01-rachmaninoff-symph2-mvtI.ogg
Piano Sonata No. 2, Op. 36, 1913, revised in 1931 https://archive.org/download/RachmaninoffSecondSonataOzanMarshPianistliveInConcertRecording/Rachmaninoff2ndSonataOzanMarshliveInConcert1985CrowderHallTucsonArizona.ogg
Prelude in G Minor, Op. 23, No. 5, Played by Rachmaninoff in 1923, 1901-1903 https://archive.org/download/VrsAcoustics-74628-SergeiRachmaninoff/Rachmaninoff_74628.ogg
This diff is collapsed.
......@@ -12,27 +12,27 @@ import irc.bot
# path to texts
#beatrix = "01_beatrix.txt"
peter = "/Beatrixbotter/behaviour/1_peter_rabbit.txt"
benjamin = "/Beatrixbotter/behaviour/2_benjamin_bunny.txt"
flopsy = "/Beatrixbotter/behaviour/3_flopsy_bunnies.txt"
tod = "/Beatrixbotter/behaviour/4_mr_tod.txt"
tom = "/Beatrixbotter/behaviour/5_tom_kitten.txt"
samuel = "/Beatrixbotter/behaviour/6_roly_poly_pudding.txt"
pie = "/Beatrixbotter/behaviour/7_pie_and_patty_pan.txt"
ginger = "/Beatrixbotter/behaviour/8_ginger_and_pickles.txt"
moppet = "/Beatrixbotter/behaviour/9_miss_moppet.txt"
nutkin = "/Beatrixbotter/behaviour/10_squirrel_nutkin.txt"
timmy = "/Beatrixbotter/behaviour/11_timmy_tiptoes.txt"
tailor = "/Beatrixbotter/behaviour/12_tailor_gloucester.txt"
johnny = "/Beatrixbotter/behaviour/13_johnny_townmouse.txt"
mice = "/Beatrixbotter/behaviour/14_two_bad_mice.txt"
tittlemouse = "/Beatrixbotter/behaviour/15_mrs_tittlemouse.txt"
tiggy = "/Beatrixbotter/behaviour/16_tiggy_winkle.txt"
rabbit = "/Beatrixbotter/behaviour/17_fierce_bad_rabbit.txt"
jemima = "/Beatrixbotter/behaviour/18_jemima_puddleduck.txt"
jeremy = "/Beatrixbotter/behaviour/19_jeremy_fisher.txt"
robinson = "/Beatrixbotter/behaviour/20_little_pig_robinson.txt"
pigling = "/Beatrixbotter/behaviour/21_pigling_bland.txt"
peter = "Beatrixbotter/behaviour/tales/1_peter_rabbit.txt"
benjamin = "Beatrixbotter/behaviour/tales/2_benjamin_bunny.txt"
flopsy = "Beatrixbotter/behaviour/tales/3_flopsy_bunnies.txt"
tod = "Beatrixbotter/behaviour/tales/4_mr_tod.txt"
tom = "Beatrixbotter/behaviour/tales/5_tom_kitten.txt"
samuel = "Beatrixbotter/behaviour/tales/6_roly_poly_pudding.txt"
pie = "Beatrixbotter/behaviour/tales/7_pie_and_patty_pan.txt"
ginger = "Beatrixbotter/behaviour/tales/8_ginger_and_pickles.txt"
moppet = "Beatrixbotter/behaviour/tales/9_miss_moppet.txt"
nutkin = "Beatrixbotter/behaviour/tales/10_squirrel_nutkin.txt"
timmy = "Beatrixbotter/behaviour/tales/11_timmy_tiptoes.txt"
tailor = "Beatrixbotter/behaviour/tales/12_tailor_gloucester.txt"
johnny = "Beatrixbotter/behaviour/tales/13_johnny_townmouse.txt"
mice = "Beatrixbotter/behaviour/tales/14_two_bad_mice.txt"
tittlemouse = "Beatrixbotter/behaviour/tales/15_mrs_tittlemouse.txt"
tiggy = "Beatrixbotter/behaviour/tales/16_tiggy_winkle.txt"
rabbit = "Beatrixbotter/behaviour/tales/17_fierce_bad_rabbit.txt"
jemima = "Beatrixbotter/behaviour/tales/18_jemima_puddleduck.txt"
jeremy = "Beatrixbotter/behaviour/tales/19_jeremy_fisher.txt"
robinson = "Beatrixbotter/behaviour/tales/20_little_pig_robinson.txt"
pigling = "Beatrixbotter/behaviour/tales/21_pigling_bland.txt"
# list of texts
texts = [peter, benjamin, flopsy, tod, tom, samuel, pie, ginger, moppet, nutkin, timmy, tailor, johnny, mice, tittlemouse,
......@@ -41,71 +41,70 @@ tiggy, rabbit, jemima, jeremy, robinson, pigling]
# functions
# random choice of tale
def select(texts):
txt = choice(texts)
return txt
item = choice(texts)
#print "selected txt", item
return item
# gets title from tale
def title(txt):
txt = open(txt).read().decode("utf-8")
nametxt = txt.splitlines()[0]
return nametxt
name = txt.splitlines()[0]
#print "name", name
return name
# gets url from tale
def source(txt):
txt = open(txt).read().decode("utf-8")
url = txt.splitlines()[1]
#print "url", url
return url
# splits text into list of words
def tokenize(txt):
txt = open(txt).read().decode("utf-8")
tokens = ' '.join(line.replace('\n', '') for line in txt)
basket = ' '.join(line.replace('\n', '') for line in txt)
#turn into wordlist
tokens = word_tokenize(txt)
return tokens
basket = word_tokenize(txt)
#print "tokens", basket
return basket
# splits text into list of sentences
def sentences(txt):
txt = ''.join(open(txt).readlines())
phrases = re.split(r' *[\.\?!][\'"\)\]]* *', txt)
return phrases
basket = re.split(r' *[\.\?!][\'"\)\]]* *', txt)
#print "sentences", basket
return basket
# Select sentences that contain keyword
def sentences_with_pick(sentences, pick):
selected_sentences = []
def sentences_with_key(sentences, word):
basket = []
for sentence in sentences:
wordlist = sentence.split(" ")
if pick in wordlist:
if word in wordlist:
sentence = sentence+'.'
selected_sentences.append(sentence)
return selected_sentences
# replace vowels by numbers
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
# Replacements
reps = {'a':'4', 'e':'3', 'i':'1', 'o':'0', 'u':'8'}
basket.append(sentence)
print "sentences_with_key", basket
return basket
def length(msg):
# captures last line in chat
# splits chat message in wordlist
words = msg.split()
# selects from chat message words between 2 and 10 characters
selected = []
basket = []
for word in words:
if len(word) > 3 and len(word) < 10:
selected.append(word)
#print(selected)
if len(word) > 2 and len(word) < 12:
basket.append(word)
print "basket words message", basket
# picks a random word
w = choice(selected)
w = choice(basket)
print "length word", w
w = w.upper()
#print(w)
print "length word capitals", w
# define length keyword
length = len(w)
#print(length)
print "lenght", length
# picks a random tale
txt = select(texts)
# captures title of tale
......@@ -120,28 +119,31 @@ def length(msg):
fin = nltk.Text(tokens)
# selecteer op lengte van woorden
T = set(fin)
words = [x for x in T if len(x) == length]
sorted_words = sorted(words)
basket = [x for x in T if len(x) == length]
sorted_words = sorted(basket)
# picks word of sorted_words
pick = choice(sorted_words)
#print(pick)
print "picked word from tale with right lenght", pick
# Selects sentences in which selected word appears
selected_sentences = sentences_with_pick(phrases, pick)
selected_sentences = sentences_with_key(phrases, pick)
print "length selected sentences with key", selected_sentences
# Shuffles the selected sentences
shuffle(selected_sentences)
# Prints the results
basket = []
if len(selected_sentences) > 0:
pick = pick.upper()
message1 = "The word, " + w + ", counts " + str(length) + " characters. In " + nametxt + " I used the following words of " + str(length) + " characters each: " + ', '.join(sorted_words[:4])
#print(message1)
basket.append(message1)
printsentence = selected_sentences[0]
#print(printsentence)
pick = pick.upper()
message2 = "Take the word, " + pick + ", for example, I used it in this sentence: " + printsentence.replace(pick, pick.upper())
print(message2)
message3 = "Source: " + nametxt
print(message3)
return message1, message2, message3
#print(message2)
basket.append(message2)
#print(message3)
return basket
#msg = e.arguments[0]
......@@ -173,10 +175,9 @@ class MyBot(irc.bot.SingleServerIRCBot):
# captures last line in chat
print e.arguments
msg = e.arguments[0]
message1, message2, message3 = length(msg)
self.say(c, message1)
self.say(c, message2)
self.say(c, message3)
messages = length(msg)
for message in messages:
self.say(c, message)
# Launch bot
if __name__ == "__main__":
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
import nltk, re, pprint
from time import sleep
from pattern.en import tag
from random import choice, random
import pickle
import re
import irc.bot
## this script takes a sentence as input, and generates a new similar sentence
## to make it work you need to run first source.py in order to get a pickledump called 'source.p'
# # 1. get a sentence as input
# sentence = raw_input('Please enter a sentence : ')
# # define punctuation
# q = re.compile('^[ ?]*[?][ ?]*$')
# e = re.compile('^[ !]*[!][ !]*$')
# if q.match(sentence):
# punct = "?"
# elif e.match(sentence):
# punct = "!"
# else:
# punct = "."
# 2. tag input sentence
def tagger_only(words):
inputtags = []
# split sentence into list of words
for word in words:
# create list with tuple of word/tag
analise = tag(word)
#selects tuple from list
tagged_token = analise[0]
# selects tag from tuple and adds it to new list
inputtags.append(tagged_token[1])
return inputtags
## 3. compare list of inputtags to keys of the saved dictionary 'source.p' and get their value
# import tags dictionary
# def pickled():
# tags = open('source.p', 'rb')
# tags_pkld = pickle.load(tags)
# #print tags_pkld
# tags.close()
# return tags_pkld
# # look for value and add to list
collection = []
possible_words = []
mirror = []
tags_pkld = {}
tags = open('Beatrixbotter/behaviour/tales/source.p', 'rb')
tags_pkld = pickle.load(tags)
#print "tagsplickled",tags_pkld
tags.close()
def value(inputtags):
ret = []
for searchtag in inputtags:
possible_words = [key for key, value in tags_pkld.items() if value == searchtag]
#print "possible_words", possible_words
#print 'tags_pkld', tags_pkld
ret.append(possible_words)
return ret
def parody(collection):
ret = []
for col in collection:
pick = choice(col)