To train an original model, follow these steps:
- Prepare a training corpus consisting of an array of sentences, where each sentence is an array of
[token, part-of-speech-tag] pairs. - Initialize a new instance:
var rma = new RakutenMA();. - Set the
featset (e.g., rma.featset = RakutenMA.default_featset_ja;). - Iterate through your corpus and call
rma.train_one(sentence) for each sentence.
Training typically converges after one epoch (one full pass through the corpus), but performing 2-3 additional epochs can improve accuracy. Reference scripts/train_ja.js or scripts/train_zh.js for implementation examples.
var rma = new RakutenMA();
rma.featset = RakutenMA.default_featset_ja;
// Example training data format
var corpus = [
[["うらにわ", "N-nc"], ["に", "P-k"], ["は", "P-rj"]],
// ... more sentences
];
// Train
corpus.forEach(sentence => {
rma.train_one(sentence);
});