Ejemplo n.º 1
0
 def parse(self, input, normalize=True):
     reqs, opts, nots, phrase = self._sort(self._split(input))
     make_clause = self.make_clause
     make_filter_clause = self.make_filter_clause
     
     reqs = [make_clause(text) for text in reqs]
     opts = [make_clause(text) for text in opts]
     nots = [make_filter_clause(text) for text in nots]
     
     pctmatch = int((len(reqs) + len(opts)) * self.minpercent) - len(reqs)
     minmatch = max(pctmatch, self.minmatch - len(reqs), 0)
     
     q = Or(opts, minmatch=minmatch)
     if reqs: q = AndMaybe(And(reqs), q)
     if nots: q = AndNot(q, Or(nots))
     
     if normalize:
         q = q.normalize()
     return q
Ejemplo n.º 2
0
    def parse(self, input, normalize=True):
        reqs, opts, nots, phrase = self._sort(self._split(input))
        make_clause = self.make_clause
        make_filter_clause = self.make_filter_clause

        reqs = [make_clause(text) for text in reqs]
        opts = [make_clause(text) for text in opts]
        nots = [make_filter_clause(text) for text in nots]

        pctmatch = int((len(reqs) + len(opts)) * self.minpercent) - len(reqs)
        minmatch = max(pctmatch, self.minmatch - len(reqs), 0)

        q = Or(opts, minmatch=minmatch)
        if reqs: q = AndMaybe(And(reqs), q)
        if nots: q = AndNot(q, Or(nots))

        if normalize:
            q = q.normalize()
        return q