Review Sentences
Overview Description
Retrieve review sentences for a specific product within a dataset history. Supports two modes: Specific Viewpoint (SPVP) and AI Viewpoint.
Swagger Link
API: Review Sentences API
Activity Diagram
---
config:
theme: base
layout: dagre
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TB
Client[Client Application]
API[ProductAnalyzerController]
Dataset[Dataset Validation]
Spvp(SpvpService)
PAService(ProductAnalyzerService)
DB[(Database)]
Client --- Step1[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1</span>
<p style='margin-top: 8px'>Send GET Request</p>
</div>
]
Step1 --> API
API --- Step2[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>2</span>
<p style='margin-top: 8px'>Validate Dataset</p>
</div>
]
Step2 --> Dataset
API --- Step3A[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #cc66cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3A</span>
<p style='margin-top: 8px'>Specific Viewpoint</p>
</div>
]
Step3A --> Spvp
Spvp --> DB
DB --> Spvp
API --- Step3B[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3B</span>
<p style='margin-top: 8px'>AI Viewpoint</p>
</div>
]
Step3B --> PAService
PAService --> DB
DB --> PAService
Spvp --- Step4A[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #cc66cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4A</span>
<p style='margin-top: 8px'>Format/Paginate</p>
</div>
]
PAService --- Step4B[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4B</span>
<p style='margin-top: 8px'>Format/Paginate</p>
</div>
]
Step4A --> API
Step4B --> API
API --- Step5[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>5</span>
<p style='margin-top: 8px'>Send JSON Response</p>
</div>
]
Step5 --> Client
%% Styling
style Client fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style API fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
style Dataset fill:#f0f8e6,stroke:#339933,stroke-width:2px
style Spvp fill:#f0f8e6,stroke:#339933,stroke-width:2px
style PAService fill:#f0f8e6,stroke:#339933,stroke-width:2px
style DB fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
style Step1 fill:transparent,stroke:transparent,stroke-width:1px
style Step2 fill:transparent,stroke:transparent,stroke-width:1px
style Step3A fill:transparent,stroke:transparent,stroke-width:1px
style Step3B fill:transparent,stroke:transparent,stroke-width:1px
style Step4A fill:transparent,stroke:transparent,stroke-width:1px
style Step4B fill:transparent,stroke:transparent,stroke-width:1px
style Step5 fill:transparent,stroke:transparent,stroke-width:1px
Case Documentation
Case 1: Specific Viewpoint (SPVP)
Sequence Diagram
sequenceDiagram
participant Client
participant API as ProductAnalyzerController
participant Service as SpvpService
participant Repository as WishlistDatasetHistoryRepository
participant DB as Database
Note over Client,DB: Review Sentences (SPVP) Flow
Client->>API: GET /api/v1/general/analyzer/{wldh_slug}/review/sentences?params
API->>Repository: findBySlug(wldh_slug)
Repository->>DB: SELECT * FROM wishlist_dataset_history WHERE slug = ?
DB-->>Repository: Dataset
Repository-->>API: WishlistDatasetHistory
API->>Service: getReviewSentencesBySpecificViewpoint(wishlistDataset, params)
Service->>DB: Query review_sentence_spvp + review_sentences
DB-->>Service: Review sentences
Service-->>API: LengthAwarePaginator
API-->>Client: 200 OK (paginated review sentences)
alt Dataset Not Found
Repository-->>API: null
API-->>Client: 404 Not Found
end
Steps
Step 1: Request
- Method: GET
- Path:
/api/v1/general/analyzer/{wldh_slug}/review/sentences - Path param:
wldh_slug - Query params:
mall_product_id(required)viewpoint_type(required):SpecificViewpointviewpoint_id(required)start_date,end_date(required, YYYY-MM-DD)descending(optional):true|falseis_noise(optional):true|falseper_page(optional)page(optional)
Step 2: Validate Dataset
- Find dataset history by slug
Step 3: Process (SPVP)
- Controller:
getSpecificReviewSentences - Service:
SpvpService::getReviewSentencesBySpecificViewpoint - Query: join
review_sentence_spvpwithreview_sentences; filter by product, date, viewpoint
Step 4: Response
- Success:
200 OK{ "data": [ { "mall_product_id": "dogparadise:4589602260099", "content": "Great quality and packaging", "sentiment_score": 5, "post_date": "2024-01-10", "viewpoints": [ { "id": 515, "name": "Price" } ] } ], "meta": { "total": 120, "per_page": 50, "current_page": 1 } }
Case 2: AI Viewpoint
Sequence Diagram
sequenceDiagram
participant Client
participant API as ProductAnalyzerController
participant Service as ProductAnalyzerService
participant Repository as WishlistDatasetHistoryRepository
participant DB as Database
Note over Client,DB: Review Sentences (AI) Flow
Client->>API: GET /api/v1/general/analyzer/{wldh_slug}/review/sentences?params
API->>Repository: findBySlug(wldh_slug)
Repository->>DB: SELECT * FROM wishlist_dataset_history WHERE slug = ?
DB-->>Repository: Dataset
Repository-->>API: WishlistDatasetHistory
API->>Service: reviewSentences(params, wishlistDataset)
Service->>DB: Query review_sentence_aivp + review_sentences
DB-->>Service: Review sentences
Service-->>API: LengthAwarePaginator
API-->>Client: 200 OK (paginated review sentences)
alt Dataset Not Found
Repository-->>API: null
API-->>Client: 404 Not Found
end
Steps
Step 1: Request
- Method: GET
- Path:
/api/v1/general/analyzer/{wldh_slug}/review/sentences - Path param:
wldh_slug - Query params:
mall_product_id(required)viewpoint_type(required):AiViewpointviewpoint_id(required)start_date,end_date(required, YYYY-MM-DD)descending(optional):true|falseis_noise(optional):true|falseper_page(optional)page(optional)
Step 2: Validate Dataset
- Find dataset history by slug
Step 3: Process (AI)
- Controller merges constants then calls:
ProductAnalyzerService::reviewSentences - Query: join
review_sentence_aivpwithreview_sentences; filter by product/date/viewpoint; paginate
Step 4: Response
- Success: same shape as SPVP, fields mapped by
ReviewSentenceResource
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
- | 404 | "Dataset not found" |
- | 400 | "Invalid parameters" |