philarios

package
v0.0.0-...-de30bf2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2014 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumSurroundingWords = 2
)
View Source
const (
	WordsToCapture = 2
)

Variables

This section is empty.

Functions

func CanonicalWordForm

func CanonicalWordForm(word string) string

func FuzzyStringEquals

func FuzzyStringEquals(word1, word2 string) bool

func SplitWords

func SplitWords(sentence string) []string

SplitWords takes a string and returns the separate words that make up the string. In essence, it splits the string according to demarcating characters like punctuation and spaces.

func Synonyms

func Synonyms(word string) ([]string, error)

Types

type Paragraph

type Paragraph struct {
	PublicationId int
	Body          string
}

type Philarios

type Philarios interface {
	SentenceFindAlternativeWords(sentence string, queryStart, queryEnd, maxWords int) ([]string, error)
	FindAlternativeWords(beforeWords, afterWords []string, queryWord string, maxWords int) ([]string, error)
	AlternativeWords(word string, maxWords int) ([]string, error)
}

type PostgresStorage

type PostgresStorage struct {
	SQLDatabase *sql.DB
}

func (PostgresStorage) AddPublication

func (p PostgresStorage) AddPublication(publication Publication) error

AddPublication adds a new publication to the database, adding data to the publications, categories, and paragraphs tables.

func (PostgresStorage) EnsureSchema

func (p PostgresStorage) EnsureSchema() error

EnsureSchema is called on a database and ensures that a correct schema has been applied so that Queries on the database can occur.

func (PostgresStorage) QueryForWord

func (p PostgresStorage) QueryForWord(word string, categories []string) ([]Paragraph, error)

QueryForWord returns SQL rows of paragraphs containing the query word given as an argument. These are returned from the database.

type Publication

type Publication struct {
	Title      string
	Author     string
	Editor     string
	Date       string
	SourceID   string
	SourceURL  string
	Encoding   string
	Type       string
	Text       string
	Categories []string
}

Publication is a structure which represents any type of publication (such as books or articles) which contains text.

type Settings

type Settings struct {
	WordsToCapture int
}

func DefaultSettingsObject

func DefaultSettingsObject() Settings

type Storage

type Storage interface {
	QueryForWord(word string, categories []string) ([]Paragraph, error)
	AddPublication(publication Publication) error
}

type WordFactory

type WordFactory struct {
	Storage  Storage
	Settings Settings
	TFIDF    tfidf.TFIDF
}

func (WordFactory) AlternativeWordVectors

func (p WordFactory) AlternativeWordVectors(word string, maxWords int) ([]WordVector, error)

AlternativeWordVectors returns alternative word vectors for a particular word.

func (WordFactory) AlternativeWords

func (p WordFactory) AlternativeWords(word string, maxWords int) ([]string, error)

AlternativeWords returns alternative words that can be used in place of the current word. The words that are returned will have close meanings to the word used as an argument, but which are usually used in place of that word.

The maxWords parameter specifies the maximum number of words to return.

func (WordFactory) FindAlternativeWords

func (p WordFactory) FindAlternativeWords(beforeWords, afterWords []string, queryWord string, maxWords int) ([]string, error)

FindAlternativeWords takes a sentence and replaces the queryWord with a set of words (not exceeding maxWords), which may be a good fit given the context. The words before the queryWord in the sentence are given by beforeWords, and the words after are given by afterWords.

func (WordFactory) SentenceFindAlternativeWords

func (p WordFactory) SentenceFindAlternativeWords(sentence string, queryStart, queryEnd, maxWords int) ([]string, error)

SentenceFindAlternativeWords takes a sentence and the start and end positions of a query, and finds alternative words for that query. The queryStart index should be the first byte of the query word, while the queryEnd index should be the index of the first byte after the query word.

func (WordFactory) TargetVectors

func (p WordFactory) TargetVectors(word string) ([]WordVector, error)

type WordVector

type WordVector struct {
	Word  string
	Score float64
}

type WordVectorCollection

type WordVectorCollection []WordVector

func (WordVectorCollection) Len

func (t WordVectorCollection) Len() int

func (WordVectorCollection) Less

func (t WordVectorCollection) Less(i, j int) bool

func (WordVectorCollection) Swap

func (t WordVectorCollection) Swap(i, j int)

Jump to

Keyboard shortcuts

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