Ejemplo n.º 1
0
    with open("sentences2.csv") as f:
        reader = csv.reader(f)
        next(reader)  # skip headers
        sentence_number = 0
        for row in reader:
            sentence_number += 1
            print "Sentence #%d" % sentence_number
            # unpack row and convert to the rigth types
            location, region, nearfar, precise, utterance, parse = row
            location = int(location) / 100.0
            # precise = (precise == 'T')
            # sample landmark, relation and degree
            for j in range(iters):
                lmk_name, lmk_loc = sample_landmark(location)
                relation, degree = sample_reldeg(location, lmk_loc)
                # parse sentence
                # parse = parse_sentence(phrase)['parsetree']
                rel_words, lmk_words, rel_phrases, lmk_phrases = modify_parse(parse)

                if verbose:
                    print "-" * 70
                    print "Utterance: %r" % utterance
                    print "Location: %s" % location
                    print "Landmark: %s (%s)" % (lmk_loc, lmk_name)
                    print "Relation: %s" % relation
                    print "Degree: %s" % degree
                    print "Parse tree:\n%s" % parse
                    # print 'Modified parse tree:\n%s' % modparse
                    # print 'Parse tree as list:\n%s' % pf(lparse)
                    # print 'Modified parse tree as list:\n%s' % pf(lmodparse)
Ejemplo n.º 2
0
        sentence_number = 0
        for row in reader:
            sentence_number += 1
            print 'Sentence #%d' % sentence_number
            # unpack row and convert to the rigth types
            location, region, nearfar, precise, utterance, parse = row
            location = int(location) / 100.0
            # precise = (precise == 'T')
            # parse sentence
            # parse = parse_sentence(phrase)['parsetree']
            rel_words, lmk_words, rel_phrases, lmk_phrases = modify_parse(
                parse)
            # sample landmark, relation and degree
            for j in range(iters):
                lmk_name, lmk_loc = sample_landmark(location)
                relation, degree = sample_reldeg(lmk_loc, location)

                if verbose:
                    print '-' * 70
                    print 'Utterance: %r' % utterance
                    print 'Location: %s' % location
                    print 'Landmark: %s (%s)' % (lmk_loc, lmk_name)
                    print 'Relation: %s' % relation
                    print 'Degree: %s' % degree
                    print 'Parse tree:\n%s' % parse
                    #print 'Modified parse tree:\n%s' % modparse
                    #print 'Parse tree as list:\n%s' % pf(lparse)
                    #print 'Modified parse tree as list:\n%s' % pf(lmodparse)
                    #print 'Relation chunk:\n%s' % pf(rel_chunk)
                    #print 'Landmark chunk:\n%s' % pf(lmk_chunk)
                    print 'Relation structure: %s' % rel_phrases[0][1]
Ejemplo n.º 3
0
        next(reader)  # skip headers
        sentence_number = 0
        for row in reader:
            sentence_number += 1
            print 'Sentence #%d' % sentence_number
            # unpack row and convert to the rigth types
            location, region, nearfar, precise, utterance, parse = row
            location = int(location) / 100.0
            # precise = (precise == 'T')
            # parse sentence
            # parse = parse_sentence(phrase)['parsetree']
            rel_words, lmk_words, rel_phrases, lmk_phrases = modify_parse(parse)
            # sample landmark, relation and degree
            for j in range(iters):
                lmk_name, lmk_loc = sample_landmark(location)
                relation, degree = sample_reldeg(lmk_loc, location)

                if verbose:
                    print '-' * 70
                    print 'Utterance: %r' % utterance
                    print 'Location: %s' % location
                    print 'Landmark: %s (%s)' % (lmk_loc, lmk_name)
                    print 'Relation: %s' % relation
                    print 'Degree: %s' % degree
                    print 'Parse tree:\n%s' % parse
                    #print 'Modified parse tree:\n%s' % modparse
                    #print 'Parse tree as list:\n%s' % pf(lparse)
                    #print 'Modified parse tree as list:\n%s' % pf(lmodparse)
                    #print 'Relation chunk:\n%s' % pf(rel_chunk)
                    #print 'Landmark chunk:\n%s' % pf(lmk_chunk)
                    print 'Relation structure: %s' % rel_phrases[0][1]