File size: 605 Bytes
aaed6d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import nltk
from operator import itemgetter

class Argument:
    def __init__(self, arg):
        self.words = [x for x in arg[0].strip().split(' ') if x]
        self.posTags = map(itemgetter(1), nltk.pos_tag(self.words))
        self.indices = arg[1]
        self.feats = {}

    def __str__(self):
        return "({})".format('\t'.join(map(str,
                                           [escape_special_chars(' '.join(self.words)),
                                            str(self.indices)])))

COREF = 'coref'

## Helper functions
def escape_special_chars(s):
    return s.replace('\t', '\\t')