Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tbp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Nasr
tbp
Commits
1e8cdf0b
Commit
1e8cdf0b
authored
4 years ago
by
Alexis Nasr
Browse files
Options
Downloads
Patches
Plain Diff
code refactoring
parent
2a1858d8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Config.py
+1
-1
1 addition, 1 deletion
src/Config.py
src/FeatModel.py
+16
-14
16 additions, 14 deletions
src/FeatModel.py
src/Mcd.py
+8
-6
8 additions, 6 deletions
src/Mcd.py
with
25 additions
and
21 deletions
src/Config.py
+
1
−
1
View file @
1e8cdf0b
...
@@ -139,7 +139,7 @@ class Config:
...
@@ -139,7 +139,7 @@ class Config:
def
extractFeatVec
(
self
,
FeatModel
):
def
extractFeatVec
(
self
,
FeatModel
):
featVec
=
[]
featVec
=
[]
i
=
0
i
=
0
for
f
in
FeatModel
.
getArray
():
for
f
in
FeatModel
.
get
Feat
Array
():
# print(f, '=', self.getWordFeat(f))
# print(f, '=', self.getWordFeat(f))
featVec
.
append
(
self
.
getWordFeat
(
f
))
featVec
.
append
(
self
.
getWordFeat
(
f
))
i
+=
1
i
+=
1
...
...
This diff is collapsed.
Click to expand it.
src/FeatModel.py
+
16
−
14
View file @
1e8cdf0b
import
numpy
as
np
import
numpy
as
np
class
FeatModel
:
class
FeatModel
:
array
=
[]
nbFeat
=
0
inputVectorSize
=
None
def
__init__
(
self
,
featModFilename
,
dicos
):
def
__init__
(
self
,
featModFilename
,
dicos
):
self
.
featArray
=
self
.
readFeatModelFile
(
featModFilename
)
self
.
inputVectorSize
=
self
.
computeInputSize
(
dicos
)
def
readFeatModelFile
(
self
,
featModFilename
):
try
:
try
:
featModFile
=
open
(
featModFilename
,
encoding
=
'
utf-8
'
)
featModFile
=
open
(
featModFilename
,
encoding
=
'
utf-8
'
)
except
IOError
:
except
IOError
:
print
(
featModFilename
,
"
: ce fichier n
'
existe pas
"
)
print
(
featModFilename
,
"
: ce fichier n
'
existe pas
"
)
exit
(
1
)
exit
(
1
)
featArray
=
[]
for
ligne
in
featModFile
:
for
ligne
in
featModFile
:
(
container
,
position
,
wordFeature
)
=
ligne
.
split
()
(
container
,
position
,
wordFeature
)
=
ligne
.
split
()
# print("container = ", container, "position = ", position, "wordFeature = ", wordFeature)
# print("container = ", container, "position = ", position, "wordFeature = ", wordFeature)
...
@@ -19,14 +22,13 @@ class FeatModel:
...
@@ -19,14 +22,13 @@ class FeatModel:
if
not
wordFeature
in
set
([
'
POS
'
,
'
LEMMA
'
,
'
FORM
'
]):
if
not
wordFeature
in
set
([
'
POS
'
,
'
LEMMA
'
,
'
FORM
'
]):
print
(
"
error while reading featMod file :
"
,
featModFilename
,
"
wordFeature :
"
,
wordFeature
,
"
undefined
"
)
print
(
"
error while reading featMod file :
"
,
featModFilename
,
"
wordFeature :
"
,
wordFeature
,
"
undefined
"
)
exit
(
1
)
exit
(
1
)
self
.
array
.
append
((
container
,
int
(
position
),
wordFeature
))
featArray
.
append
((
container
,
int
(
position
),
wordFeature
))
self
.
nbFeat
+=
1
featModFile
.
close
()
featModFile
.
close
()
self
.
inputVectorSize
=
self
.
computeInputSize
(
dicos
)
return
featArray
def
computeInputSize
(
self
,
dicos
):
def
computeInputSize
(
self
,
dicos
):
inputVectorSize
=
0
inputVectorSize
=
0
for
featTuple
in
self
.
getArray
():
for
featTuple
in
self
.
get
Feat
Array
():
feat
=
featTuple
[
2
]
feat
=
featTuple
[
2
]
inputVectorSize
+=
dicos
.
getDico
(
feat
).
getSize
()
inputVectorSize
+=
dicos
.
getDico
(
feat
).
getSize
()
return
inputVectorSize
return
inputVectorSize
...
@@ -35,19 +37,19 @@ class FeatModel:
...
@@ -35,19 +37,19 @@ class FeatModel:
return
self
.
inputVectorSize
return
self
.
inputVectorSize
def
getNbFeat
(
self
):
def
getNbFeat
(
self
):
return
self
.
nbFeat
return
len
(
self
.
featArray
)
def
getArray
(
self
):
def
get
Feat
Array
(
self
):
return
self
.
a
rray
return
self
.
featA
rray
def
getFeatContainer
(
self
,
featIndex
):
def
getFeatContainer
(
self
,
featIndex
):
return
self
.
a
rray
[
featIndex
][
0
]
return
self
.
featA
rray
[
featIndex
][
0
]
def
getFeatPosition
(
self
,
featIndex
):
def
getFeatPosition
(
self
,
featIndex
):
return
self
.
a
rray
[
featIndex
][
1
]
return
self
.
featA
rray
[
featIndex
][
1
]
def
getFeatWordFeature
(
self
,
featIndex
):
def
getFeatWordFeature
(
self
,
featIndex
):
return
self
.
a
rray
[
featIndex
][
2
]
return
self
.
featA
rray
[
featIndex
][
2
]
def
buildInputVector
(
self
,
featVec
,
dicos
):
def
buildInputVector
(
self
,
featVec
,
dicos
):
inputVector
=
np
.
zeros
(
self
.
inputVectorSize
,
dtype
=
"
int32
"
)
inputVector
=
np
.
zeros
(
self
.
inputVectorSize
,
dtype
=
"
int32
"
)
...
...
This diff is collapsed.
Click to expand it.
src/Mcd.py
+
8
−
6
View file @
1e8cdf0b
class
Mcd
:
class
Mcd
:
array
=
[]
nbCol
=
0
def
__init__
(
self
,
mcdFilename
):
def
__init__
(
self
,
mcdFilename
):
self
.
array
=
self
.
readMcdFile
(
mcdFilename
)
def
readMcdFile
(
self
,
mcdFilename
):
try
:
try
:
mcdFile
=
open
(
mcdFilename
,
encoding
=
'
utf-8
'
)
mcdFile
=
open
(
mcdFilename
,
encoding
=
'
utf-8
'
)
except
IOError
:
except
IOError
:
print
(
mcdFilename
,
"
: ce fichier n
'
existe pas
"
)
print
(
mcdFilename
,
"
: ce fichier n
'
existe pas
"
)
exit
(
1
)
exit
(
1
)
colDescriptionArray
=
[]
for
ligne
in
mcdFile
:
for
ligne
in
mcdFile
:
(
col
,
name
,
type
,
status
)
=
ligne
.
split
()
(
col
,
name
,
type
,
status
)
=
ligne
.
split
()
#print("col = ", col, "name = ", name, "type = ", type, "status =", status)
#print("col = ", col, "name = ", name, "type = ", type, "status =", status)
...
@@ -16,12 +18,12 @@ class Mcd:
...
@@ -16,12 +18,12 @@ class Mcd:
if
(
type
!=
"
INT
"
and
type
!=
"
SYM
"
):
if
(
type
!=
"
INT
"
and
type
!=
"
SYM
"
):
print
(
"
error while reading mcd file :
"
,
mcdFilename
,
"
type :
"
,
type
,
"
undefined
"
)
print
(
"
error while reading mcd file :
"
,
mcdFilename
,
"
type :
"
,
type
,
"
undefined
"
)
exit
(
1
)
exit
(
1
)
self
.
a
rray
.
append
((
int
(
col
),
name
,
type
,
status
))
colDescriptionA
rray
.
append
((
int
(
col
),
name
,
type
,
status
))
mcdFile
.
close
()
mcdFile
.
close
()
self
.
nbCol
=
int
(
col
)
+
1
return
colDescriptionArray
def
getNbCol
(
self
):
def
getNbCol
(
self
):
return
self
.
nbCol
return
len
(
self
.
array
)
def
getArray
(
self
):
def
getArray
(
self
):
return
self
.
array
return
self
.
array
...
@@ -36,7 +38,7 @@ class Mcd:
...
@@ -36,7 +38,7 @@ class Mcd:
return
self
.
array
[
colIndex
][
3
]
return
self
.
array
[
colIndex
][
3
]
def
locateCol
(
self
,
name
):
def
locateCol
(
self
,
name
):
for
colIndex
in
range
(
self
.
n
bCol
):
for
colIndex
in
range
(
self
.
getN
bCol
()
):
if
self
.
array
[
colIndex
][
1
]
==
name
:
if
self
.
array
[
colIndex
][
1
]
==
name
:
return
colIndex
return
colIndex
return
None
return
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment