示例#1
0
def do(data, canvas, width, g, after=0):
  # ...

  canvas.delete('all')
  chart(data, canvas, width, g)
  canvas.update()
  root.after(after, do, data, canvas, width, g)
示例#2
0
    def OnButtonEigenvaluesButton(self, event):
        self.clear_canvas()
        ch = chart()
        ch.fc = self.canvas

        se = series()
        ch.bind_series(se)
        se.color = "#000000"
        se.data = self.o2.eigenvals

        ch.draw()
示例#3
0
    def OnButtonLoadingsButton(self, event):
        self.clear_canvas()
        ch = chart()
        ch.custom_y_max = 1.
        ch.custom_y_min = -1.
        ch.fc = self.canvas

        pc_s = self.get_pc_s()
        i = 0
        for pc in pc_s:
            se = series()
            ch.bind_series(se)
            se.color = COLORS[i]
            se.data = self.o2.get_loading(pc)

            i += 1

        ch.draw()
示例#4
0
    def OnButtonShowButton(self, event):
        def binder_function(event2):
            event2.shape.spectrum_index = event2.index
            event2.shape.Bind(fc.EVT_FC_LEFT_DOWN, self.on_shape_down)

        pc_s = self.get_pc_s()
        ms = self.get_marker_size()
        idjudge = self.get_idjudge()

        flag_judge = False
        if idjudge > 0:
            self.sl = sentence_lot()
            sl = self.sl
            self.configure_object(sl)
            sl.colors = COLORS
            sl.idjudge = idjudge
            sl.read()
            sl.calculate()

            flag_judge = True

        self.clear_canvas()

        if self.get_dimensions() == 0:
            if len(pc_s) < 2:
                raise error_x("At least 2 PC's are needed!")

            x_pc = pc_s[0]
            y_pc = pc_s[1]

            ch = chart()
            ch.fc = self.canvas

            se = series_marker()
            ch.bind_series(se)
            se.marker_size = ms
            se.binder_function = binder_function
            se.x_values = self.o2.scores[:, x_pc]
            se.y_values = self.o2.scores[:, y_pc]

        else:
            if len(pc_s) < 3:
                raise error_x("At least 3 PC's are needed!")

            x_pc = pc_s[0]
            y_pc = pc_s[1]
            z_pc = pc_s[2]

            ch = chart3d()
            self.ch = ch
            ch.fc = self.canvas

            se = series3d_marker()
            ch.bind_series(se)
            se.marker_size = ms
            se.binder_function = binder_function
            se.x_values = self.o2.scores[:, x_pc]
            se.y_values = self.o2.scores[:, y_pc]
            se.z_values = self.o2.scores[:, z_pc]

        if flag_judge:
            se.colors = sl.get_colors()

        if self.get_dimensions() == 0:
            ch.draw()
        else:
            self.redraw_3d()

        self.set_flag_scores_plot(True)
示例#5
0
  
  # tokens:
  rule("medium", ["email", "text", "im"]),
  rule("entity", ["alice", "bob"]),
  rule("medium_verb", ["between", "to", "from"]),
  rule("topic", ["concert", "rent", "movie"])
]

tokens = in_sequence(["emails", "to", "bob", "about", "movie"])

con = context()
con.compile(flatten(rules))

compiled_rules = con.get_rules()

ch = chart(tokens, compiled_rules)

winners = ch.parse(tokens)

print "rules:"
ch.print_rules()
print
print "symbols:"
ch.print_symbols()

print
print "winners:"

i = 0
for w in sorted(winners):
  print i, "\t", w
示例#6
0
  symbol("buffalo", "Buffalo-born", (2,3)),
  symbol("buffalo", "Bison",        (3,4)),
  symbol("buffalo", "bully",        (4,5)),
  symbol("buffalo", "bully",        (5,6)),
  symbol("buffalo", "Buffalo-born", (6,7)),
  symbol("buffalo", "Bison",        (7,8))
]
    
rules = [
  rule("start", ["sentence"]),
  rule("sentence", ["noun_phrase", "verb", "noun_phrase"], lambda n1, v, n2: flatten_values(["<", n1, "> performs the action ", v, " to <", n2, ">"])),
  rule("noun_phrase", ["noun"]),
  rule("noun_phrase", ["adjective", "noun"], lambda a, n: [n, " with property ", a]),
  rule("noun_phrase", ["noun_phrase", "noun_phrase", "verb"], lambda n1, n2, v: ["<", n1, "> which is ", v, "'d by <", n2, ">"]),
  rule("noun", ["buffalo"]),
  rule("verb", ["buffalo"]),
  rule("adjective", ["buffalo"])
]

ch = chart(tokens, rules)

ch.print_rules()

winners = ch.parse(tokens)

print
print "winners:"
i = 0
for w in sorted(winners):
  print i, "\t", w
  i += 1