Skip to content

Commit

Permalink
✅ Update examples/sentiment
Browse files Browse the repository at this point in the history
  • Loading branch information
maiqingqiang committed Aug 6, 2023
1 parent 0098a3c commit 6b58ec6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions examples/sentiment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ go 1.20

require github.com/maiqingqiang/typechat-go v1.0.0

require golang.org/x/text v0.12.0 // indirect

replace github.com/maiqingqiang/typechat-go => ../../
2 changes: 0 additions & 2 deletions examples/sentiment/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
Binary file modified examples/sentiment/run.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion examples/sentiment/sentiment_schema.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
// The following is a schema definition for determining the sentiment of a some user input.

package main

import "fmt"

// Sentiment Define the enum type, this value is int
type Sentiment int

// Define the enum constants for Sentiment
const (
Negative Sentiment = iota
Neutral
Positive
)

// Use switch statement to handle the enum type for Sentiment
func (s Sentiment) String() string {
switch s {
case Negative:
Expand All @@ -24,7 +29,7 @@ func (s Sentiment) String() string {
}

type SentimentResponse struct {
Sentiment int `json:"sentiment"`
Sentiment Sentiment `json:"sentiment"` // The sentiment of the Sentiment enum type
}

func (s SentimentResponse) String() string {
Expand Down

0 comments on commit 6b58ec6

Please sign in to comment.