1.0.12 • Published 3 years ago

markov-ja v1.0.12

Weekly downloads
12
License
MIT
Repository
github
Last release
3 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

3 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago