Select Git revision
Word.py 1.36 KiB
class Word:
def __init__(self):
self.featDic = {}
self.leftDaughters = []
self.rightDaughters = []
def getFeat(self, featName):
if(not featName in self.featDic):
print('WARNING : feat', featName, 'does not exist')
return None
else:
return self.featDic[featName]
def setFeat(self, featName, featValue):
self.featDic[featName] = featValue
def addLeftDaughter(self, index):
self.leftDaughters.append(index)
def addRightDaughter(self, index):
self.rightDaughters.append(index)
def affiche(self, mcd):
first = True
for columnNb in range(mcd.getNbCol()):
if mcd.getColStatus(columnNb) == 'KEEP':
if first:
first = False
else:
print('\t', end='')
print(self.getFeat(mcd.getColName(columnNb)), end='')
# print('')
@staticmethod
def fakeWordConll():
w = Word()
return w
@staticmethod
def fakeWord(mcd):
w =Word()
for elt in mcd.getArray():
(col, feat, type, status) = elt
w.setFeat(feat, 'ROOT')
w.setFeat('GOV', '0')
return w
@staticmethod
def invalidGov():
return 123456789
@staticmethod
def invalidLabel():
return ''