from queneau import Assembler, WordAssembler import textwrap corpus = Assembler.load(open("data/minor_planets.min.json"), tokens_in='citation') how_many = 100 for i in range(how_many): sentences = [] names = [] for sentence, source in corpus.assemble("f.l", min_length=3): sentences.append(sentence) names.append(source['name']) # Make a new assembler from the names of the asteroids that were chosen. name_assembler = WordAssembler(names) name = name_assembler.assemble_word() print name for s in textwrap.wrap(" ".join(sentences)): print s if i < how_many - 1: print
import json from queneau import Assembler import textwrap corpus = Assembler.load(open("data/milton_paradise_lost.json"), tokens_in='lines') #print "\n".join(line for line, source in corpus.assemble('0.l')) print "\n".join(line for line, source in corpus.assemble('f.l')) #print "\n".join(line for line, source in corpus.assemble('f.')) #print "\n".join(line for line, source in corpus.assemble('0.')) #print "\n".join(line for line, source in corpus.assemble('.'))
import json from queneau import Assembler import textwrap corpus = Assembler.load(open("data/shakespeare_sonnets.json"), tokens_in='lines') print "\n".join(line for line, source in corpus.assemble('0.l'))
from queneau import Assembler, WordAssembler import textwrap corpus = Assembler.load(open("data/minor_planets.min.json"), tokens_in='citation') how_many = 100 for i in range(how_many): sentences = [] names = [] for sentence, source in corpus.assemble("f.l", min_length=3): sentences.append(sentence) names.append(source['name']) # Make a new assembler from the names of the asteroids that were chosen. name_assembler = WordAssembler(names) name = name_assembler.assemble_word() print name for s in textwrap.wrap(" ".join(sentences)): print s if i < how_many-1: print