Comparison Table

Overview Description

The Comparison Tools feature enables users to perform side-by-side comparisons of products within a dataset. This functionality provides a structured view of product attributes, performance metrics, and review insights in a tabular format that highlights similarities and differences. The comparison table helps users make informed decisions by clearly visualizing how products compare across various important dimensions.

This feature is particularly valuable for competitive analysis, product selection, and identifying market opportunities based on product strengths and weaknesses. It requires a valid dataset containing multiple products with comparable attributes.

Swagger Link

API: Comparison Table API

Case Documentation

Case 1: Specific Viewpoint (SPVP)

Description

Generate comparison table based on Specific Viewpoints. Data is aggregated from review_sentence_spvp and returned per viewpoint with positive/negative ratios per product.

Sequence Diagram

sequenceDiagram
    participant User
    participant API as ProductAnalyzerController
    participant Service as SpvpService
    participant Repo as WishlistDatasetHistoryRepository
    participant DB as Database

    Note over User,DB: Step 1: Request SPVP Comparison Table
    User->>API: GET /api/v1/general/analyzer/{wldh_slug}/products/comparison (viewpoint_type=SpecificViewpoint)
    
    Note over API,Repo: Step 2: Validate Dataset
    API->>Repo: findBySlug(wldh_slug)
    Repo-->>API: wishlistDataset
    
    Note over API,Service: Step 3: Aggregate by Specific Viewpoints
    API->>Service: getComparitionTableBySpecificViewpoint(wishlistDataset, params)
    Service->>DB: Query review_sentence_spvp joined with review_sentences
    DB-->>Service: SPVP review data
    
    Note over Service,API: Step 4: Structure Comparison Table
    Service-->>API: Formatted comparison table
    
    Note over API,User: Step 5: Return Response
    API-->>User: 200 OK (Comparison table data)

Steps

Step 1: Request (SPVP)

  • Description: Generate comparison table using Specific Viewpoints
  • Request: GET /api/v1/general/analyzer/{wldh_slug}/products/comparison
  • Parameters:
    • Path: wldh_slug
    • Query:
      • viewpoint_type (required): SpecificViewpoint
      • start_date (required): YYYY-MM-DD
      • end_date (required): YYYY-MM-DD
      • mall_product_ids (optional): comma-separated product IDs
      • base_product_id (optional): base product to include
      • is_noise (optional): true | false
      • all_products (optional, boolean, default: false): when true, response includes raw positive/negative counts per product in addition to rates

Step 2: Validate Dataset

  • Description: System validates that the requested dataset exists
  • Action: Find dataset by slug in the repository
  • Potential errors: Dataset not found

Step 3: Aggregate (SPVP)

  • Description: Aggregate SPVP review sentences by viewpoint
  • Action:
    • Join review_sentence_spvp with review_sentences
    • Group by products and viewpoint_ordinal_number
    • Compute positive/negative percentages per product

Step 4: Structure (SPVP)

  • Description: Structure per-viewpoint rows with per-product positive/negative
  • Output fields per viewpoint:
    • viewpoint_id, viewpoint_name
    • data: map of mall_product_id => { positive, negative }

Step 5: Return Response

  • Description: Return structured comparison table
  • Response example (SPVP, default without totals):
    [
      {
        "viewpoint_id": 515,
        "viewpoint_name": "Price",
        "data": {
          "dogparadise:4589602260099": { "positive": "60.0%(30)", "negative": "40.0%(20)" },
          "1001000497050103287": { "positive": "55.0%(22)", "negative": "45.0%(18)" }
        }
      }
    ]
    
  • Response example (SPVP, with all_products=true):
    [
      {
        "viewpoint_id": 515,
        "viewpoint_name": "Price",
        "data": {
          "dogparadise:4589602260099": {
            "positive": { "rate": "60.0%", "count": 30 },
            "negative": { "rate": "40.0%", "count": 20 },
            "total_count": 50
          },
          "1001000497050103287": {
            "positive": { "rate": "55.0%", "count": 22 },
            "negative": { "rate": "45.0%", "count": 18 },
            "total_count": 40
          }
        }
      }
    ]
    

Case 2: AI Viewpoint

Description

Generate comparison table using AI viewpoints. Data is aggregated by AI viewpoint across selected products.

Sequence Diagram

sequenceDiagram
    participant User
    participant API as ProductAnalyzerController
    participant Service as ProductAnalyzerService
    participant Repo as WishlistDatasetHistoryRepository
    participant DB as Database

    Note over User,DB: Step 1: Request AI Comparison Table
    User->>API: GET /api/v1/general/analyzer/{wldh_slug}/products/comparison (viewpoint_type=AiViewpoint)
 
    Note over API,Repo: Step 2: Validate Dataset
    API->>Repo: findBySlug(wldh_slug)
    Repo-->>API: wishlistDataset
 
    Note over API,Service: Step 3: Aggregate by AI Viewpoints
    API->>Service: comparisonTable(request, wishlistDataset)
    Service->>DB: Query review_sentence_aivp + review_sentences
    DB-->>Service: AI viewpoint review data
 
    Note over Service,API: Step 4: Structure Comparison Table
    Service-->>API: Formatted comparison table
 
    Note over API,User: Step 5: Return Response
    API-->>User: 200 OK (Comparison table data)

Steps

Step 1: Request (AI)

  • Request: GET /api/v1/general/analyzer/{wldh_slug}/products/comparison
  • Parameters:
    • Path: wldh_slug
    • Query:
      • viewpoint_type (required): AiViewpoint
      • start_date (required): YYYY-MM-DD
      • end_date (required): YYYY-MM-DD
      • mall_product_ids (optional): comma-separated product IDs
      • is_noise (optional): true | false
      • all_products (optional, boolean, default: false): when true, response includes raw positive/negative counts per product in addition to rates

Step 2: Aggregate (AI)

  • Description: Aggregate AI viewpoint review sentences
  • Action:
    • Use review_sentence_aivp joined with review_sentences
    • Group by products and AI viewpoint_id
    • Compute positive/negative totals per product

Step 3: Return Response (AI)

  • Response example (default without totals):
    [
      {
        "viewpoint_id": 101,
        "viewpoint_name": "Delivery",
        "data": {
          "dogparadise:4589602260099": { "positive": "62.0%(31)", "negative": "38.0%(19)" }
        }
      }
    ]
    
  • Response example (with all_products=true):
    [
      {
        "viewpoint_id": 101,
        "viewpoint_name": "Delivery",
        "data": {
          "dogparadise:4589602260099": {
            "positive": { "rate": "62.0%", "count": 31 },
            "negative": { "rate": "38.0%", "count": 19 },
            "total_count": 50
          }
        }
      }
    ]
    

Database Related Tables & Fields (SPVP)

erDiagram
    review_sentences {
        bigint id PK
        string mall_product_id
        double sentiment_score
        date post_date
        boolean is_noise
    }
    review_sentence_spvp {
        bigint id PK
        bigint sentence_id FK
        int viewpoint_category_id
        int viewpoint_ordinal_number
    }
    review_sentences ||--o{ review_sentence_spvp : has

Database Related Tables & Fields (AI Viewpoint)

erDiagram
    review_sentences {
        bigint id PK
        string mall_product_id
        double sentiment_score
        date post_date
        boolean is_noise
    }
    review_sentence_aivp {
        bigint id PK
        bigint sentence_id FK
        bigint ai_viewpoint_id FK
        bigint dataset_id FK
    }
    review_sentences ||--o{ review_sentence_aivp : has

Error Handling

  • Log

    • Comparison table generation failures logged to application log
  • Error Detail:

    Status Code Error Message Description
    404 "Dataset not found" When the specified dataset slug does not exist
    400 "Invalid product selection" When invalid product IDs are provided
    400 "Insufficient products for comparison" When fewer than 2 products are selected
    400 Generic error with exception message When unexpected errors occur during processing

Additional Notes

  • For optimal comparison, 2-5 products are recommended
  • The comparison table can be exported in various formats (CSV, PDF)
  • Custom comparison metrics can be calculated based on product attributes
  • Performance may be affected when comparing many products with numerous attributes