review package

Review data model consisting of review and summary.

This module defines abstract review.base.Review and review.base.Summary, and those implementations. review.base.Review represents review itself and review.base.Summary is a summarized reviews given to a same object.

This module assumes each review is representable in one scalar value, and those review values are in a multipliable additive group. With the assumption, this module implements two types of summarization methods. One of them is average of reviews and the other one is making a vector, in other words histogram, of reviews.

This module has the following aliases:

Submodules

review.base module

Defines abstract Review and Summary classes.

class review.base.Review(date=None)[source]

Bases: review.base._MultipliableImmutableAdditiveGroup

Abstruct class of Review.

Review is defined on a multipliable immutable additive group. Subclass must implement the following methods;

  • _eq_:
  • _add_:
  • _rmul_:

Review also needs to implement a property score to return the review score itselt. The returned score must be a float number.

Attribute:
date: the date when this review was posted.
date
score

A float value representing score of this review.

class review.base.Summary[source]

Bases: object

Abstract class of summary of reviews.

Summary only needs to define differenct and norm methods. difference computes difference between a summary and a review. norm maps a summary to a float value.

Each summary type might be related to a review type. Summary must implements a class method review_class to return the associated review class.

difference(r)[source]

Compute a difference between this summary and a given review score.

Parameters:instance of Review. (An) –
Returns:The difference between of the summary and the given review.
classmethod review_class()[source]

A review class associated with this summary.

score

Return a float value representing this summary.

review.histogram module

Implementations of histogram review and summary classes.

class review.histogram.HistoReview(v, quantizer=<built-in function round>, date=None)[source]

Bases: review.base.Review

Vector Review.

inner_product(other)[source]

Inner product of two vectors.

Parameters:other – a HistogramReview instance.
Returns:the inner product between this and the other.
norm()[source]

1-Norm of this vector.

score

A float value representing score of this review.

vector

Raw vector.

class review.histogram.HistoSummary(reviews)[source]

Bases: review.base.Summary

Vector summary.

difference(r)[source]

Compute a difference between this summary and a given review score.

Parameters:instance of Review. (An) –
Returns:The difference between of the summary and the given review.
classmethod review_class()[source]

A review class associated with this summary.

score

Return a float value representing this summary.

review.scalar module

Implementations of scalar review and summary classes.

class review.scalar.AverageReview(v, date=None)[source]

Bases: review.base.Review

Scalar review.

Parameters:v – a float value representing review score.

The review score is a scalar value.

score

A float value representing score of this review.

class review.scalar.AverageSummary(scores)[source]

Bases: review.base.Summary

Scalar summary.

The summary is an average of given reviews.

difference(r)[source]

Difference between this summary and a given review.

Parameters:r – a review.
Returns:a non-negative float value or 0 representing the difference between this summary and the given value.
classmethod review_class()[source]

A review class associated with this summary.

score

Float value representing this summary.

v

Summary score.