assocentity

package module
v5.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: MIT Imports: 3 Imported by: 0

README

assocentity

Package assocentity returns the average distance from words to a given entity.

Features

  • Interfere at every step
  • pass aliases to entity
  • provides a default tokenzier

Installation

$ go get github.com/ndabAP/assocentity/v5

Prerequisites

Sign-up for a Cloud Natural Language API service account key and download the generated JSON file. This equals the credentialsFile at the example below. Don't commit that file.

Usage

import (
	"fmt"
	"log"

	"github.com/ndabAP/assocentity/v5/tokenize"
	"github.com/ndabAP/assocentity/v5"
)

const (
	credentialsFile = "google_nlp_service_account.json"
)

func main() {
	text := "Punchinello wanted Payne? He'd see the pain."
	entities := []string{"Punchinello", "Payne"}

	// Create a NLP instance
	nlp, err := tokenize.NewNLP(credentialsFile, text, entities)
	if err != nil {
		log.Fatal(err)
	}

	dps := tokenize.NewPoSDetermer(tokenize.ANY)
	dj := tokenize.NewJoin(tokenize.Whitespace)

    	// Do calculates the average distances
	assocEntities, err := assocentity.Do(dj, nlp, entities)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(assocEntities) // map[wanted:1 ?:2 He:3 'd:4 see:5 the:6 pain:7 .:8]
}

Author

Julian Claus and contributors.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(tokenizer tokenize.Tokenizer, dps tokenize.PoSDetermer, j tokenize.Joiner, entities []string) (map[string]float64, error)

Do returns the entity distances

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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