tripadvisor module

This module provides a loading function of the Trip Advisor Dataset.

It also a helper function, print_state(), to output a state of a graph object. To use both fuctions, the graph object must implement the graph interface.

tripadvisor.load(graph)[source]

Load the Trip Advisor dataset to a given graph object.

The graph object must implement the graph interface.

Parameters:graph – an instance of bipartite graph.
Returns:The graph instance graph.
tripadvisor.print_state(g, i, output=<open file '<stdout>', mode 'w'>)[source]

Print a current state of a given graph.

This method outputs a current of a graph as a set of json objects. Graph objects must have two properties, reviewers and products. Those properties returns a set of reviewers and products respectively. See the graph interface for more information.

In this output format, each line represents a reviewer or product object.

Reviewer objects are defined as

{
   "iteration": <the iteration number given as i>
   "reviewer":
   {
      "reviewer_id": <Reviewer's ID>
      "score": <Anomalous score of the reviewer>
   }
}

Product objects are defined as

{
   "iteration": <the iteration number given as i>
   "reviewer":
   {
      "product_id": <Product's ID>
      "sumarry": <Summary of the reviews for the product>
   }
}
Parameters:
  • g – Graph instance.
  • i – Iteration number.
  • output – A writable object (default: sys.stdout).