rafatbiin / gongram

Ngram generator in Go that just works

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gongram CI

Ngram generator in Go that just works.

Overview

gongram provides a Go package which generates Ngrams of given gram size from given text. It has support for unicode language as well. It'll remove all the punctuations but keep the cases of the letters untouched.

In addition this library provides a CLI to perform the above operation via console.

Installing

To start using gongram, install Go and run go get:

$ go get github.com/rafatbiin/gongram/...

This will retrieve the library and install the gongram command line utility into your $GOBIN path.

Generating Ngram

package main

import (
	"fmt"
	"github.com/rafatbiin/gongram"
)

func main()  {
	text := "It’s not about ideas. It’s about making ideas happen!"
	ngrams, err:= gongram.Generate(text, 4) // ["Its not about ideas","not about ideas Its","about ideas Its about","ideas Its about making","Its about making ideas","about making ideas happen"]
	if err != nil {
		// Handle error
	}
	...
}

CLI

$ gongram ngram -g 4 It’s not about ideas. It’s about making ideas happen!
["Its not about ideas","not about ideas Its","about ideas Its about","ideas Its about making","Its about making ideas","about making ideas happen"]

About

Ngram generator in Go that just works

License:MIT License


Languages

Language:Go 100.0%