woordenlijst

package module
v0.0.0-...-fa30a2f Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: Unlicense Imports: 7 Imported by: 0

README

Woordenlijst

The woordenlijst Go package allows you to search and retrieve information about Dutch words from woordenlijst.org. It currently exposes functionality which I need but this can be expanded.

Installation

To install the package, use the following command:

go get github.com/pears-one/go-woordenlijst

Usage

Importing the Package

In your Go program, import the package:

import "github.com/pears-one/go-woordenlijst"
Searching for Nouns

To search for nouns, use the SearchNouns function:

package main

import (
    "fmt"
    "log"
    "github.com/pears-one/go-woordenlijst"
)

func main() {
    nouns, err := woordenlijst.SearchNouns("kantoor")
    if err != nil {
        log.Fatal(err)
    }

    for _, noun := range nouns {
        article, _ := noun.Article()
        fmt.Printf("Word with article: %s %s\n", article, noun.Word())
    }
}
Searching for Verbs

To search for verbs, use the SearchVerbs function:

package main

import (
    "fmt"
    "log"
    "github.com/pears-one/go-woordenlijst"
)

func main() {
    verbs, err := woordenlijst.SearchVerbs("voetbal")
    if err != nil {
        log.Fatal(err)
    }

    for _, verb := range verbs {
        fmt.Printf("Verb: %s\n", verb.Word())
    }
}

For a custom search, you can use the SearchWithParams function. First, create a SearchParameters struct:

params := &woordenlijst.SearchParameters{
    WordForm:      "huis",
    PartsOfSpeech: []woordenlijst.PartOfSpeech{woordenlijst.Noun},
    Paradigm:      true,
    Diminutive:    true,
}

Then, call the SearchWithParams function:

results, err := woordenlijst.SearchWithParams(params)
if err != nil {
    log.Fatal(err)
}

for _, lemma := range results {
    fmt.Printf("Word: %s\n", lemma.Word())
}
Lemma Methods

Once you have a Lemma object, you can use various methods to get more information. The functions available depend of the word's part of speech. For example the following functions are available for nouns:

  • SingularForm() (string, error): Returns the singular form.
  • PluralForm() (string, error): Returns the plural form.
  • Gender() (string, error): Returns the gender.
  • Article() (string, error): Returns the article (de/het).

Example:

for _, lemma := range results {
    singular, _ := lemma.SingularForm()
    plural, _ := lemma.PluralForm()
    gender, _ := lemma.Gender()
    article, _ := lemma.Article()

    fmt.Printf("Lemma: %s, Singular: %s, Plural: %s, Gender: %s, Article: %s\n",
               lemma.Lemma, singular, plural, gender, article)
}

Functions

Search Functions
  • func Search(word string, partsOfSpeech []PartOfSpeech) ([]Lemma, error)
  • func SearchNouns(word string) ([]Lemma, error)
  • func SearchVerbs(word string) ([]Lemma, error)
  • func SearchWithParams(params *SearchParameters) ([]Lemma, error)

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

Contact

For any questions or issues, please open an issue on GitHub.

Documentation

Index

Constants

View Source
const (
	DefaultDatabase = "gig_pro_wrdlst"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lemma

type Lemma struct {
	DiminutiveInfo string `xml:"diminutive_info"`
	Diminutives    string `xml:"diminutives"`
	EntryType      string `xml:"entry_type"`
	ExternalLink   string `xml:"external_link"`
	Gloss          string `xml:"gloss"`
	Keurmerk       bool   `xml:"keurmerk"`
	Label          string `xml:"label"`
	Lemma          string `xml:"lemma"`
	LemmaID        int    `xml:"lemma_id"`
	Message        string `xml:"message"`
	Nuancerende    string `xml:"nuancerende_opmerking"`
	Online         bool   `xml:"online"`
	POS            string `xml:"lemma_part_of_speech"`
	P              P      `xml:"paradigm"`
	Parent         string `xml:"parent"`
	PartNumber     int    `xml:"part_number"`
	Pronounciation string `xml:"pronounciation"`
	Source         string `xml:"source"`
	Subset         string `xml:"subset"`
	Taaladvies     string `xml:"taaladvies"`
	Taalvariant    string `xml:"taalvariant"`
	Trademark      bool   `xml:"trademark"`
	VerbFeatures   string `xml:"verb_features"`
	Wordparts      string `xml:"wordparts"`
	WordpartsInfo  string `xml:"wordparts_info"`
}
func Search(word string, partsOfSpeech []PartOfSpeech) ([]Lemma, error)

func SearchNouns

func SearchNouns(word string) ([]Lemma, error)

func SearchVerbs

func SearchVerbs(word string) ([]Lemma, error)

func SearchWithParams

func SearchWithParams(params *SearchParameters) ([]Lemma, error)

func (*Lemma) Article

func (l *Lemma) Article() (string, error)

func (*Lemma) Gender

func (l *Lemma) Gender() (string, error)

func (*Lemma) IsNoun

func (l *Lemma) IsNoun() bool

func (*Lemma) PartOfSpeech

func (l *Lemma) PartOfSpeech() string

func (*Lemma) PartOfSpeechDetails

func (l *Lemma) PartOfSpeechDetails() PartOfSpeechDetails

func (*Lemma) PluralForm

func (l *Lemma) PluralForm() (string, error)

func (*Lemma) SingularForm

func (l *Lemma) SingularForm() (string, error)

func (*Lemma) Word

func (l *Lemma) Word() string

type P

type P struct {
	Paradigms []Paradigm `xml:"paradigm"`
}

type Paradigm

type Paradigm struct {
	Arch        bool   `xml:"arch"`
	GroupLabel  string `xml:"group_label"`
	Hyphenation string `xml:"hyphenation"`
	POS         string `xml:"part_of_speech"`
	Position    int    `xml:"position"`
	Wordform    string `xml:"wordform"`
	WordformID  int    `xml:"wordform_id"`
}

func (*Paradigm) PartOfSpeech

func (p *Paradigm) PartOfSpeech() string

PartOfSpeech returns the part of speech of the paradigm.

func (*Paradigm) PartOfSpeechDetails

func (p *Paradigm) PartOfSpeechDetails() PartOfSpeechDetails

type PartOfSpeech

type PartOfSpeech int
const (
	Adverb       PartOfSpeech = iota // bijwoord
	Adjective                        // bijvoeglijk naamwoord
	Verb                             // werkwoord
	Noun                             // zelfstandig naamwoord
	Preposition                      // voorzetsel
	Conjunction                      // voegwoord
	Pronoun                          // voornaamwoord
	Numeral                          // telwoord
	Interjection                     // tussenwerpsel
	Other                            // overig
)

func (PartOfSpeech) String

func (p PartOfSpeech) String() string

func (PartOfSpeech) ToEnglish

func (p PartOfSpeech) ToEnglish() string

type PartOfSpeechDetails

type PartOfSpeechDetails struct {
	Part    string
	Details map[string]string
}

type SearchParameters

type SearchParameters struct {
	WordForm      string `validate:"required"`
	PartsOfSpeech []PartOfSpeech
	Paradigm      bool
	Diminutive    bool
}

func NewSearchParameters

func NewSearchParameters(word string, partsOfSpeech []PartOfSpeech) *SearchParameters

func (*SearchParameters) ToQueryString

func (p *SearchParameters) ToQueryString() string

ToQueryString returns the query string for this search parameter.

Jump to

Keyboard shortcuts

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