Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy
- from numpy import matrix
- from numpy import linalg
- import itertools
- from pprint import pprint
- import random
- m = matrix( [
- ['Robot','Cyborg','Andoid', 'Bot', 'Droid'],
- ['Character','Concept','Mechanical Person', 'Artificial Intelligence', 'Mascot'],
- ['Downloadable','Stock','3d', 'Digital', 'Robotics'],
- ['Clipart','Illustration','Render', 'Image', 'Graphic'],
- ])
- used = []
- i = 0
- def make_sentence(m, used):
- sentence = []
- i = 0
- while i <= 3:
- word = m[i,random.randrange(0,4)]
- sentence.append(word)
- i = i+1
- return ' '.join(sentence)
- def is_used(sentence, used):
- if sentence not in used:
- return False
- else:
- return True
- sentences = []
- i = 0
- while i <= 1000:
- sentence = make_sentence(m, used)
- if(is_used(sentence, used)):
- continue
- else:
- sentences.append(sentence)
- print str(i) + ' ' +sentence
- used.append(sentence)
- i = i+1
- import itertools
- mx = [
- ['Robot','Cyborg','Andoid', 'Bot', 'Droid'],
- ['Character','Concept','Mechanical Person', 'Artificial Intelligence', 'Mascot'],
- ['Downloadable','Stock','3d', 'Digital', 'Robotics'],
- ['Clipart','Illustration','Render', 'Image', 'Graphic'],
- ]
- for combination in itertools.product(*mx):
- print combination
- def make_sentences(m, choices = []):
- output = []
- if len(choices) == 4:
- sentence = ""
- i = 0
- #Go through the four rows of the matrix
- #and choose words for the sentence
- for j in choices:
- sentence += " " + m[i][j]
- i += 1
- return [sentence] #must be returned as a list
- for i in range(0,4):
- output += make_sentences(m, choices+[i])
- return output #this could be changed to a yield statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement