tripadvisor package

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

tripadvisor.load(graph: Graph) Graph[source]

Load the Trip Advisor dataset to a given graph object.

Parameters:

graph – an instance of review graph.

Returns:

The graph instance graph.

tripadvisor.reviews() Iterator[dict[str, Any]][source]

Load the Trip Advisor dataset.

Submodules

tripadvisor.cli module

Evaluate a review graph mining algorithm with the Trip Advisor dataset.

Usage: python -m tripadvisor [OPTIONS]

Evaluate a review graph mining algorithm with the Trip Advisor dataset.

Options:
-m, –method [rsd|feagle|fraudar]

name of algorithm. [required]

--loop INTEGER

number of iteration.

--threshold FLOAT

threshold.

--output FILENAME

file path to store results. [Default: stdout]

--param TEXT

key and value a pair of parameters corresponding to the chosen algorithm, connected with ‘=’.

--version

Show the version and exit.

--help

Show this message and exit.

tripadvisor.debug module

This module provides a debug function for the Trip Advisor Dataset.

class tripadvisor.debug.Graph(*args, **kwargs)[source]

Bases: Protocol[RT, PT]

A protocol for a graph object.

property products: list[PT]

A list of products.

property reviewers: list[RT]

A list of reviewers.

class tripadvisor.debug.Product(*args, **kwargs)[source]

Bases: Protocol

A protocol for a product object.

property name: str

The product’s ID.’

property summary: Any

The summary of the reviews for the product.

class tripadvisor.debug.Reviewer(*args, **kwargs)[source]

Bases: Protocol

A protocol for a reviewer object.

property anomalous_score: float

The anomalous score of the reviewer.

property name: str

The reviewer’s ID.’

tripadvisor.debug.print_state(g: ~tripadvisor.debug.Graph, i: int | str, output: ~typing.TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) None[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 return 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>
      "summary": <Summary of the reviews for the product>
   }
}
Parameters:
  • g – Graph instance.

  • i – Iteration number.

  • output – A writable object (default: sys.stdout).

tripadvisor.loader module

This module provides a function to load the Trip Advisor dataset.

class tripadvisor.loader.Graph(*args, **kwargs)[source]

Bases: Protocol[RT, PT]

A protocol class representing a graph object.

This protocol defines the methods required for a class to be used as the graph object in the load function. The graph object facilitates creating reviewers, products, and adding reviews.

add_review(reviewer: RT, product: PT, score: float, time: int | None = None) Any[source]

Adds a review connecting a reviewer to a product with a score and time.

Parameters:
  • reviewer – The reviewer node.

  • product – The product node.

  • score – The score of the review.

  • time – Optional. The time of the review.

new_product(name: str) PT[source]

Creates a new product node in the graph.

Parameters:

name – The name of the product.

Returns:

The created product node.

new_reviewer(name: str, anomalous_score: float | None = None) RT[source]

Creates a new reviewer node in the graph.

Parameters:
  • name – The name of the reviewer.

  • anomalous_score – Optional. The initial anomalous score for the reviewer.

Returns:

The created reviewer node.

tripadvisor.loader.load(graph: Graph) Graph[source]

Load the Trip Advisor dataset to a given graph object.

Parameters:

graph – an instance of review graph.

Returns:

The graph instance graph.

tripadvisor.loader.reviews() Iterator[dict[str, Any]][source]

Load the Trip Advisor dataset.