Câu Đánh giá (Review Sentences)
Mô tả Tổng quan
Lấy các câu đánh giá cho một sản phẩm cụ thể trong lịch sử dataset. Hỗ trợ hai chế độ: Quan điểm Cụ thể (SPVP) và Quan điểm AI.
Swagger Link
API: Review Sentences API
Sơ đồ Hoạt động
---
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'>Gửi yêu cầu GET</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'>Xác thực 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'>Định dạng/Phân trang</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'>Định dạng/Phân trang</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'>Trả về JSON</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
Tài liệu Tình huống
Trường hợp 1: Quan điểm Cụ thể (SPVP)
Sơ đồ Trình tự
sequenceDiagram
participant Client
participant API as ProductAnalyzerController
participant Service as SpvpService
participant Repository as WishlistDatasetHistoryRepository
participant DB as Database
Note over Client,DB: Luồng Câu Đánh giá (SPVP)
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
Các bước
Bước 1: Request
- Method: GET
- Path:
/api/v1/general/analyzer/{wldh_slug}/review/sentences - Path param:
wldh_slug - Query params:
mall_product_id(bắt buộc)viewpoint_type(bắt buộc):SpecificViewpointviewpoint_id(bắt buộc)start_date,end_date(bắt buộc, YYYY-MM-DD)descending(tùy chọn):true|falseis_noise(tùy chọn):true|falseper_page(tùy chọn)page(tùy chọn)
Bước 2: Xác thực Dataset
- Tìm dataset history theo slug
Bước 3: Xử lý (SPVP)
- Controller:
getSpecificReviewSentences - Service:
SpvpService::getReviewSentencesBySpecificViewpoint - Truy vấn: join
review_sentence_spvpvớireview_sentences; lọc theo sản phẩm/ngày/quan điểm
Bước 4: Phản hồi
- Thành công:
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 } }
Trường hợp 2: Quan điểm AI
Sơ đồ Trình tự
sequenceDiagram
participant Client
participant API as ProductAnalyzerController
participant Service as ProductAnalyzerService
participant Repository as WishlistDatasetHistoryRepository
participant DB as Database
Note over Client,DB: Luồng Câu Đánh giá (AI)
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
Các bước
Bước 1: Request
- Method: GET
- Path:
/api/v1/general/analyzer/{wldh_slug}/review/sentences - Path param:
wldh_slug - Query params:
mall_product_id(bắt buộc)viewpoint_type(bắt buộc):AiViewpointviewpoint_id(bắt buộc)start_date,end_date(bắt buộc, YYYY-MM-DD)descending(tùy chọn):true|falseis_noise(tùy chọn):true|falseper_page(tùy chọn)page(tùy chọn)
Bước 2: Xác thực Dataset
- Tìm dataset history theo slug
Bước 3: Xử lý (AI)
- Controller trộn hằng số và gọi:
ProductAnalyzerService::reviewSentences - Truy vấn: join
review_sentence_aivpvớireview_sentences; lọc theo sản phẩm/ngày/quan điểm; phân trang
Bước 4: Phản hồi
- Thành công: cùng cấu trúc với SPVP, các trường được ánh xạ bởi
ReviewSentenceResource
Bảng/Trường liên quan (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
Bảng/Trường liên quan (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
Xử lý Lỗi
- | 404 | "Dataset not found" |
- | 400 | "Invalid parameters" |