Commit 4a37ce59 authored by Alexis Nasr's avatar Alexis Nasr
Browse files

code refactoring

parent 25e8bd5c
B -2 POS
B -1 POS
B 0 POS
B 1 POS
B 2 POS
S 0 POS
S 1 POS
W B -2 POS
W B -1 POS
W B 0 POS
W B 1 POS
W B 2 POS
W S 0 POS
W S 1 POS
......@@ -86,9 +86,9 @@ class Config:
return False
def getWordFeat(self, featTuple):
container = featTuple[0]
index = featTuple[1]
tape = featTuple[2]
container = featTuple[1]
index = featTuple[2]
tape = featTuple[3]
if(container == 'B'):
......
......@@ -14,22 +14,22 @@ class FeatModel:
exit(1)
featArray = []
for ligne in featModFile:
(container, position, wordFeature) = ligne.split()
# print("container = ", container, "position = ", position, "wordFeature = ", wordFeature)
(featType, container, position, wordFeature) = ligne.split()
#print("type =", featType, "container = ", container, "position = ", position, "wordFeature = ", wordFeature)
if(container != "B" and container != "S"):
print("error while reading featMod file : ", featModFilename, "container :", container, "undefined")
exit(1)
if not wordFeature in set(['POS', 'LEMMA', 'FORM']):
print("error while reading featMod file : ", featModFilename, "wordFeature :", wordFeature, "undefined")
exit(1)
featArray.append((container, int(position), wordFeature))
featArray.append((featType, container, int(position), wordFeature))
featModFile.close()
return featArray
def computeInputSize(self, dicos):
inputVectorSize = 0
for featTuple in self.getFeatArray():
feat = featTuple[2]
feat = featTuple[3]
inputVectorSize += dicos.getDico(feat).getSize()
return inputVectorSize
......@@ -42,15 +42,18 @@ class FeatModel:
def getFeatArray(self):
return self.featArray
def getFeatContainer(self, featIndex):
def getFeatType(self, featIndex):
return self.featArray[featIndex][0]
def getFeatPosition(self, featIndex):
def getFeatContainer(self, featIndex):
return self.featArray[featIndex][1]
def getFeatLabel(self, featIndex):
def getFeatPosition(self, featIndex):
return self.featArray[featIndex][2]
def getFeatLabel(self, featIndex):
return self.featArray[featIndex][3]
def buildInputVector(self, featVec, dicos):
inputVector = np.zeros(self.inputVectorSize, dtype="int32")
origin = 0
......
......@@ -43,7 +43,7 @@ sys.stderr.write('\n')
mcd = Mcd(mcd_file)
sys.stderr.write('loading dicos\n')
dicos = Dicos(fileName=dicos_file, verbose=False)
dicos = Dicos(fileName=dicos_file)
moves = Moves(dicos)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment