Exemple #1
0
def sample_model(model, chars = 5000):
    try:
        model_path = model.split(';')[0].strip()
        temp = model.split(';')[1].strip()
        words = rnn.run_temperature(model_path, temp, chars).splitlines()[2:-2]
        print model,'generated',len(words)
        return words
    except:
        print traceback.format_exc()
        return []
Exemple #2
0
    model, words = observed_model.strip().splitlines()
    words = words.replace(')', '').replace('(', '').replace(' ', '').split(',')
    for index in models[model]:
        model_sample = training_data[index:index + 100]
        for word in words:
            if word in model_sample:
                line_end = index - 1
                line_start = training_data.rfind('\n', 0, line_end - 1)
                generators.add(training_data[line_start + 1:line_end].strip())

model_scores = {}

for model_temp in generators:
    model = model_temp.split(';')[0].strip()
    temp = model_temp.split(';')[1].replace(':', '').strip()
    words = rnn.run_temperature(model, temp, 1000).splitlines()
    model_scores[model_temp] = score_words(words)

models_score_ordered = map(lambda x: x[0],
                           sorted(model_scores.items(), key=lambda x: x[1]))
models_score_ordered.reverse()

print '\n'.join(models_score_ordered[:5])
sys.exit(0)

#pdb.set_trace()

results = sorted(model_samples.items(), key=lambda x: score(x[1]))
results.reverse()
for result in results:
    print score(result[1])
Exemple #3
0
    model, words = observed_model.strip().splitlines()
    words = words.replace(')','').replace('(','').replace(' ','').split(',')
    for index in models[model]:
        model_sample = training_data[index:index+100]
        for word in words:
            if word in model_sample:
                line_end = index - 1
                line_start = training_data.rfind('\n', 0, line_end - 1)
                generators.add(training_data[line_start+1:line_end].strip())

model_scores = {}

for model_temp in generators:
    model = model_temp.split(';')[0].strip()
    temp = model_temp.split(';')[1].replace(':','').strip()
    words = rnn.run_temperature(model, temp, 1000).splitlines()
    model_scores[model_temp] = score_words(words)

models_score_ordered = map(lambda x:x[0], sorted(model_scores.items(), key = lambda x:x[1]))
models_score_ordered.reverse()

print '\n'.join(models_score_ordered[:5])
sys.exit(0)

#pdb.set_trace()

results = sorted(model_samples.items(), key = lambda x:score(x[1]))
results.reverse()
for result in results:
    print score(result[1])
    print result[0]