示例#1
0
 def visitResposta(self, ctx: EnquestesParser.RespostaContext):
     print("Visit Resposta: count=" + str(ctx.getChildCount()))
     g = ctx.getChildren()
     l = [next(g) for i in range(ctx.getChildCount())]
     for x in l:
         print("resposta text=" + x.getText())
     EnquestesVisitor.myGraph.add_node((l[0]).getText(), resposta='')
     EnquestesVisitor.actualNode = (l[0]).getText()
     for y in range(5, ctx.getChildCount()):
         self.visit(l[y])
     values = nx.get_node_attributes(EnquestesVisitor.myGraph, 'resposta')
     EnquestesVisitor.dictAnswers[EnquestesVisitor.actualNode] = values[(
         l[0]).getText()]
     print("options=" + values[(l[0]).getText()])
示例#2
0
 def visitResposta(self, ctx: EnquestesParser.RespostaContext):
     IDResposta = next(ctx.getChildren()).getText()
     n = ctx.getChildren()
     l = [next(n) for i in range((ctx.getChildCount()))]
     resp = ""
     for i in range((ctx.getChildCount())):
         primer = True
         if (i == ctx.getChildCount()-1):
             if (primer):
                 resp = resp+(self.visit(l[i]))
                 primer = False
             else:
                 resp = resp + (" ") + (self.visit(l[i]))
     self.nodeRes.append(IDResposta)
     self.G.add_node(IDResposta, tipus='resposta', r=resp)
     return self.visitChildren(ctx)
示例#3
0
 def visitResposta(self, ctx: EnquestesParser.RespostaContext):
     RID = ctx.getChild(0).getText()
     n = ctx.getChildCount()
     res = []
     for i in range(n - 3):
         res.append(self.visit(ctx.getChild(i + 3)))
     self.G.add_node(RID, content=res, tipo="respuesta")
示例#4
0
    def visitResposta(self, ctx: EnquestesParser.RespostaContext):
        #   Crear nodo Rx con sus respuestas
        g = ctx.getChildren()  #   obtenir els fills [ID : RESPOSTA opcio*]
        fills = ctx.getChildCount()
        l = [next(g) for i in range(fills)]

        q = [self.visit(x) for x in l[3:]]
        self.ast.add_node(l[0].getText(), content=q)
示例#5
0
 def visitResposta(self, ctx: EnquestesParser.RespostaContext):
     l = ctx.getChildren()
     f = [next(l) for i in range(ctx.getChildCount())]
     respostes = {}
     for i in f[3:]:
         k, v = self.visit(i)
         respostes[k] = v
     self.graph.add_node(f[0].getText(), respostes=respostes)
示例#6
0
 def visitResposta(self, ctx: EnquestesParser.RespostaContext):
     num = ctx.getChildCount()
     g = ctx.getChildren()
     L = [next(g) for i in range(num)]
     id = L[0].getText()
     opcions = {}
     for j in range(3, num):
         optnum, opttext = self.visit(L[j])
         opcions[optnum] = opttext
     self.G.add_node(id, res=opcions, type='resposta')
示例#7
0
    def visitResposta(self, ctx: EnquestesParser.RespostaContext):

        if (ctx.getChildCount() == 5):
            g = ctx.getChildren()
            l = [next(g) for i in range(5)]
            self.digraph._node[self.current_resposta]['respostes'].append(
                l[2].getText()[1:-2])
            self.visit(l[4])

        else:
            g = ctx.getChildren()
            l = [next(g) for i in range(3)]
            self.digraph._node[self.current_resposta]['respostes'].append(
                l[2].getText()[1:-2])

        self.visitChildren(ctx)