コード例 #1
0
 def evaluate(self, sentences, ex_arcs):
     """LAS on either training or test sets"""
     act_arcs = minibatch_parse(sentences, self, self.config.batch_size)
     ex_arcs = tuple([(a[0], a[1], self.transducer.id2deprel[a[2]])
                      for a in pp] for pp in ex_arcs)
     stdout.flush()
     return score_arcs(act_arcs, ex_arcs)
コード例 #2
0
 def eval(self, sentences, ex_arcs):
     '''LAS on either training or test sets'''
     act_arcs = minibatch_parse(sentences, self, self.config.batch_size)
     ex_arcs = tuple([(a[0], a[1], self.transducer.id2deprel[a[2]]) for a in pp] for pp in ex_arcs)
     if FLAGS.output:
         import json
         with open(FLAGS.output, 'w+') as f:
             for row in act_arcs:
                 f.write('%s\n' % json.dumps(row))
     return score_arcs(act_arcs, ex_arcs)
コード例 #3
0
    def eval(self, sentences, ex_arcs):
        '''LAS on either training or test sets'''
        act_arcs = minibatch_parse(sentences, self, self.config.batch_size)
        ex_arcs = tuple([(a[0], a[1], self.transducer.id2deprel[a[2]])
                         for a in pp] for pp in ex_arcs)
        # code to print a list of arcs. obtained from 2017 bb
        import json
        with open('q2btest.txt', 'w+') as f:
            for row in act_arcs:
                f.write('%s\n' % json.dumps(row))

        return score_arcs(act_arcs, ex_arcs)
コード例 #4
0
    def eval(self, sentences, ex_arcs, isTest=False):
        '''LAS on either training or test sets'''
        act_arcs = minibatch_parse(sentences, self, self.config.batch_size)
        ex_arcs = tuple([(a[0], a[1], self.transducer.id2deprel[a[2]])
                         for a in pp] for pp in ex_arcs)

        if isTest:
            f = open('q2btest.txt', 'w')
            for x in act_arcs:
                f.write("%s\n" % str(x))
            f.close()
        return score_arcs(act_arcs, ex_arcs)
コード例 #5
0
ファイル: model.py プロジェクト: lydavid/CSC485-A3
    def eval(self, sentences, ex_arcs):
        '''LAS on either training or test sets'''
        act_arcs = minibatch_parse(sentences, self, self.config.batch_size)
        ex_arcs = tuple([(a[0], a[1], self.transducer.id2deprel[a[2]])
                         for a in pp] for pp in ex_arcs)

        # TA modification to generate q2b.txt
        import json
        with open('q2btest.txt', 'w+') as f:
            for row in act_arcs:
                f.write('%s\n' % json.dumps(row))

        return score_arcs(act_arcs, ex_arcs)