Nantes Université
Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
L
Lgeval
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Service d'assistance
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
CROHME
Lgeval
Validations
e8f665a7
Valider
e8f665a7
rédigé
il y a 3 ans
par
R
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Made unknown symbol error messages optional for get_MML.
parent
4ed941d2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/lg2txt.py
+23
-10
23 ajouts, 10 suppressions
src/lg2txt.py
avec
23 ajouts
et
10 suppressions
src/lg2txt.py
+
23
−
10
Voir le fichier @
e8f665a7
...
...
@@ -112,6 +112,7 @@ def translateStructure(
symbolMap
,
segId
,
nodeString
,
warnings
=
True
):
"""
Generate a string for a given structure.
"""
strString
=
""
...
...
@@ -150,7 +151,8 @@ def translateStructure(
(
childId
,
relation
)
=
nodeRelationPairs
[
j
]
if
relation
==
nextRelation
:
strString
+=
translate
(
lg
,
childId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
lg
,
childId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
,
warnings
)
match
=
True
break
...
...
@@ -177,7 +179,8 @@ def translateStructure(
(
childId
,
relation
)
=
nodeRelationPairs
[
j
]
if
relation
==
nextRelation
:
strString
+=
translate
(
lg
,
childId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
lg
,
childId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
,
warnings
)
match
=
True
break
...
...
@@ -198,7 +201,7 @@ def translateStructure(
def
translateRelation
(
lg
,
relation
,
nextChildId
,
structureMap
,
segPrimMap
,
edgeMap
,
symbolMap
,
nodeString
lg
,
relation
,
nextChildId
,
structureMap
,
segPrimMap
,
edgeMap
,
symbolMap
,
nodeString
,
warnings
=
True
):
"""
Translate an individual spatial relation.
"""
relString
=
""
...
...
@@ -227,7 +230,8 @@ def translateRelation(
relString
+=
nodeString
elif
nextEntry
==
"
CHILD
"
:
relString
+=
translate
(
lg
,
nextChildId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
lg
,
nextChildId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
,
warnings
)
else
:
relString
+=
replacementTuple
[
i
]
...
...
@@ -235,7 +239,8 @@ def translateRelation(
return
relString
def
translate
(
lg
,
segId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
):
def
translate
(
lg
,
segId
,
segPrimMap
,
edgeMap
,
symbolMap
,
structureMap
,
warnings
=
True
):
"""
Recursively create output for an expression at the object level.
"""
byValue
=
lambda
pair
:
pair
[
1
]
byRel
=
lambda
pair
:
pair
[
0
]
...
...
@@ -260,7 +265,8 @@ def translate(lg, segId, segPrimMap, edgeMap, symbolMap, structureMap):
.
replace
(
"
_I_
"
,
'"'
+
primListString
+
'"'
)
.
replace
(
"
_L_
"
,
label
)
)
sys
.
stderr
.
write
(
"
!! lg2txt Warning: Unknown object label
"
+
label
+
"
\n
"
)
if
warnings
:
sys
.
stderr
.
write
(
"
!! lg2txt Warning: Unknown object label
"
+
label
+
"
\n
"
)
if
segId
in
edgeMap
:
# This node has children - lookup replacement based on sorted labels
...
...
@@ -311,6 +317,7 @@ def translate(lg, segId, segPrimMap, edgeMap, symbolMap, structureMap):
symbolMap
,
segId
,
nodeString
,
warnings
)
if
not
strString
==
""
:
nodeString
=
strString
...
...
@@ -326,6 +333,7 @@ def translate(lg, segId, segPrimMap, edgeMap, symbolMap, structureMap):
symbolMap
,
segId
,
nodeString
,
warnings
)
if
not
strString
==
""
:
nodeString
=
strString
...
...
@@ -339,6 +347,7 @@ def translate(lg, segId, segPrimMap, edgeMap, symbolMap, structureMap):
edgeMap
,
symbolMap
,
nodeString
,
warnings
)
# nodeString += translateRelation(lg, (relation, nextChildId),\
...
...
@@ -355,6 +364,7 @@ def translate(lg, segId, segPrimMap, edgeMap, symbolMap, structureMap):
edgeMap
,
symbolMap
,
nodeString
,
warnings
)
# Lastly, generate string for adjacent symbols on the baseline.
...
...
@@ -369,6 +379,7 @@ def translate(lg, segId, segPrimMap, edgeMap, symbolMap, structureMap):
edgeMap
,
symbolMap
,
nodeString
,
warnings
)
return
nodeString
...
...
@@ -389,7 +400,7 @@ def cleanRows(mmlFile):
return
rowSoup
.
prettify
()
def
lg2mml
(
lg_file
,
mapFile
):
def
lg2mml
(
lg_file
,
mapFile
,
warnings
=
True
):
# RZ: lg_file may actually be a StringIO object
lg
=
Lg
(
lg_file
)
...
...
@@ -444,7 +455,9 @@ def lg2mml(lg_file, mapFile):
# symbolMap, structureMap))
mml_out_raw
.
append
(
translate
(
lg
,
root
,
segmentPrimitiveMap
,
treeEdgeMap
,
symbolMap
,
structureMap
lg
,
root
,
segmentPrimitiveMap
,
treeEdgeMap
,
symbolMap
,
structureMap
,
warnings
)
)
# mml_out = postprocess("\n".join(mml_out_raw))
...
...
@@ -483,7 +496,7 @@ def relabel(lg_NE_string, Map, pattern):
temp
=
temp
.
replace
(
"
,
"
+
source_label
+
"
,
"
,
"
,
"
+
mapped_label
+
"
,
"
)
return
temp
def
get_MML
(
lgString
,
mapFile
,
translateFile
):
def
get_MML
(
lgString
,
mapFile
,
translateFile
,
warnings
=
True
):
# RZ: add ability to use StringIO and avoid writing temp file.
# Create StringIO object
...
...
@@ -491,7 +504,7 @@ def get_MML( lgString, mapFile, translateFile):
intermString
=
preprocess
(
stringIO
,
translateFile
)
intermStringIO
=
StringIO
(
intermString
)
mml_out
=
lg2mml
(
intermStringIO
,
mapFile
)
mml_out
=
lg2mml
(
intermStringIO
,
mapFile
,
warnings
)
return
mml_out
def
main
(
lg_file
,
mapFile
,
translateFile
):
...
...
This diff is collapsed.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter