equal
deleted
inserted
replaced
959 :param scorefunc: callable expected to take an entity as argument and to |
959 :param scorefunc: callable expected to take an entity as argument and to |
960 return a score >= 0 |
960 return a score >= 0 |
961 """ |
961 """ |
962 def __init__(self, scorefunc, once_is_enough=False): |
962 def __init__(self, scorefunc, once_is_enough=False): |
963 super(score_entity, self).__init__(once_is_enough) |
963 super(score_entity, self).__init__(once_is_enough) |
964 self.score_entity = scorefunc |
964 def intscore(*args, **kwargs): |
|
965 score = scorefunc(*args, **kwargs) |
|
966 if not score: |
|
967 return 0 |
|
968 if isinstance(score, (int, long)): |
|
969 return score |
|
970 return 1 |
|
971 self.score_entity = intscore |