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")
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)
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)
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')
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()])
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)
def visitResposta(self, ctx: EnquestesParser.RespostaContext): # Retorna el identifiacador de la resposta i els numeros de la resposta c = [x for x in ctx.getChildren()] L = [] for i in range(3, len(c)): L.append(self.visit(c[i])) return ["RESPOSTA"] + [self.visit(c[0])] + L
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)
def visitContingutEnquesta(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] for i in range(len(l)): if l[i].getText() != ' ': G.add_edge(elemP[-1], labelsI[l[i].getText()], color='black') G[elemP[-1]][labelsI[l[i].getText()]]['question'] = -1 G[elemP[-1]][labelsI[l[i].getText()]]['tipus'] = 2 elemP.append(labelsI[l[i].getText()]) G.add_edge(elemP[-1], 'END', color='black') G[elemP[-1]]['END']['tipus'] = 2 G[elemP[-1]]['END']['question'] = -1 #del EnquestesParser
def visitContingutClaus(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] for i in range(len(l)): if l[i].getText() == 'I': labelsA[(labelsI[elemA[-1]], labelsI[str(l[i].getText() + l[i + 1].getText())])] = l[i - 2].getText() G.add_edge(labelsI[elemA[-1]], labelsI[str(l[i].getText() + l[i + 1].getText())], color='green') G[labelsI[elemA[-1]]][labelsI[ str(l[i].getText() + l[i + 1].getText())]]['question'] = l[i - 2].getText() G[labelsI[elemA[-1]]][labelsI[str( l[i].getText() + l[i + 1].getText())]]['tipus'] = 2
def visitContingutResposta(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] G.nodes[elemR[-1]]['info'].append(' ' + str(l[1].getText()))
def visitInfoEnquesta(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] for i in range(len(l)): self.visit(l[i])
def visitContingutAlternativa(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] elemA.append(l[0].getText()) for i in range(len(l)): self.visit(l[i])
def visitAlternativa(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] self.visit(l[4])
def visitRelacioItem(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] labelsI[elemI[-1]] = l[0].getText() labels[(l[0].getText(), l[4].getText())] = elemI[-1] G.add_edge(l[0].getText(), l[4].getText(), color='blue') G[l[0].getText()][l[4].getText()]['tipus'] = 1
def visitItem(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] elemI.append(l[0].getText()) self.visit(l[4])
def visitLlistaRespostes(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] G.nodes[elemR[-1]['possR']].append(int(l[0])) self.visit(l[2])
def visitResposta(self, ctx: EnquestesParser.RespostaContext): l = [x for x in ctx.getChildren()] G.add_node(l[0].getText(), info=[]) elemR.append(l[0].getText()) for i in range(3, len(l)): self.visit(l[i])