vonny

package module
v1.0.0 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: 9 Imported by: 0

README

go-vonny

This library can be used to vonnify text. It changes neighbour characters or removes them from words.
Supports same set of languages as pkg.botr.me/monogram (doc, src).
If you want to support yours, please send character frequencies for alphabet of choice there.

Intensity of changes can be configured. Currently vonny only able to make changes for provided locale. For example, when you pass language.Russian it won't change latin characters.
Non-text characters like punctuation symbols, whitespaces or emoji aren't processed or stripped out from input text.

Be aware that input text being converted to NFC unicode form.

Usage

$ go get pkg.botr.me/go-vonny@latest
package main

import (
	"log"

	"pkg.botr.me/go-vonny"
	"golang.org/x/text/language"
)

func main() {
	str := "Hello World!"
	fmt.Println(str)

	out := vonny.Translate(language.English, str)
	fmt.Println(out) // "Heol Worl!"
}

Etymology of the name

Package vonny named after fictional character "Vonny-the-Pyh" whose prototype is Pooh, the plush bear.
He speaks using intentionally corrupted words and represents stereotypical low-life person.

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 vonny transforms text by making it corrupted yet still recognizable.

Translate will transform single piece of text. If more parameter tuning needed, New returns instance of Vonny with custom settings applied

Translate performs NFC transformation to make sure that characters are in same normal form.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Translate

func Translate(tag language.Tag, s string) string

Translate performs transformation with default settings. It will cache created instances of vonny, so no additional overhead is expected.

Types

type Vonny

type Vonny struct {
	// contains filtered or unexported fields
}

Vonny corrupts everything you feed to it. Implements transform.Transformer interface so it can be used in transform.Chain.

func New

func New(config VonnyConfig) *Vonny

New returns customized instance of Vonny. Configuration parameters described in VonnyConfig

func (*Vonny) Reset

func (*Vonny) Reset()

Reset does nothing and exists only to correctly implement transform.Transformer interface

func (*Vonny) Transform

func (vonny *Vonny) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

Transform method applies Vonny transformation to source text

func (*Vonny) Translate

func (vonny *Vonny) Translate(s string) string

Translate transforms text into corrupted version of itself. Uses NFC normalization beforehand.

type VonnyConfig

type VonnyConfig struct {
	VowelExcludeRate float64 // control exclusion of vowels (default: 61.1)
	ExcludeRate      float64 // control exclusion of any character (default: 50.0)
	SwapRate         float64 // how often to swap characters instead of delete (default: 50.0)
	Strength         float64 // rate of changes (default: 50.0)

	Language language.Tag
}

VonnyConfig allows to tune transform parameters

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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