text2datago

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 5 Imported by: 0

README

Text2Data SDK for Go

Build Status GoDoc Go Report Card GitHub release

This is Text2Data's unofficial Go client, designed to enable you to use Text2Data's services easily from your own applications.

Text2Data

Text2Data is a cloud-based text analytics service that through APIs allows you extract informations from a text content.

SDK versions

This SDK is compatible with v3 of the Text2Data API.

Getting started

Installation

You can load text2data-go into your project by using:

go get github.com/henomis/text2data-go
Configuration

The only things you need to start using Text2Data's APIs are PrivateKey and Secret.

Usage

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))
}

Documentation

Index

Constants

View Source
const (
	Text2DataAPIEndpointV3 = "http://api.text2data.com/v3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Text2DataClient

type Text2DataClient struct {
	// contains filtered or unexported fields
}

func New

func New(endpoint, privateKey, secret string, timeout time.Duration) *Text2DataClient

func (*Text2DataClient) Analyze

func (m *Text2DataClient) Analyze(analyzeRequest *request.Request) (*response.Response, error)

func (*Text2DataClient) Categorize

func (m *Text2DataClient) Categorize(categorizeRequest *request.Request) (*response.Response, error)

func (*Text2DataClient) Extract

func (m *Text2DataClient) Extract(extractRequest *request.Request) (*response.Response, error)

Directories

Path Synopsis
examples
cmd/analyze command
cmd/categorize command
cmd/extract command
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL