monogram

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MPL-2.0 Imports: 3 Imported by: 1

README

monogram

Package monogram provides convenient access to weights of characters with corresponding tools to generate such mappings.

Package already contains calculated values for English and Russian languages.
All letter weights for alphabet normalized so their sum is 1.0.
It makes them uniform for different character sets.

During generation process all of the letters are converted to UPPERCASE and normalized using NFC.

Usage example

$ go get pkg.botr.me/monogram@latest
package example

import (
    "log"

    "golang.org/x/text/language"
    "pkg.botr.me/monogram"
)

func main() {
    w := monogram.Weights(language.English)
    log.Println(w['E']) // should return ~0.12
}

License

Copyright (c) 2021 gudvinr

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

Documentation

Overview

Package monogram contains normalized weights for different alphabets. Language matching performed using language.Tag from golang.org/x/text/language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPW added in v1.1.0

func CPW(tag language.Tag) float64

CPW returns average number of characters-per-word for provided language

func IsVowel added in v1.1.0

func IsVowel(l language.Tag, r rune) bool

IsVowel returns true if rune belongs to language and defined as vowel. Character transformed to uppercase before checking.

Types

type RuneWeights

type RuneWeights map[rune]float64

RuneWeights describes language character weights for set of runes. All frequencies for the language are weighted so sum is always 1. Every rune is NFC normalized code point.

func Weights

func Weights(tag language.Tag) RuneWeights

Weights returns RuneWeights for provided Tag. It copies underlying map to avoid accidental modifications to one. If provided tag not explicitely defined it will try to find closest match using language.Match with High confidence.

Directories

Path Synopsis
internal
gen

Jump to

Keyboard shortcuts

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