Skip to content

surzia/go-n-gram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

This is an N-gram model implemented by go.

N-gram

A language model is a probability distribution over sequences of words W, namely:

eq1

According to the chain rule,

eq2

We can use Maximum Likelihood Estimation

eq3

Usage

You can run it directly, as:

go run . -word "中国"

or run it after compilation:

go build .
./go-n-gram -word "中国"

the output is:

The next word is 人, probability is 0.071429
The next word is 扶, probability is 0.055556
The next word is 的, probability is 0.039683
The next word is 社, probability is 0.039683
The next word is ,, probability is 0.039683
......

Releases

No releases published

Packages

No packages published

Languages