dictionaries

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

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 2 Imported by: 1

README

Dictionaries

Dictionaries is a Go package that provides access to dictionaries for different languages.

Installation

go get github.com/STRockefeller/dictionaries

Usage

This package exposes two interfaces: EnglishDictionaries and JapaneseDictionaries. They provide access to the following dictionaries:

  • English : FreeDictionary
  • Japanese: JishoOrg

Example

package main

import (
	"fmt"

	"github.com/STRockefeller/dictionaries"
	"github.com/STRockefeller/dictionaries/instances/english/freedictionary"
	"github.com/STRockefeller/dictionaries/instances/japanese/jishoorg"
)

func main() {
	// English dictionary
	{
		dictionary := dictionaries.NewEnglishDictionary[freedictionary.Dictionary]()
		definition, err := dictionary.Search("word")
		if err != nil {
			fmt.Println(err)
		} else {
			fmt.Println(definition)
		}
	}

	// Japanese dictionary
	{
		dictionary := dictionaries.NewJapaneseDictionary[jishoorg.Dictionary]()
		definition, err := dictionary.Search("単語")
		if err != nil {
			fmt.Println(err)
		} else {
			fmt.Println(definition)
		}
	}
}

In the above example, we create instances of both English and Japanese dictionaries and get their respective definitions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEnglishDictionary

func NewEnglishDictionary[T EnglishDictionaries]() T

Creates a new instance of an English Dictionary.

func NewJapaneseDictionary

func NewJapaneseDictionary[T JapaneseDictionaries]() T

Creates a new instance of a Japanese Dictionary.

Types

type EnglishDictionaries

type EnglishDictionaries interface {
	freedictionary.Dictionary
}

Interface definition for English Dictionaries which inherits from the freedictionary interface.

type JapaneseDictionaries

type JapaneseDictionaries interface {
	jishoorg.Dictionary
}

Interface definition for Japanese Dictionaries which inherits from the jishoorg interface.

Directories

Path Synopsis
instances

Jump to

Keyboard shortcuts

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