# Path: recommender/ratings.py
# POSITIVE = 1
# NEGATIVE = -1
# NEUTRAL = 0
# def NumberToRating(value):


from abc import ABCMeta
from abc import abstractmethod
from recommender import ratings
import math
    feed. This allows us to avoid doing updates for every single new item.

    Args:
      publisher: The publisher that recommended the items.
      num_items: The number of items the publisher recommended.
    """
    for connection in self.connection_store.GetSubscribers(
        publisher, positive=POSITIVE):
      # We do not decay negative weights because getting out of the negative
      # zone should be earned by posting useful content, not just a ton of
      # content that the user ignores.
      if connection.weight <= 0:
        continue
      # This could be calculated using the expected prediction.
      # w = w - a * (hypothesis(subscriber, item) - 0.5) * rating
      # But we simplify.
      weight = self.GetDecayedWeight(connection.weight, num_items)

      self.connection_store.SetWeight(
          connection.user, publisher, POSITIVE, weight, publisher_voted=True)

  def RecommendationAdded(self, user, item, rating):
    """Updates connection weights between users.

    Args:
      user: Who recommended.
      item: What was recommended.
      rating: {1, 0, -1} - positive, neutral or negative - the rating the user
        gave to the item.
    """

# Path: recommender/ratings.py
# POSITIVE = 1
# NEGATIVE = -1
# NEUTRAL = 0
# def NumberToRating(value):


# Path: recommender/connection_trainer.py
from abc import ABCMeta
from abc import abstractmethod
from recommender import ratings
import math

    feed. This allows us to avoid doing updates for every single new item.

    Args:
      publisher: The publisher that recommended the items.
      num_items: The number of items the publisher recommended.
    """
    for connection in self.connection_store.GetSubscribers(
        publisher, positive=POSITIVE):
      # We do not decay negative weights because getting out of the negative
      # zone should be earned by posting useful content, not just a ton of
      # content that the user ignores.
      if connection.weight <= 0:
        continue
      # This could be calculated using the expected prediction.
      # w = w - a * (hypothesis(subscriber, item) - 0.5) * rating
      # But we simplify.
      weight = self.GetDecayedWeight(connection.weight, num_items)

      self.connection_store.SetWeight(
          connection.user, publisher, POSITIVE, weight, publisher_voted=True)

  def RecommendationAdded(self, user, item, rating):
    """Updates connection weights between users.

    Args:
      user: Who recommended.
      item: What was recommended.
      rating: {1, 0, -1} - positive, neutral or negative - the rating the user
        gave to the item.
    """

    if rating == ratings.NEUTRAL: