ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - m1/gospin: Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations
Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations - m1/gospin
Visit Site

GitHub - m1/gospin: Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations

GitHub - m1/gospin: Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations

GoSpin

GoDoc Build Status Go Report Card Release Coverage Status

Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations. Use as a library or as a CLI.

Installation

Use go get to get the latest version

go get github.com/m1/gospin

Then import it into your projects using the following:

import (
	"github.com/m1/gospin"
)

What is spintax?

Take this example:

{hello|hey} world

When spinning an article (the above sentence) each of the words/phrases contained within the curly brackets are randomly picked and substituted in the sentence. So for example, the above article could be spun to be: hey world and hello world

You can also have nested spintax, take this example:

{hello|hey} world, {hope {you're|you are} {okay|good}|have a nice day}

A few examples of what the above could output:

  • hey world, hope you're okay
  • hello world, hope you are good
  • hello world, have a nice day
  • etc...

You can also have optional phrases, just don't specify a word after or before a pipe to make it optional:

{hello|hey}{ world|}, how are you today?

A few examples of what the above could output:

  • hey, how are you today?
  • hello world, how are you today?
  • etc...

Why use spintax?

Spintax can be used for several things. It used to be used a lot for spinning articles for SEO but is less useful for that these days. It's more used for A/B testing, testing pieces of text for efficiency/click through rate. Also it is used spinning content for users to keep things fresh, i.e home page text or ai/chat bots.

Usage

To use as a library is pretty simple:

spinner := gospin.New(nil)
simple := "The {slow|quick} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog"

spin := spinner.Spin(simple) // The slow fox jumps over the sleeping dog
spins := spinner.SpinN(simple, 10)
// spins = [
// "The slow fox gracefully jumps over the lazy dog"
// "The slow deer jumps over the sleeping dog"
// "The quick fox jumps over the lazy dog"
// ...
// ]

You can also configure it to take custom syntax (the package uses Jet format as the default), e.g. if you wanted it to set the start and end characters (default are curly brackets) to square brackets:

spinner := gospin.New(&gospin.Config{
        StartChar:     "[",
        EndChar:       "]",
        DelimiterChar: ";",
})
simple := "The [slow;quick] [fox;deer] [gracefully ;]jumps over the [sleeping;lazy] dog"
spin := spinner.Spin(simple) // The slow fox jumps over the sleeping dog

Escaping

To escape, the default character to use is \\, e.g:

The \{slow|quick\} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog

Would output something like:

The {slow|quick} fox jumps over the sleeping dog

You can customize the escape char in the config:

spinner := gospin.New(&gospin.Config{
        EscapeChar:    "@",
})
simple := "The @{slow|quick@} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog"
spin := spinner.Spin(simple) // The @{slow|quick@} fox jumps over the sleeping dog

Random seeds

The spin by default generates a random seed each spin, to stop this and use your own global rand seed you can use the UseGlobalRand toggle in the config. This is useful for testing:

spinner := gospin.New(&gospin.Config{
        UseGlobalRand: false,
})

CLI usage

GoSpin can also be used on the cli, just install using: go get github.com/m1/gospin/cmd/gospin

To use:

โžœ  ~ gospin --help                    
GoSpin is a fast and configurable article spinning and spintax engine written in Go.

Usage:
  gospin [text] [flags]

Flags:
      --delimiter string   Delimiter char (default "|")
      --end string         End char for the spinning engine (default "}")
      --escape string      Escape char (default "\\")
  -h, --help               help for gospin
      --start string       Start char for the spinning engine (default "{")
      --times int          How many articles to generate (default 1)

For example:

โžœ  ~ gospin "{hello|hey} friend"                     
hey friend

To spin multiple, use the times flag, this is outputted as json for easier parsing:

โžœ  ~ gospin "The {slow|quick} {fox|deer} {gracefully |}jumps over the {sleeping|lazy} dog" --times=5 | jq
[
  "The slow fox gracefully jumps over the sleeping dog",
  "The slow deer jumps over the lazy dog",
  "The quick deer jumps over the sleeping dog",
  "The slow fox gracefully jumps over the sleeping dog",
  "The quick fox jumps over the lazy dog"
]

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory