def __init__(self, rightwalls = [], leftwalls = []): Annotation.__init__(self) self.rightwalls = rightwalls # A list of strokes making up the right walls of the track self.leftwalls = leftwalls #A list of strokes making up the left walls self.centerline = None #Stroke for the centerline self.rebuildCenterline()
def __init__(self, state_graph_anno = None, edge_labels = set([])): Annotation.__init__(self) tm_logger.debug("Creating new turing machine") #Which state we are currently in self.active_state = None #Where on the tape we are currently residing self.tape_idx = -1 #What is currently on the tape self.tape_string = [] #What edge brought us here self.leading_edge = {'edge': None, 'label' : None} #edge ArrowAnno, label TextAnno self.tape_text_anno = None self.tape_box = None #A dictionary mapping edges to their labels. self.edge2labels_map = {} self.labels2edge_map = {} for l in edge_labels: self.assocLabel2Edge(l, None) #A DiGraphAnnotation that keeps track of all of the edges and nodes and their connections self.state_graph_anno = None self.setDiGraphAnno(state_graph_anno)
def __init__(self, tip, tail, headstroke = None, tailstroke = None, direction = 'tail2head', linearity=0): Annotation.__init__(self) self.tip = tip # Point self.tail = tail # Point self.linearity = linearity self.headstroke = headstroke self.tailstroke = tailstroke self.direction = direction # 'tail2head' vs. 'head2tail' for the direction the tail stroke was drawn in
def __init__(self, scale): "Create a Text annotation. text is the string, and scale is an appropriate size" Annotation.__init__(self) self.scale = scale # an approximate "size" for the text self.number = None self.parent = None self.left = None self.right = None self.op = None
def __init__(self, scores): "Create a Rubin annotation." Annotation.__init__(self) #self.type = type # Deprecated #self.accuracy = accuracy Deprecated #self.scale = scale # Deprecated self.scores = scores self.name = "" if len(self.scores) > 0: self.name = scores[0]['symbol']
def __init__(self, text, alternates, stroke_letter_map, scale): """Create a Text annotation. text is the string, stroke_letter_map bins strokes according to the letter they're associated with, e.g. "Hi" : [ [<strokes for 'H'>], [<strokes for 'i'>] ]. scale is an appropriate size alternates is a tuple (indexed by letter) of a list of that letter's alternates""" Annotation.__init__(self) self.text = text # a string for the text assert len(stroke_letter_map) == len(text) self.letter2strokesMap = stroke_letter_map assert scale > 0.0 self.scale = scale # an approximate "size" for the text self.alternates = alternates #([],) * len(text) # a tuple (indexed per letter) of lists of alternate letters
def xml(self): root = Annotation.xml(self) root.attrib['name'] = self.name #root.attrib["type"] = self.type #root.attrib['scale'] = str(self.scale) #root.attrib['accuracy'] = str(self.accuracy) return root
def xml(self): root = Annotation.xml(self) for node_anno in self.node_set: nodeEl = ET.SubElement(root, "node") nodeEl.attrib['id'] = str(node_anno.ident) for edge_anno in self.edge_set: edgeEl = ET.SubElement(root, "edge") edgeEl.attrib['id'] = str(edge_anno.ident) for from_node, connList in self.connectMap.items(): for connEdge, to_node in connList: connEl = ET.SubElement(root, "conn") fid = tid = eid = -1 if from_node is not None: fid = from_node.ident if to_node is not None: tid = to_node.ident if connEdge is not None: eid = connEdge.ident connEl.attrib['from'] = str(fid) connEl.attrib['to'] = str(tid) connEl.attrib['e'] = str(eid) return root
def xml( self ): "Returns an element tree object for the XML serialization of this annotation" root = Annotation.xml(self) root.attrib['circularity'] = str(self.circularity) root.attrib['x'] = str(self.center.X) root.attrib['y'] = str(self.center.Y) root.attrib['radius'] = str(self.radius) return root
def xml(self): root = Annotation.xml(self) root.attrib["text"] = self.text root.attrib['scale'] = str(self.scale) for i, a in enumerate(self.alternates): textEl = ET.SubElement(root, "alt") textEl.attrib['priority'] = str(i) textEl.attrib['text'] = str(a) root.append(textEl) return root
def __init__(self, node_set=None, edge_set=None): Annotation.__init__(self) # DiGraph annotations maintain 3 things: # 1) a list of the nodes (which points to the circle_annos) # 2) a list of the edges (which points to the arrow_annos) # 3) a connectivity map (which is of the form { node_anno: [ (edge_anno, node_anno), (edge_anno, node_anno) ]} # set of circle annotations for nodes if node_set is None: self.node_set = set([]) else: self.node_set = node_set # set of arrow annotations for edges if edge_set is None: self.edge_set = set([]) else: self.edge_set = edge_set # set the map of connections self.connectMap = {}
def xml( self ): "Returns an element tree object for the XML serialization of this annotation" root = Annotation.xml(self) root.attrib['headstroke'] = str(self.headstroke.ident) root.attrib['tailstroke'] = str(self.tailstroke.ident) root.attrib['direction'] = str(self.direction) tail = ET.SubElement(root, "tail") tail.attrib['x'] = str(self.tail.X) tail.attrib['y'] = str(self.tail.Y) tip = ET.SubElement(root, "tip") tip.attrib['x'] = str(self.tip.X) tip.attrib['y'] = str(self.tip.Y) return root
def xml(self): root = Annotation.xml(self) mapEl = ET.SubElement(root, "edge_label_map") for e, labelset in self.edge2labels_map.items(): #edgeEl = e.xml() #edgeEl.tag = "edge" #root.append(edgeEl) edgeEl = ET.SubElement(root, "edge") edgeEl.attrib['id'] = str(e.ident) for l in labelset: e_label = ET.SubElement(mapEl, "m") e_label.attrib['e'] = str(e.ident) e_label.attrib['l'] = str(l.ident) for l, edgeset in self.labels2edge_map.items(): #labelEl = l.xml() #labelEl.tag = "label" #root.append(labelEl) labelEl = ET.SubElement(root, "label") labelEl.attrib['id'] = str(l.ident) leadEdge = self.leading_edge['edge'] if leadEdge is not None: eid = leadEdge.ident else: eid = -1 root.attrib['leading_edge'] = str(eid) #graphEl = self.state_graph_anno.xml() #graphEl.tag = "state_graph" #root.append(graphEl) graphEl = ET.SubElement(root, "state_graph") graphEl.attrib['id'] = str(self.state_graph_anno.ident) return root
def __init__(self, circ, cen, avgDist): Annotation.__init__(self) self.circularity = circ # float self.center = cen # Point self.radius = avgDist # float
def __init__(self, tag): Annotation.__init__(self) self.name = tag
def xml(self): root = Annotation.xml(self) root.attrib['scale'] = str(self.scale) return root
def __init__(self, scale): "Create a Text annotation. text is the string, and scale is an appropriate size" Annotation.__init__(self) self.scale = scale # an approximate "size" for the text
def __init__(self, scale, type, number = 0): "Create a Text annotation. text is the string, and scale is an appropriate size" Annotation.__init__(self) self.scale = scale # an approximate "size" for the text self.type = type self.number = number
def __init__(self, latex): Annotation.__init__(self) # logger.debug("Annotating as %s" % (latex)) self.latex = latex
def xml(self): root = Annotation.xml(self) return root
def __init__(self, corners): Annotation.__init__(self) assert len(corners) == 4, "BoxAnnotation: Wrong number of corners in box annotation." self.corners = list(corners)
def __init__(self, horizArrow, vertArrow): Annotation.__init__(self) self.horizontalArrow = horizArrow self.verticalArrow = vertArrow self.equations = []
def __init__(self, linearity, angle, start_point, end_point ): Annotation.__init__(self) self.linearity = linearity self.angle = angle self.start_point = start_point self.end_point = end_point
def __init__(self, tag, template): Annotation.__init__(self) self.template = template self.name = tag
def __init__(self, text, scale): "Create a Bin annotation. text is the string, and scale is an appropriate size" Annotation.__init__(self) self.text = text # a string for the text self.scale = scale # an approximate "size" for the text self.alternates = [text]
def __init__(self): Annotation.__init__(self) self.dt = 0 self.pattern = [1,1,1,1,1,0,0,0,0,0,2,0,0,0,0,0] self.idx = 0
def __init__(self, tip, tail, linearity=0): Annotation.__init__(self) self.tip = tip # Point self.tail = tail # Point self.linearity = linearity