Beispiel #1
0
 def region_selected(self, regions):
     """Called from JavaScript"""
     if not regions:
         self.regions = []
     if not regions or self.data is None:
         return self.Outputs.corpus.send(None)
     self.regions = regions.split(',')
     attr = self.data.domain[self.selected_attr]
     if attr.is_discrete: return  # TODO, FIXME: make this work for discrete attrs also
     from Orange.data.filter import FilterRegex
     filter = FilterRegex(attr, r'\b{}\b'.format(r'\b|\b'.join(self.regions)), re.IGNORECASE)
     self.Outputs.corpus.send(self.data._filter_values(filter))
Beispiel #2
0
    def test_reprs(self):
        flid = IsDefined(negate=True)
        flhc = HasClass()
        flr = Random()
        fld = FilterDiscrete(self.attr_disc, None)
        flsv = SameValue(self.attr_disc, self.value_disc, negate=True)
        flc = FilterContinuous(self.vs[0], FilterContinuous.Less, 5)
        flc2 = FilterContinuous(self.vs[1], FilterContinuous.Greater, 3)
        flv = Values([flc, flc2], conjunction=False, negate=True)
        flvf = ValueFilter(self.attr_disc)
        fls = FilterString("name", FilterString.Equal, "Aardvark", case_sensitive=False)
        flsl = FilterStringList("name", ["Aardvark"], case_sensitive=False)
        flrx = FilterRegex("name", "^c...$")

        filters = [flid, flhc, flr, fld, flsv, flc, flv, flvf, fls, flsl, flrx]

        for f in filters:
            repr_str = repr(f)
            new_f = eval(repr_str)
            self.assertEqual(repr(new_f), repr_str)