mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 07:15:25 +00:00
log sentiment analysis
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/micro/micro/v3/service/logger"
|
||||||
pb "github.com/micro/services/posts/proto"
|
pb "github.com/micro/services/posts/proto"
|
||||||
"github.com/micro/services/sentiment/model"
|
"github.com/micro/services/sentiment/model"
|
||||||
)
|
)
|
||||||
@@ -25,6 +26,8 @@ func EnrichPost(ctx context.Context, post *pb.Post) error {
|
|||||||
score := model.Analyze(post.Title)
|
score := model.Analyze(post.Title)
|
||||||
post.Metadata["sentiment"] = fmt.Sprintf("%.1f", score)
|
post.Metadata["sentiment"] = fmt.Sprintf("%.1f", score)
|
||||||
|
|
||||||
|
logger.Info("Setting score %.1f for post %v", score, post.Title)
|
||||||
|
|
||||||
// now save the post
|
// now save the post
|
||||||
PostsClient.Save(ctx, &pb.SaveRequest{
|
PostsClient.Save(ctx, &pb.SaveRequest{
|
||||||
Id: post.Id,
|
Id: post.Id,
|
||||||
|
|||||||
Reference in New Issue
Block a user