예제 #1
0
def make_exclude_file(game):
    overlist = []
    gamematix = divisi2.load(game + '.pickle')
    nouns = gamematix.row_labels
    overlist += nouns
    overlist += verb_reader(game+'.inf')
    overlist = [x.lower() for x in overlist]
    return overlist
예제 #2
0
def make_divisi_matrix(filename):
    parsedlist = inform_parser(filename)
    game = filename.split('.')[0]
    thinglist = [(1 if x[3] else -1, english.normalize(x[0].replace('^', "'")), ('right', x[1], english.normalize(x[2].replace('^', "'")))) for x in parsedlist]
    # Write out the confusingly-named overlist. First, the nouns.
    overlist = open(game + '.over', 'w')
    for concept1, rel, concept2, val in parsedlist:
        if rel == 'HasProperty' and concept2 == 'mark_as_thing':
            print >> overlist, concept1
            print concept1

    # Now the verbs.
    verbs = verb_reader(filename)
    for verb in verbs:
        print >> overlist, verb
    overlist.close()

    game_matrix = divisi2.make_sparse(thinglist).normalize_all()
    divisi2.save(game_matrix, game + '.pickle')
    return game_matrix