1.0.12 • Published 2 years ago

markov-ja v1.0.12

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

markov-ja

Requirements

You need to install MeCab before using this package.

How to use

$ npm install -S markov-ja

Try this:

const MarkovJa = require('markov-ja')

var markov = new MarkovJa()

// Maybe you want to load the database from file…?
const path = 'triplets_db.json'
markov.loadDatabase(fs.readFileSync(path, 'utf-8'))

var text = fs.readFileSync('in.txt', 'utf-8')
markov.learn(text)

// Now your original texts are generated with the power of markov chain
console.log(markov.generate().join('\n'))

// Maybe you want to save the database to file…?
fs.writeFileSync(path, markov.exportDatabase(), 'utf-8')
// You can change the options for mecab command
markov.mecab.commandOptions = '-d /usr/local/lib/mecab/dic/mecab-ipadic-neologd/'

For more information, please see my source code.

There are Japanese jsdoc in the code.

1.0.12

2 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago