dandeliongo

package module
v1.0.1 Latest Latest
Warning

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

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

README

Dandelion SDK for Go

Build Status GoDoc Go Report Card GitHub release

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

Danelion

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

Supported API versions

Entity extraction v1
Text similarity v1
Language detection v1
Sentiment analysis v1
Wikisearch v1

Getting started

Installation

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

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

The only thing you need to start using Dandelio's APIs is the Token.

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"

	dandeliongo "github.com/henomis/dandelion-go"
	"github.com/henomis/dandelion-go/pkg/request"
)

const Token = "YOUR_API_TOKEN"

func main() {

	dandelionClient := dandeliongo.New(
		dandeliongo.DandelionEndpoint,
		Token,
		10*time.Second,
	)

	response, err := dandelionClient.EntityExtraction(
		&request.EntityExtraction{
			Lang:    newString("en"),
			Include: newString("types,abstract,categories,lod"),
			Text:    "The doctor says an apple is better than an orange",
		},
	)
	if err != nil {
		log.Fatal(err)
	}

	if !response.IsSuccess() {
		log.Fatal(response.Error())
	}

	bytes, _ := json.MarshalIndent(response, "", "  ")
	fmt.Println(string(bytes))

}

// Support methods

func newString(s string) *string {
	return &s
}

Documentation

Index

Constants

View Source
const (
	DandelionEndpoint = "https://api.dandelion.eu"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DandelionClient

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

func New

func New(endpoint string, token string, timeout time.Duration) *DandelionClient

func (*DandelionClient) EntityExtraction

func (d *DandelionClient) EntityExtraction(
	entityExtractionRequest *request.EntityExtraction,
) (*response.EntityExtraction, error)

func (*DandelionClient) LanguageDetection

func (d *DandelionClient) LanguageDetection(
	languageDetectionRequest *request.LanguageDetection,
) (*response.LanguageDetection, error)

func (*DandelionClient) SentimentAnalysis

func (d *DandelionClient) SentimentAnalysis(
	sentimentAnalysisRequest *request.SentimentAnalysis,
) (*response.SentimentAnalysis, error)

func (*DandelionClient) TextSimilarity

func (d *DandelionClient) TextSimilarity(
	textSimilarityRequest *request.TextSimilarity,
) (*response.TextSimilarity, error)

func (*DandelionClient) WikiSearch

func (d *DandelionClient) WikiSearch(
	wikiSearchRequest *request.WikiSearch,
) (*response.WikiSearch, error)

Jump to

Keyboard shortcuts

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