Exemple #1
0
    def _process_exp_sense(self, articles, which='test'):
        exp_feat_name = FILE_PATH + '/../tmp/exp.feat'
        expParser = Explicit()
        exp_sense_file = codecs.open(exp_feat_name, 'w', 'utf-8')
        for art in articles:
            for rel in art.exp_relations:
                expParser.print_features(rel, ['xxxxx'], which, exp_sense_file)
        exp_sense_file.close()
        exp_pred = FILE_PATH + '/../tmp/exp.pred'
        Corpus.test_with_opennlp(exp_feat_name, expParser.model_file, exp_pred)

        exp_res = [l.strip().split()[-1] for l in codecs.open(exp_pred, 'r', 'utf-8')]
        rid = 0
        for art in articles:
            for rel in art.exp_relations:
                pred_sense = exp_res[rid]
                rel.sense = [pred_sense]
                rid += 1
Exemple #2
0
    def _process_exp_sense(self, articles, which='test'):
        exp_feat_name = FILE_PATH + '/../tmp/exp.feat'
        expParser = Explicit()
        exp_sense_file = codecs.open(exp_feat_name, 'w', 'utf-8')
        for art in articles:
            for rel in art.exp_relations:
                expParser.print_features(rel, ['xxxxx'], which, exp_sense_file)
        exp_sense_file.close()
        exp_pred = FILE_PATH + '/../tmp/exp.pred'
        Corpus.test_with_opennlp(exp_feat_name, expParser.model_file, exp_pred)

        exp_res = [
            l.strip().split()[-1] for l in codecs.open(exp_pred, 'r', 'utf-8')
        ]
        rid = 0
        for art in articles:
            for rel in art.exp_relations:
                pred_sense = exp_res[rid]
                rel.sense = [pred_sense]
                rid += 1
Exemple #3
0
    def _process_exp_sense(self, articles, which='test'):
        exp_feat_name = FILE_PATH + '/../tmp/exp.feat'
        expParser = Explicit()
        exp_sense_file = open(exp_feat_name, 'w')
        for art in articles:
            for rel in art.exp_relations:
                expParser.print_features(rel, ['Conjunction'], which, exp_sense_file)
        exp_sense_file.close()
        exp_vec = FILE_PATH + '/../tmp/exp.vec'
        exp_pred = FILE_PATH + '/../tmp/exp.pred'
        # Corpus.test_with_svm(exp_feat_name, expParser.feat_map_file, exp_vec, expParser.model_file, exp_pred)
        Corpus.test_with_opennlp(exp_feat_name, expParser.model_file, exp_pred)

        exp_res = [LABEL_SENSES_MAP[l.strip().split()[-1]] for l in open(exp_pred, 'r')]
        rid = 0
        for art in articles:
            for rel in art.exp_relations:
                pred_sense = exp_res[rid]
                rel.sense = [pred_sense]
                rid += 1