Example #1
0
class Service(object):

    def __init__(self):
        """ We need the name later for heuristic stuff """
        self.heuristic = Heuristic(self.__class__.short_name())

    def applies_to_me(self, client, feature_request_type):
        """ Returns true if this service is a potentially relevant to the
            specified client and request type.
        """
        raise NotImplementedError()

    def get_confidence(self, params):
        """ Returns a number between -Inf and +Inf indicating the confidence of
            this service that it is relevant to the specified features.
        """
        return self.heuristic.run_heuristic(params['features']['keywords'])

    def go(self, features):
        """ Returns a response to the specified features, making calls to
            exernal APIs as needed.
        """
        raise NotImplementedError()

    @classmethod
    def short_name(cls):
        name = cls.__name__
        return re.match('(\w+)Service', name).group(1).lower()
Example #2
0
class Service(object):
    def __init__(self):
        """ We need the name later for heuristic stuff """
        self.heuristic = Heuristic(self.__class__.short_name())

    def applies_to_me(self, client, feature_request_type):
        """ Returns true if this service is a potentially relevant to the
            specified client and request type.
        """
        raise NotImplementedError()

    def get_confidence(self, params):
        """ Returns a number between -Inf and +Inf indicating the confidence of
            this service that it is relevant to the specified features.
        """
        return self.heuristic.run_heuristic(params['features']['keywords'])

    def go(self, features):
        """ Returns a response to the specified features, making calls to
            exernal APIs as needed.
        """
        raise NotImplementedError()

    @classmethod
    def short_name(cls):
        name = cls.__name__
        return re.match('(\w+)Service', name).group(1).lower()