wordpos

package module
v0.0.0-...-35d49c9 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 8 Imported by: 0

README

Go Reference

WordPOS for Go

This package intends to be a port of moos' wordpos package. I have no relation to the individual who made the package nor the package. I simply needed the same functionality for a different Go project, and I couldn't find a suitable replacement.

Note: This is not a complete port. Some wordnet data is not captured using the method I am currently using, and the definition is VERY crudely formatted. I may or may not change this in the future.

KNOWN MAJOR ISSUES:

  • VERY slow
  • Verbs and adverb lookup only works on base forms, and random word fetch only works on base forms.
  • Does not provide you with all information compared to moos' wordpos
  • Random word fetch only fetches the first word in the dataline

Installation

This will take quite a few megabytes as it includes all of wordnet locally.

Usage

View wordpos_test.go for examples of how to use the functions.

MIT License

Copyright (c) 2023 Nathan B. (10Nates)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

WordNet License

This license is available as the file LICENSE in any downloaded version of WordNet.

WordNet 3.0 license: (Download)

WordNet Release 3.0 This software and database is being provided to you, the LICENSEE, by Princeton University under the following license. By obtaining, using and/or copying this software and database, you agree that you have read, understood, and will comply with these terms and conditions.: Permission to use, copy, modify and distribute this software and database and its documentation for any purpose and without fee or royalty is hereby granted, provided that you agree to comply with the following copyright notice and statements, including the disclaimer, and that the same appear on ALL copies of the software, database and documentation, including modifications that you make for internal use or for distribution. WordNet 3.0 Copyright 2006 by Princeton University. All rights reserved. THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT- ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. The name of Princeton University or Princeton may not be used in advertising or publicity pertaining to distribution of the software and/or database. Title to copyright in this software, database and any associated documentation shall at all times remain with Princeton University and LICENSEE agrees to preserve same.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAdjective

func IsAdjective(word string) (bool, error)

func IsAdverb

func IsAdverb(word string) (bool, error)

func IsNoun

func IsNoun(word string) (bool, error)

func IsVerb

func IsVerb(word string) (bool, error)

Types

type POS

type POS string
const (
	POS_Noun      POS = "n"
	POS_Verb      POS = "v"
	POS_Adjective POS = "adj"
	POS_Adverb    POS = "adv"
	POS_Other     POS = "o"
)

type POSSet

type POSSet struct {
	Nouns      []*Word
	Verbs      []*Word
	Adjectives []*Word
	Adverbs    []*Word
	Rest       []*Word
}

func GetPOS

func GetPOS(text string) (*POSSet, error)

type Word

type Word struct {
	ID           uint
	Word         string
	PartOfSpeech POS
	Definition   string
}

func GetAdjectives

func GetAdjectives(text string) ([]*Word, error)

func GetAdverbs

func GetAdverbs(text string) ([]*Word, error)

func GetNouns

func GetNouns(text string) ([]*Word, error)

func GetVerbs

func GetVerbs(text string) ([]*Word, error)

func Lookup

func Lookup(word string, checkAll bool) ([]*Word, error)

func LookupAdjective

func LookupAdjective(word string) (*Word, error)

func LookupAdverb

func LookupAdverb(word string) (*Word, error)

func LookupNoun

func LookupNoun(word string) (*Word, error)

func LookupVerb

func LookupVerb(word string) (*Word, error)

func Rand

func Rand(startsWith string, count uint) ([]*Word, error)

Random lookup. Leave startsWith as "" for any.

func RandAdjective

func RandAdjective(startsWith string, count uint) ([]*Word, error)

func RandAdverb

func RandAdverb(startsWith string, count uint) ([]*Word, error)

func RandNoun

func RandNoun(startsWith string, count uint) ([]*Word, error)

func RandVerb

func RandVerb(startsWith string, count uint) ([]*Word, error)

Jump to

Keyboard shortcuts

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