Documentation ¶
Index ¶
- Constants
- func CanonicalWordForm(word string) string
- func FuzzyStringEquals(word1, word2 string) bool
- func SplitWords(sentence string) []string
- func Synonyms(word string) ([]string, error)
- type Paragraph
- type Philarios
- type PostgresStorage
- type Publication
- type Settings
- type Storage
- type WordFactory
- func (p WordFactory) AlternativeWordVectors(word string, maxWords int) ([]WordVector, error)
- func (p WordFactory) AlternativeWords(word string, maxWords int) ([]string, error)
- func (p WordFactory) FindAlternativeWords(beforeWords, afterWords []string, queryWord string, maxWords int) ([]string, error)
- func (p WordFactory) SentenceFindAlternativeWords(sentence string, queryStart, queryEnd, maxWords int) ([]string, error)
- func (p WordFactory) TargetVectors(word string) ([]WordVector, error)
- type WordVector
- type WordVectorCollection
Constants ¶
const (
NumSurroundingWords = 2
)
const (
WordsToCapture = 2
)
Variables ¶
This section is empty.
Functions ¶
func CanonicalWordForm ¶
func FuzzyStringEquals ¶
func SplitWords ¶
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.
Types ¶
type PostgresStorage ¶
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 WordFactory ¶
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 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)