Пример #1
0
def remix_it(form):       
    ''' Scramble word order, vary how many words get remixed '''
      
    tokens = list(form.output[0:])
    to_mix = []
    
    if len(tokens) > 2:
        to_mix = tokens
    elif len(form.last_five) > 0:
        to_mix = list(form.last_five)
    else: to_mix = tokens    
    
    # Get wave values for each word number possibility
    values = [wave.run() for wdx, wave in enumerate(form.winning_voice.sub_waves) if wdx < len(to_mix)]
    ranges = die.build_range_from_values(values)
    which = die.pick_one(ranges)

    print "Remix Values: " + str(values)      
    print "Re-order how many times? " + str(which)
    
        
    for wdx, word in enumerate(to_mix):
        if wdx < which + 1:  
            idx = random.randrange(0, len(to_mix))
            popped = to_mix.pop(idx)
            if len(to_mix) > 0: idx = random.randrange(0, len(to_mix))
            else: idx = 0
            to_mix.insert(idx, popped)
            
    remixed = to_mix            
    return tuple(remixed)
Пример #2
0
    def __init__(self, duration = 10, mode_ranges = [], wave_ranges = [], mode_idx=-1, mod_freq=-1, wave_idx=-1):
        self.value = 0
        
        # Select a Mode only if there are mode_ranges to select from
        if mode_idx > -1: self.mode_idx = mode_idx
        elif len(mode_ranges) > 0: self.mode_idx = die.pick_one(mode_ranges)
        else: self.mode_idx = -1
        
        # Create Sub-Waves
        # Remix/Repeat: Up to 10
        if self.mode_idx == 0 or self.mode_idx == 1: cap = 10
        # Stutter: 3 options
        elif self.mode_idx == 2: cap =3
        # Elision: 2 options
        elif self.mode_idx == 3 : cap = 2
        # Allit/Rhyme: 1 option
        elif self.mode_idx >= 5: cap = 1
        # Synonymize does not have cap
        else: cap = 0
        
        self.sub_waves_idxes = [die.pick_one(wave_ranges) for i in range(cap)]
        self.sub_waves = [create_wave(idx, random.random()) for idx in self.sub_waves_idxes]

        
        # Modulate Frequency?
        if mod_freq > -1: self.mod_freq = mod_freq
        else: self.mod_freq = random.random()
        
        # Which Wave Function?
        if wave_idx > -1: self.wave_idx = wave_idx
        else: self.wave_idx = die.pick_one(wave_ranges)
                
        # Get the Wave Object
        self.wave = create_wave(self.wave_idx, self.mod_freq)
        
        # Pick a Duration
        self.duration = random.randrange(0, duration, 1)
        # Kick off Duration counter for each voice
        self.counter = 0
    
        print "Mode:" + str(self.mode_idx) + "\tMod Freq:" + str(self.mod_freq) + "\tDuration:" + str(self.duration) + "\tWhich Curve:" + str(self.wave_idx)   
Пример #3
0
def elide_it(form):
    ''' Find collocations, vary whether to return just the 2nd or both words ''' 
     
    tokens = form.output[0:]      
    this = tokens[-1]
    thats = el.get(form.collocations, this)
    
    # Calculate probably of returning one or two-word elision
    values = [wave.run() for wave in form.winning_voice.sub_waves]

    ranges = die.build_range_from_values(values)  
    which = die.pick_one(ranges) + 1

    print "Elision Values: " + str(values)      
    print "1 or 2 words? " + str(which)
    print thats
    
    if which == 1:
        return thats
    else:
        thisthats = []    
        for that in thats:
            thisthats.append((this, that)) 
        return tuple(thisthats)