Ejemplo n.º 1
0
def make_aggregator(xs, ys):
    dx = Dropdown(description='"X" Axis',
                  values=OrderedDict((describe_field(x), x) for x in xs))
    dy = Dropdown(description='"Y" Axis',
                  values=OrderedDict((describe_field(y), y) for y in ys))
    dx.value = 'perspective'
    dy.value = 'source-schemafamilies'
    c = HBox(children=(dx, dy))
    return c
Ejemplo n.º 2
0
def sentences(pairs, debug, limit=5, _index='lms-test3', kind='query_string'):
    out = StringIO()
    x, x_val = pairs[-2]
    y, y_val = pairs[-1]
    print('<h2>Example LMs</h2>', file=out)
    print('<p>%s: %s, %s: %s</p>' %
          (describe_field(x), x_val, describe_field(y), y_val),
          file=out)

    print('<ul>', file=out)
    for s in index.sentences2(pairs,
                              limit=limit,
                              index=_index,
                              kind=kind,
                              debug=debug):
        print('<li>%s</li>' % s['text'], file=out)
    print('<ul>', file=out)

    return HTML(out.getvalue())
Ejemplo n.º 3
0
    def chart(self, _):
        pp = [[f.value for f in s.children if hasattr(f, 'value')]
              for s in self.sels]
        x, y = [f.value for f in self.agg.children]

        if (self.debug):
            pprint(pp)
            print(x, y)

        title = ', '.join('{}: {}'.format(describe_field(f), v) for f, v in pp)

        c = index.chart(pp,
                        x,
                        y,
                        kind=self.kind,
                        height=self.height,
                        width=self.width)
        c.title(title)

        c.show()
Ejemplo n.º 4
0
    def chart4(self, _):
        self.pairs = pp = [('query', self.sels[0].value)]
        x, y = [f.value for f in self.aggs.children]

        self.x, self.y = x, y

        if (self.debug):
            pprint(pp)
            print(x, y)

        title = ', '.join('{}: {}'.format(describe_field(f), v) for f, v in pp)

        self.data = index.make_chart_data(pp,
                                          x,
                                          y,
                                          op='and',
                                          kind=self.kind,
                                          limit=self.limit,
                                          debug=self.debug)

        self._chart = c = index.chart2(self.data,
                                       height=self.height,
                                       width=self.width)
        c.title(title)

        clear_output(wait=False)

        c.show()

        # Add more widgets here?
        mgs = self.data.mgs
        xs = [unlabel(c) for c in mgs.columns if c.startswith('doc_count')]
        ys = [k for k in mgs.key]
        xd, yd = self.field_chooser.children

        xd.description = x
        xd.values = xs

        yd.description = y
        yd.values = ys
Ejemplo n.º 5
0
    def chart3(self, _):
        pp = [('query', self.sels[0].value)]
        x, y = [f.value for f in self.aggs.children]

        if (self.debug):
            pprint(pp)
            print(x, y)

        title = ', '.join('{}: {}'.format(describe_field(f), v) for f, v in pp)

        self.data = index.make_chart_data(pp,
                                          x,
                                          y,
                                          op='and',
                                          kind=self.kind,
                                          limit=self.limit,
                                          debug=self.debug)

        c = index.chart2(self.data, height=self.height, width=self.width)
        c.title(title)

        clear_output(wait=False)

        c.show()

        # Add more widgets here?
        mgs = self.data.mgs
        xs = [unlabel(c) for c in mgs.columns if c.startswith('doc_count')]
        ys = [k for k in mgs.key]
        sf = SentenceForm(pairs=pp,
                          x=x,
                          xs=xs,
                          y=y,
                          ys=ys,
                          kind=self.kind,
                          debug=self.debug,
                          limit=self.limit)
        sf.display()