This is Text2Data's unofficial Go client, designed to enable you to use Text2Data's services easily from your own applications.
Text2Data is a cloud-based text analytics service that through APIs allows you extract informations from a text content.
This SDK is compatible with v3 of the Text2Data API.
You can load text2data-go into your project by using:
go get github.com/henomis/text2data-go
The only things you need to start using Text2Data's APIs are PrivateKey and Secret.
Please refer to the examples folder to see how to use the SDK.
Here below a simple usage example:
package main
import (
"encoding/json"
"fmt"
"log"
"time"
text2datago "github.com/henomis/text2data-go"
"github.com/henomis/text2data-go/pkg/request"
)
const PrivateKey = "YOUR_PRIVATE_KEY"
const Secret = "YOUR_SECRET"
func main() {
text2dataClient := text2datago.New(
text2datago.Text2DataAPIEndpointV3,
PrivateKey,
Secret,
10*time.Second,
)
requestAnalyze := &request.Request{}
requestAnalyze.DocumentText = "Excellent location, opposite a very large mall with wide variety of shops, restaurants and more."
response, err := text2dataClient.Analyze(requestAnalyze)
if err != nil {
log.Fatalf("error while performing analysis: %v", err)
}
if !response.Status.IsSuccess() {
log.Fatalf("error: %s", response.ErrorMessage.Error())
}
bytes, _ := json.MarshalIndent(response, "", " ")
fmt.Println(string(bytes))
}